Mercurial > emacs
annotate src/doc.c @ 60712:d37e83a20683
(isearch-lazy-highlight-new-loop):
Make arguments beg and end optional.
(isearch-update): Remove optional arguments nil from
isearch-lazy-highlight-new-loop.
(isearch-lazy-highlight-search): Let-bind case-fold-search to
isearch-lazy-highlight-case-fold-search instead of
isearch-case-fold-search, and let-bind isearch-regexp to
isearch-lazy-highlight-regexp. Use
isearch-lazy-highlight-last-string instead of isearch-string.
author | Juri Linkov <juri@jurta.org> |
---|---|
date | Fri, 18 Mar 2005 09:59:31 +0000 |
parents | 1f66922e7ad0 |
children | a8fa7c632ee4 29e773288013 |
rev | line source |
---|---|
297 | 1 /* Record indices of function doc strings stored in a file. |
54745
98cf37e32872
(Fsnarf_documentation): Ignore new file name entries.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54234
diff
changeset
|
2 Copyright (C) 1985, 86,93,94,95,97,98,99,2000,04 |
98cf37e32872
(Fsnarf_documentation): Ignore new file name entries.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54234
diff
changeset
|
3 Free Software Foundation, Inc. |
297 | 4 |
5 This file is part of GNU Emacs. | |
6 | |
7 GNU Emacs is free software; you can redistribute it and/or modify | |
8 it under the terms of the GNU General Public License as published by | |
10344
a6e8525a1a9d
(store_function_docstring, Fdocumentation): Use & PSEUDOVECTOR_SIZE_MASK on
Roland McGrath <roland@gnu.org>
parents:
10330
diff
changeset
|
9 the Free Software Foundation; either version 2, or (at your option) |
297 | 10 any later version. |
11 | |
12 GNU Emacs is distributed in the hope that it will be useful, | |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 GNU General Public License for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with GNU Emacs; see the file COPYING. If not, write to | |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14069
diff
changeset
|
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14069
diff
changeset
|
20 Boston, MA 02111-1307, USA. */ |
297 | 21 |
22 | |
4696
1fc792473491
Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents:
3999
diff
changeset
|
23 #include <config.h> |
297 | 24 |
25 #include <sys/types.h> | |
26 #include <sys/file.h> /* Must be after sys/types.h for USG and BSD4_1*/ | |
58087 | 27 #include <ctype.h> |
297 | 28 |
51402 | 29 #ifdef HAVE_FCNTL_H |
297 | 30 #include <fcntl.h> |
31 #endif | |
32 | |
6862
653504b6b5dd
[HAVE_UNISTD_H]: Include unistd.h.
Richard M. Stallman <rms@gnu.org>
parents:
6030
diff
changeset
|
33 #ifdef HAVE_UNISTD_H |
653504b6b5dd
[HAVE_UNISTD_H]: Include unistd.h.
Richard M. Stallman <rms@gnu.org>
parents:
6030
diff
changeset
|
34 #include <unistd.h> |
653504b6b5dd
[HAVE_UNISTD_H]: Include unistd.h.
Richard M. Stallman <rms@gnu.org>
parents:
6030
diff
changeset
|
35 #endif |
653504b6b5dd
[HAVE_UNISTD_H]: Include unistd.h.
Richard M. Stallman <rms@gnu.org>
parents:
6030
diff
changeset
|
36 |
297 | 37 #ifndef O_RDONLY |
38 #define O_RDONLY 0 | |
39 #endif | |
40 | |
41 #include "lisp.h" | |
42 #include "buffer.h" | |
1511
ff88f962a982
* doc.c: #include keyboard.h.
Jim Blandy <jimb@redhat.com>
parents:
1116
diff
changeset
|
43 #include "keyboard.h" |
20619 | 44 #include "charset.h" |
39697
0b986bb45526
Include keymap.h.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39675
diff
changeset
|
45 #include "keymap.h" |
297 | 46 |
31336 | 47 #ifdef HAVE_INDEX |
48 extern char *index P_ ((const char *, int)); | |
31225
7930c46bb365
(toplevel) [HAVE_STRING_H]: Include string.h.
Gerd Moellmann <gerd@gnu.org>
parents:
30154
diff
changeset
|
49 #endif |
7930c46bb365
(toplevel) [HAVE_STRING_H]: Include string.h.
Gerd Moellmann <gerd@gnu.org>
parents:
30154
diff
changeset
|
50 |
40139
0600331ddd52
(Vhelp_manyarg_func_alist): Variable removed.
Miles Bader <miles@gnu.org>
parents:
39973
diff
changeset
|
51 Lisp_Object Vdoc_file_name; |
297 | 52 |
28334
f9cb3463ee2a
(Qfunction_documentation): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
28036
diff
changeset
|
53 Lisp_Object Qfunction_documentation; |
f9cb3463ee2a
(Qfunction_documentation): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
28036
diff
changeset
|
54 |
58068
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
55 /* A list of files used to build this Emacs binary. */ |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
56 static Lisp_Object Vbuild_files; |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
57 |
5784
9c3be8e0d2ef
(Fsubstitute_command_keys): Pass keymap as that arg
Richard M. Stallman <rms@gnu.org>
parents:
5550
diff
changeset
|
58 extern Lisp_Object Voverriding_local_map; |
9c3be8e0d2ef
(Fsubstitute_command_keys): Pass keymap as that arg
Richard M. Stallman <rms@gnu.org>
parents:
5550
diff
changeset
|
59 |
9087
e3c272c7f4d2
(get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents:
8823
diff
changeset
|
60 /* For VMS versions with limited file name syntax, |
60388
1f66922e7ad0
(munge_doc_file_name) [VMS]: Use NO_HYPHENS_IN_FILENAMES, not VMS4_4.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
60065
diff
changeset
|
61 convert the name to something VMS will allow. */ |
9087
e3c272c7f4d2
(get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents:
8823
diff
changeset
|
62 static void |
e3c272c7f4d2
(get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents:
8823
diff
changeset
|
63 munge_doc_file_name (name) |
e3c272c7f4d2
(get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents:
8823
diff
changeset
|
64 char *name; |
297 | 65 { |
66 #ifdef VMS | |
60388
1f66922e7ad0
(munge_doc_file_name) [VMS]: Use NO_HYPHENS_IN_FILENAMES, not VMS4_4.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
60065
diff
changeset
|
67 #ifndef NO_HYPHENS_IN_FILENAMES |
1f66922e7ad0
(munge_doc_file_name) [VMS]: Use NO_HYPHENS_IN_FILENAMES, not VMS4_4.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
60065
diff
changeset
|
68 extern char * sys_translate_unix (char *ufile); |
1f66922e7ad0
(munge_doc_file_name) [VMS]: Use NO_HYPHENS_IN_FILENAMES, not VMS4_4.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
60065
diff
changeset
|
69 strcpy (name, sys_translate_unix (name)); |
1f66922e7ad0
(munge_doc_file_name) [VMS]: Use NO_HYPHENS_IN_FILENAMES, not VMS4_4.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
60065
diff
changeset
|
70 #else /* NO_HYPHENS_IN_FILENAMES */ |
1f66922e7ad0
(munge_doc_file_name) [VMS]: Use NO_HYPHENS_IN_FILENAMES, not VMS4_4.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
60065
diff
changeset
|
71 char *p = name; |
297 | 72 while (*p) |
73 { | |
74 if (*p == '-') | |
75 *p = '_'; | |
76 p++; | |
77 } | |
60388
1f66922e7ad0
(munge_doc_file_name) [VMS]: Use NO_HYPHENS_IN_FILENAMES, not VMS4_4.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
60065
diff
changeset
|
78 #endif /* NO_HYPHENS_IN_FILENAMES */ |
297 | 79 #endif /* VMS */ |
9087
e3c272c7f4d2
(get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents:
8823
diff
changeset
|
80 } |
e3c272c7f4d2
(get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents:
8823
diff
changeset
|
81 |
14648
45d13c154bb4
(get_doc_string): Move static vars outside the function,
Richard M. Stallman <rms@gnu.org>
parents:
14552
diff
changeset
|
82 /* Buffer used for reading from documentation file. */ |
45d13c154bb4
(get_doc_string): Move static vars outside the function,
Richard M. Stallman <rms@gnu.org>
parents:
14552
diff
changeset
|
83 static char *get_doc_string_buffer; |
45d13c154bb4
(get_doc_string): Move static vars outside the function,
Richard M. Stallman <rms@gnu.org>
parents:
14552
diff
changeset
|
84 static int get_doc_string_buffer_size; |
45d13c154bb4
(get_doc_string): Move static vars outside the function,
Richard M. Stallman <rms@gnu.org>
parents:
14552
diff
changeset
|
85 |
22690
31bc848c5f18
(get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents:
22602
diff
changeset
|
86 static unsigned char *read_bytecode_pointer; |
41823
e192139240f2
(Fsnarf_documentation): Add prototype.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41218
diff
changeset
|
87 Lisp_Object Fsnarf_documentation P_ ((Lisp_Object)); |
22690
31bc848c5f18
(get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents:
22602
diff
changeset
|
88 |
31bc848c5f18
(get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents:
22602
diff
changeset
|
89 /* readchar in lread.c calls back here to fetch the next byte. |
31bc848c5f18
(get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents:
22602
diff
changeset
|
90 If UNREADFLAG is 1, we unread a byte. */ |
31bc848c5f18
(get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents:
22602
diff
changeset
|
91 |
31bc848c5f18
(get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents:
22602
diff
changeset
|
92 int |
31bc848c5f18
(get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents:
22602
diff
changeset
|
93 read_bytecode_char (unreadflag) |
25758
fca9459a0555
(read_bytecode_char): Declare arg.
Dave Love <fx@gnu.org>
parents:
25662
diff
changeset
|
94 int unreadflag; |
22690
31bc848c5f18
(get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents:
22602
diff
changeset
|
95 { |
31bc848c5f18
(get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents:
22602
diff
changeset
|
96 if (unreadflag) |
31bc848c5f18
(get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents:
22602
diff
changeset
|
97 { |
31bc848c5f18
(get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents:
22602
diff
changeset
|
98 read_bytecode_pointer--; |
31bc848c5f18
(get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents:
22602
diff
changeset
|
99 return 0; |
31bc848c5f18
(get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents:
22602
diff
changeset
|
100 } |
31bc848c5f18
(get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents:
22602
diff
changeset
|
101 return *read_bytecode_pointer++; |
31bc848c5f18
(get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents:
22602
diff
changeset
|
102 } |
31bc848c5f18
(get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents:
22602
diff
changeset
|
103 |
10202
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
104 /* Extract a doc string from a file. FILEPOS says where to get it. |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
105 If it is an integer, use that position in the standard DOC-... file. |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
106 If it is (FILE . INTEGER), use FILE as the file name |
11252
f610f9d7e3ca
(get_doc_string): In (STRING . INTEGER), if INTEGER
Richard M. Stallman <rms@gnu.org>
parents:
10345
diff
changeset
|
107 and INTEGER as the position in that file. |
f610f9d7e3ca
(get_doc_string): In (STRING . INTEGER), if INTEGER
Richard M. Stallman <rms@gnu.org>
parents:
10345
diff
changeset
|
108 But if INTEGER is negative, make it positive. |
f610f9d7e3ca
(get_doc_string): In (STRING . INTEGER), if INTEGER
Richard M. Stallman <rms@gnu.org>
parents:
10345
diff
changeset
|
109 (A negative integer is used for user variables, so we can distinguish |
22043
10a9f355a346
(get_doc_string): New arg UNIBYTE
Richard M. Stallman <rms@gnu.org>
parents:
21514
diff
changeset
|
110 them without actually fetching the doc string.) |
10a9f355a346
(get_doc_string): New arg UNIBYTE
Richard M. Stallman <rms@gnu.org>
parents:
21514
diff
changeset
|
111 |
44324
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
112 If the location does not point to the beginning of a docstring |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
113 (e.g. because the file has been modified and the location is stale), |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
114 return nil. |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
115 |
22602
9c6b3b9c3c8f
(get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents:
22562
diff
changeset
|
116 If UNIBYTE is nonzero, always make a unibyte string. |
9c6b3b9c3c8f
(get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents:
22562
diff
changeset
|
117 |
22562
ddb3fd464b77
(get_doc_string): 2nd arg is now DEFINITION;
Richard M. Stallman <rms@gnu.org>
parents:
22268
diff
changeset
|
118 If DEFINITION is nonzero, assume this is for reading |
ddb3fd464b77
(get_doc_string): 2nd arg is now DEFINITION;
Richard M. Stallman <rms@gnu.org>
parents:
22268
diff
changeset
|
119 a dynamic function definition; convert the bytestring |
ddb3fd464b77
(get_doc_string): 2nd arg is now DEFINITION;
Richard M. Stallman <rms@gnu.org>
parents:
22268
diff
changeset
|
120 and the constants vector with appropriate byte handling, |
ddb3fd464b77
(get_doc_string): 2nd arg is now DEFINITION;
Richard M. Stallman <rms@gnu.org>
parents:
22268
diff
changeset
|
121 and return a cons cell. */ |
10202
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
122 |
22268
9308a15aa8f8
(get_doc_string): Make non-static.
Richard M. Stallman <rms@gnu.org>
parents:
22043
diff
changeset
|
123 Lisp_Object |
22602
9c6b3b9c3c8f
(get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents:
22562
diff
changeset
|
124 get_doc_string (filepos, unibyte, definition) |
10202
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
125 Lisp_Object filepos; |
22602
9c6b3b9c3c8f
(get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents:
22562
diff
changeset
|
126 int unibyte, definition; |
9087
e3c272c7f4d2
(get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents:
8823
diff
changeset
|
127 { |
10202
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
128 char *from, *to; |
9087
e3c272c7f4d2
(get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents:
8823
diff
changeset
|
129 register int fd; |
e3c272c7f4d2
(get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents:
8823
diff
changeset
|
130 register char *name; |
e3c272c7f4d2
(get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents:
8823
diff
changeset
|
131 register char *p, *p1; |
e3c272c7f4d2
(get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents:
8823
diff
changeset
|
132 int minsize; |
14552
e6f31368feeb
(get_doc_string): Always read entire disk blocks.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
133 int offset, position; |
10202
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
134 Lisp_Object file, tem; |
9087
e3c272c7f4d2
(get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents:
8823
diff
changeset
|
135 |
10202
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
136 if (INTEGERP (filepos)) |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
137 { |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
138 file = Vdoc_file_name; |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
139 position = XINT (filepos); |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
140 } |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
141 else if (CONSP (filepos)) |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
142 { |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
24573
diff
changeset
|
143 file = XCAR (filepos); |
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
24573
diff
changeset
|
144 position = XINT (XCDR (filepos)); |
10202
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
145 } |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
146 else |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
147 return Qnil; |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
148 |
41823
e192139240f2
(Fsnarf_documentation): Add prototype.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41218
diff
changeset
|
149 if (position < 0) |
e192139240f2
(Fsnarf_documentation): Add prototype.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41218
diff
changeset
|
150 position = - position; |
e192139240f2
(Fsnarf_documentation): Add prototype.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41218
diff
changeset
|
151 |
10202
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
152 if (!STRINGP (Vdoc_directory)) |
9087
e3c272c7f4d2
(get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents:
8823
diff
changeset
|
153 return Qnil; |
e3c272c7f4d2
(get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents:
8823
diff
changeset
|
154 |
10202
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
155 if (!STRINGP (file)) |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
156 return Qnil; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
157 |
10202
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
158 /* Put the file name in NAME as a C string. |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
159 If it is relative, combine it with Vdoc_directory. */ |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
160 |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
161 tem = Ffile_name_absolute_p (file); |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
162 if (NILP (tem)) |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
163 { |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45368
diff
changeset
|
164 minsize = SCHARS (Vdoc_directory); |
10202
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
165 /* sizeof ("../etc/") == 8 */ |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
166 if (minsize < 8) |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
167 minsize = 8; |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45368
diff
changeset
|
168 name = (char *) alloca (minsize + SCHARS (file) + 8); |
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45368
diff
changeset
|
169 strcpy (name, SDATA (Vdoc_directory)); |
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45368
diff
changeset
|
170 strcat (name, SDATA (file)); |
10202
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
171 munge_doc_file_name (name); |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
172 } |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
173 else |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
174 { |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45368
diff
changeset
|
175 name = (char *) SDATA (file); |
10202
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
176 } |
297 | 177 |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26076
diff
changeset
|
178 fd = emacs_open (name, O_RDONLY, 0); |
297 | 179 if (fd < 0) |
9087
e3c272c7f4d2
(get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents:
8823
diff
changeset
|
180 { |
e3c272c7f4d2
(get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents:
8823
diff
changeset
|
181 #ifndef CANNOT_DUMP |
e3c272c7f4d2
(get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents:
8823
diff
changeset
|
182 if (!NILP (Vpurify_flag)) |
e3c272c7f4d2
(get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents:
8823
diff
changeset
|
183 { |
e3c272c7f4d2
(get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents:
8823
diff
changeset
|
184 /* Preparing to dump; DOC file is probably not installed. |
e3c272c7f4d2
(get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents:
8823
diff
changeset
|
185 So check in ../etc. */ |
e3c272c7f4d2
(get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents:
8823
diff
changeset
|
186 strcpy (name, "../etc/"); |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45368
diff
changeset
|
187 strcat (name, SDATA (file)); |
9087
e3c272c7f4d2
(get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents:
8823
diff
changeset
|
188 munge_doc_file_name (name); |
e3c272c7f4d2
(get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents:
8823
diff
changeset
|
189 |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26076
diff
changeset
|
190 fd = emacs_open (name, O_RDONLY, 0); |
9087
e3c272c7f4d2
(get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents:
8823
diff
changeset
|
191 } |
e3c272c7f4d2
(get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents:
8823
diff
changeset
|
192 #endif |
e3c272c7f4d2
(get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents:
8823
diff
changeset
|
193 if (fd < 0) |
e3c272c7f4d2
(get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents:
8823
diff
changeset
|
194 error ("Cannot open doc string file \"%s\"", name); |
e3c272c7f4d2
(get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents:
8823
diff
changeset
|
195 } |
e3c272c7f4d2
(get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents:
8823
diff
changeset
|
196 |
14552
e6f31368feeb
(get_doc_string): Always read entire disk blocks.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
197 /* Seek only to beginning of disk block. */ |
44324
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
198 /* Make sure we read at least 1024 bytes before `position' |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
199 so we can check the leading text for consistency. */ |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
200 offset = min (position, max (1024, position % (8 * 1024))); |
14552
e6f31368feeb
(get_doc_string): Always read entire disk blocks.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
201 if (0 > lseek (fd, position - offset, 0)) |
297 | 202 { |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26076
diff
changeset
|
203 emacs_close (fd); |
297 | 204 error ("Position %ld out of range in doc string file \"%s\"", |
10202
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
205 position, name); |
297 | 206 } |
10202
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
207 |
14648
45d13c154bb4
(get_doc_string): Move static vars outside the function,
Richard M. Stallman <rms@gnu.org>
parents:
14552
diff
changeset
|
208 /* Read the doc string into get_doc_string_buffer. |
45d13c154bb4
(get_doc_string): Move static vars outside the function,
Richard M. Stallman <rms@gnu.org>
parents:
14552
diff
changeset
|
209 P points beyond the data just read. */ |
10202
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
210 |
14648
45d13c154bb4
(get_doc_string): Move static vars outside the function,
Richard M. Stallman <rms@gnu.org>
parents:
14552
diff
changeset
|
211 p = get_doc_string_buffer; |
10202
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
212 while (1) |
297 | 213 { |
14648
45d13c154bb4
(get_doc_string): Move static vars outside the function,
Richard M. Stallman <rms@gnu.org>
parents:
14552
diff
changeset
|
214 int space_left = (get_doc_string_buffer_size |
45d13c154bb4
(get_doc_string): Move static vars outside the function,
Richard M. Stallman <rms@gnu.org>
parents:
14552
diff
changeset
|
215 - (p - get_doc_string_buffer)); |
10202
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
216 int nread; |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
217 |
14552
e6f31368feeb
(get_doc_string): Always read entire disk blocks.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
218 /* Allocate or grow the buffer if we need to. */ |
10202
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
219 if (space_left == 0) |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
220 { |
14648
45d13c154bb4
(get_doc_string): Move static vars outside the function,
Richard M. Stallman <rms@gnu.org>
parents:
14552
diff
changeset
|
221 int in_buffer = p - get_doc_string_buffer; |
45d13c154bb4
(get_doc_string): Move static vars outside the function,
Richard M. Stallman <rms@gnu.org>
parents:
14552
diff
changeset
|
222 get_doc_string_buffer_size += 16 * 1024; |
45d13c154bb4
(get_doc_string): Move static vars outside the function,
Richard M. Stallman <rms@gnu.org>
parents:
14552
diff
changeset
|
223 get_doc_string_buffer |
45d13c154bb4
(get_doc_string): Move static vars outside the function,
Richard M. Stallman <rms@gnu.org>
parents:
14552
diff
changeset
|
224 = (char *) xrealloc (get_doc_string_buffer, |
45d13c154bb4
(get_doc_string): Move static vars outside the function,
Richard M. Stallman <rms@gnu.org>
parents:
14552
diff
changeset
|
225 get_doc_string_buffer_size + 1); |
45d13c154bb4
(get_doc_string): Move static vars outside the function,
Richard M. Stallman <rms@gnu.org>
parents:
14552
diff
changeset
|
226 p = get_doc_string_buffer + in_buffer; |
45d13c154bb4
(get_doc_string): Move static vars outside the function,
Richard M. Stallman <rms@gnu.org>
parents:
14552
diff
changeset
|
227 space_left = (get_doc_string_buffer_size |
45d13c154bb4
(get_doc_string): Move static vars outside the function,
Richard M. Stallman <rms@gnu.org>
parents:
14552
diff
changeset
|
228 - (p - get_doc_string_buffer)); |
10202
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
229 } |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
230 |
14552
e6f31368feeb
(get_doc_string): Always read entire disk blocks.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
231 /* Read a disk block at a time. |
e6f31368feeb
(get_doc_string): Always read entire disk blocks.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
232 If we read the same block last time, maybe skip this? */ |
10202
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
233 if (space_left > 1024 * 8) |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
234 space_left = 1024 * 8; |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26076
diff
changeset
|
235 nread = emacs_read (fd, p, space_left); |
10202
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
236 if (nread < 0) |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
237 { |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26076
diff
changeset
|
238 emacs_close (fd); |
10202
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
239 error ("Read error on documentation file"); |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
240 } |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
241 p[nread] = 0; |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
242 if (!nread) |
297 | 243 break; |
14648
45d13c154bb4
(get_doc_string): Move static vars outside the function,
Richard M. Stallman <rms@gnu.org>
parents:
14552
diff
changeset
|
244 if (p == get_doc_string_buffer) |
31225
7930c46bb365
(toplevel) [HAVE_STRING_H]: Include string.h.
Gerd Moellmann <gerd@gnu.org>
parents:
30154
diff
changeset
|
245 p1 = (char *) index (p + offset, '\037'); |
14552
e6f31368feeb
(get_doc_string): Always read entire disk blocks.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
246 else |
31225
7930c46bb365
(toplevel) [HAVE_STRING_H]: Include string.h.
Gerd Moellmann <gerd@gnu.org>
parents:
30154
diff
changeset
|
247 p1 = (char *) index (p, '\037'); |
297 | 248 if (p1) |
249 { | |
250 *p1 = 0; | |
251 p = p1; | |
252 break; | |
253 } | |
10202
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
254 p += nread; |
297 | 255 } |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26076
diff
changeset
|
256 emacs_close (fd); |
10202
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
257 |
44324
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
258 /* Sanity checking. */ |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
259 if (CONSP (filepos)) |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
260 { |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
261 int test = 1; |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
262 if (get_doc_string_buffer[offset - test++] != ' ') |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
263 return Qnil; |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
264 while (get_doc_string_buffer[offset - test] >= '0' |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
265 && get_doc_string_buffer[offset - test] <= '9') |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
266 test++; |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
267 if (get_doc_string_buffer[offset - test++] != '@' |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
268 || get_doc_string_buffer[offset - test] != '#') |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
269 return Qnil; |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
270 } |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
271 else |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
272 { |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
273 int test = 1; |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
274 if (get_doc_string_buffer[offset - test++] != '\n') |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
275 return Qnil; |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
276 while (get_doc_string_buffer[offset - test] > ' ') |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
277 test++; |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
278 if (get_doc_string_buffer[offset - test] != '\037') |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
279 return Qnil; |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
280 } |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
281 |
10202
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
282 /* Scan the text and perform quoting with ^A (char code 1). |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
283 ^A^A becomes ^A, ^A0 becomes a null char, and ^A_ becomes a ^_. */ |
14648
45d13c154bb4
(get_doc_string): Move static vars outside the function,
Richard M. Stallman <rms@gnu.org>
parents:
14552
diff
changeset
|
284 from = get_doc_string_buffer + offset; |
45d13c154bb4
(get_doc_string): Move static vars outside the function,
Richard M. Stallman <rms@gnu.org>
parents:
14552
diff
changeset
|
285 to = get_doc_string_buffer + offset; |
10202
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
286 while (from != p) |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
287 { |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
288 if (*from == 1) |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
289 { |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
290 int c; |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
291 |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
292 from++; |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
293 c = *from++; |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
294 if (c == 1) |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
295 *to++ = c; |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
296 else if (c == '0') |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
297 *to++ = 0; |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
298 else if (c == '_') |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
299 *to++ = 037; |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
300 else |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
301 error ("Invalid data in documentation file -- ^A followed by code 0%o", c); |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
302 } |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
303 else |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
304 *to++ = *from++; |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
305 } |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
306 |
22690
31bc848c5f18
(get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents:
22602
diff
changeset
|
307 /* If DEFINITION, read from this buffer |
31bc848c5f18
(get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents:
22602
diff
changeset
|
308 the same way we would read bytes from a file. */ |
22562
ddb3fd464b77
(get_doc_string): 2nd arg is now DEFINITION;
Richard M. Stallman <rms@gnu.org>
parents:
22268
diff
changeset
|
309 if (definition) |
ddb3fd464b77
(get_doc_string): 2nd arg is now DEFINITION;
Richard M. Stallman <rms@gnu.org>
parents:
22268
diff
changeset
|
310 { |
22690
31bc848c5f18
(get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents:
22602
diff
changeset
|
311 read_bytecode_pointer = get_doc_string_buffer + offset; |
31bc848c5f18
(get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents:
22602
diff
changeset
|
312 return Fread (Qlambda); |
22562
ddb3fd464b77
(get_doc_string): 2nd arg is now DEFINITION;
Richard M. Stallman <rms@gnu.org>
parents:
22268
diff
changeset
|
313 } |
ddb3fd464b77
(get_doc_string): 2nd arg is now DEFINITION;
Richard M. Stallman <rms@gnu.org>
parents:
22268
diff
changeset
|
314 |
22602
9c6b3b9c3c8f
(get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents:
22562
diff
changeset
|
315 if (unibyte) |
9c6b3b9c3c8f
(get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents:
22562
diff
changeset
|
316 return make_unibyte_string (get_doc_string_buffer + offset, |
9c6b3b9c3c8f
(get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents:
22562
diff
changeset
|
317 to - (get_doc_string_buffer + offset)); |
9c6b3b9c3c8f
(get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents:
22562
diff
changeset
|
318 else |
24573
aa24b1cb428a
(get_doc_string): When UNIBYTE and DEFINITION are 0,
Richard M. Stallman <rms@gnu.org>
parents:
23921
diff
changeset
|
319 { |
aa24b1cb428a
(get_doc_string): When UNIBYTE and DEFINITION are 0,
Richard M. Stallman <rms@gnu.org>
parents:
23921
diff
changeset
|
320 /* Let the data determine whether the string is multibyte, |
aa24b1cb428a
(get_doc_string): When UNIBYTE and DEFINITION are 0,
Richard M. Stallman <rms@gnu.org>
parents:
23921
diff
changeset
|
321 even if Emacs is running in --unibyte mode. */ |
aa24b1cb428a
(get_doc_string): When UNIBYTE and DEFINITION are 0,
Richard M. Stallman <rms@gnu.org>
parents:
23921
diff
changeset
|
322 int nchars = multibyte_chars_in_text (get_doc_string_buffer + offset, |
aa24b1cb428a
(get_doc_string): When UNIBYTE and DEFINITION are 0,
Richard M. Stallman <rms@gnu.org>
parents:
23921
diff
changeset
|
323 to - (get_doc_string_buffer + offset)); |
aa24b1cb428a
(get_doc_string): When UNIBYTE and DEFINITION are 0,
Richard M. Stallman <rms@gnu.org>
parents:
23921
diff
changeset
|
324 return make_string_from_bytes (get_doc_string_buffer + offset, |
aa24b1cb428a
(get_doc_string): When UNIBYTE and DEFINITION are 0,
Richard M. Stallman <rms@gnu.org>
parents:
23921
diff
changeset
|
325 nchars, |
aa24b1cb428a
(get_doc_string): When UNIBYTE and DEFINITION are 0,
Richard M. Stallman <rms@gnu.org>
parents:
23921
diff
changeset
|
326 to - (get_doc_string_buffer + offset)); |
aa24b1cb428a
(get_doc_string): When UNIBYTE and DEFINITION are 0,
Richard M. Stallman <rms@gnu.org>
parents:
23921
diff
changeset
|
327 } |
10202
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
328 } |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
329 |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
330 /* Get a string from position FILEPOS and pass it through the Lisp reader. |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
331 We use this for fetching the bytecode string and constants vector |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
332 of a compiled function from the .elc file. */ |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
333 |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
334 Lisp_Object |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
335 read_doc_string (filepos) |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
336 Lisp_Object filepos; |
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
337 { |
22602
9c6b3b9c3c8f
(get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents:
22562
diff
changeset
|
338 return get_doc_string (filepos, 0, 1); |
297 | 339 } |
340 | |
44348
80c9e94bec17
(reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44324
diff
changeset
|
341 static int |
44324
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
342 reread_doc_file (file) |
44355
412b4760216b
(reread_doc_file): Add missing argument declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44348
diff
changeset
|
343 Lisp_Object file; |
44324
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
344 { |
45368
65ad2c8b301b
(reread_doc_file): Don't ask for confirmation.
Richard M. Stallman <rms@gnu.org>
parents:
44385
diff
changeset
|
345 #if 0 |
44324
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
346 Lisp_Object reply, prompt[3]; |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
347 struct gcpro gcpro1; |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
348 GCPRO1 (file); |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
349 prompt[0] = build_string ("File "); |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
350 prompt[1] = NILP (file) ? Vdoc_file_name : file; |
45368
65ad2c8b301b
(reread_doc_file): Don't ask for confirmation.
Richard M. Stallman <rms@gnu.org>
parents:
44385
diff
changeset
|
351 prompt[2] = build_string (" is out of sync. Reload? "); |
44324
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
352 reply = Fy_or_n_p (Fconcat (3, prompt)); |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
353 UNGCPRO; |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
354 if (NILP (reply)) |
44348
80c9e94bec17
(reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44324
diff
changeset
|
355 return 0; |
45368
65ad2c8b301b
(reread_doc_file): Don't ask for confirmation.
Richard M. Stallman <rms@gnu.org>
parents:
44385
diff
changeset
|
356 #endif |
44324
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
357 |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
358 if (NILP (file)) |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
359 Fsnarf_documentation (Vdoc_file_name); |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
360 else |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
361 Fload (file, Qt, Qt, Qt, Qnil); |
44348
80c9e94bec17
(reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44324
diff
changeset
|
362 |
80c9e94bec17
(reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44324
diff
changeset
|
363 return 1; |
44324
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
364 } |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
365 |
570 | 366 DEFUN ("documentation", Fdocumentation, Sdocumentation, 1, 2, 0, |
41001
a17c8b15ef1b
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40702
diff
changeset
|
367 doc: /* Return the documentation string of FUNCTION. |
a17c8b15ef1b
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40702
diff
changeset
|
368 Unless a non-nil second argument RAW is given, the |
a17c8b15ef1b
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40702
diff
changeset
|
369 string is passed through `substitute-command-keys'. */) |
a17c8b15ef1b
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40702
diff
changeset
|
370 (function, raw) |
647 | 371 Lisp_Object function, raw; |
297 | 372 { |
373 Lisp_Object fun; | |
374 Lisp_Object funcar; | |
570 | 375 Lisp_Object tem, doc; |
44348
80c9e94bec17
(reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44324
diff
changeset
|
376 int try_reload = 1; |
80c9e94bec17
(reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44324
diff
changeset
|
377 |
80c9e94bec17
(reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44324
diff
changeset
|
378 documentation: |
297 | 379 |
34363
62a349fc3d3c
(Fsubstitute_command_keys): Change the way buffers
Gerd Moellmann <gerd@gnu.org>
parents:
32988
diff
changeset
|
380 doc = Qnil; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
381 |
28334
f9cb3463ee2a
(Qfunction_documentation): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
28036
diff
changeset
|
382 if (SYMBOLP (function) |
f9cb3463ee2a
(Qfunction_documentation): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
28036
diff
changeset
|
383 && (tem = Fget (function, Qfunction_documentation), |
f9cb3463ee2a
(Qfunction_documentation): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
28036
diff
changeset
|
384 !NILP (tem))) |
f9cb3463ee2a
(Qfunction_documentation): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
28036
diff
changeset
|
385 return Fdocumentation_property (function, Qfunction_documentation, raw); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
386 |
647 | 387 fun = Findirect_function (function); |
10002
5b2b7e378772
(Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9958
diff
changeset
|
388 if (SUBRP (fun)) |
297 | 389 { |
28334
f9cb3463ee2a
(Qfunction_documentation): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
28036
diff
changeset
|
390 if (XSUBR (fun)->doc == 0) |
f9cb3463ee2a
(Qfunction_documentation): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
28036
diff
changeset
|
391 return Qnil; |
f9cb3463ee2a
(Qfunction_documentation): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
28036
diff
changeset
|
392 else if ((EMACS_INT) XSUBR (fun)->doc >= 0) |
570 | 393 doc = build_string (XSUBR (fun)->doc); |
297 | 394 else |
41823
e192139240f2
(Fsnarf_documentation): Add prototype.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41218
diff
changeset
|
395 doc = make_number ((EMACS_INT) XSUBR (fun)->doc); |
10002
5b2b7e378772
(Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9958
diff
changeset
|
396 } |
5b2b7e378772
(Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9958
diff
changeset
|
397 else if (COMPILEDP (fun)) |
5b2b7e378772
(Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9958
diff
changeset
|
398 { |
41823
e192139240f2
(Fsnarf_documentation): Add prototype.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41218
diff
changeset
|
399 if ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) <= COMPILED_DOC_STRING) |
297 | 400 return Qnil; |
41823
e192139240f2
(Fsnarf_documentation): Add prototype.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41218
diff
changeset
|
401 tem = AREF (fun, COMPILED_DOC_STRING); |
9133
48820d57a24c
(get_doc_string, Fdocumentation, Fdocumentation_property,
Karl Heuer <kwzh@gnu.org>
parents:
9087
diff
changeset
|
402 if (STRINGP (tem)) |
570 | 403 doc = tem; |
10202
4013c083162e
(get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
10002
diff
changeset
|
404 else if (NATNUMP (tem) || CONSP (tem)) |
41823
e192139240f2
(Fsnarf_documentation): Add prototype.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41218
diff
changeset
|
405 doc = tem; |
570 | 406 else |
407 return Qnil; | |
10002
5b2b7e378772
(Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9958
diff
changeset
|
408 } |
5b2b7e378772
(Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9958
diff
changeset
|
409 else if (STRINGP (fun) || VECTORP (fun)) |
5b2b7e378772
(Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9958
diff
changeset
|
410 { |
297 | 411 return build_string ("Keyboard macro."); |
10002
5b2b7e378772
(Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9958
diff
changeset
|
412 } |
5b2b7e378772
(Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9958
diff
changeset
|
413 else if (CONSP (fun)) |
5b2b7e378772
(Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9958
diff
changeset
|
414 { |
297 | 415 funcar = Fcar (fun); |
9133
48820d57a24c
(get_doc_string, Fdocumentation, Fdocumentation_property,
Karl Heuer <kwzh@gnu.org>
parents:
9087
diff
changeset
|
416 if (!SYMBOLP (funcar)) |
297 | 417 return Fsignal (Qinvalid_function, Fcons (fun, Qnil)); |
647 | 418 else if (EQ (funcar, Qkeymap)) |
23921
81a6345fd5e8
(Fdocumentation): Change the doc string for prefix
Andreas Schwab <schwab@suse.de>
parents:
22890
diff
changeset
|
419 return build_string ("Prefix command (definition is a keymap associating keystrokes with commands)."); |
647 | 420 else if (EQ (funcar, Qlambda) |
421 || EQ (funcar, Qautoload)) | |
297 | 422 { |
13521
13e55327ef5e
(Fdocumentation): Reject a file reference
Richard M. Stallman <rms@gnu.org>
parents:
13244
diff
changeset
|
423 Lisp_Object tem1; |
13e55327ef5e
(Fdocumentation): Reject a file reference
Richard M. Stallman <rms@gnu.org>
parents:
13244
diff
changeset
|
424 tem1 = Fcdr (Fcdr (fun)); |
13e55327ef5e
(Fdocumentation): Reject a file reference
Richard M. Stallman <rms@gnu.org>
parents:
13244
diff
changeset
|
425 tem = Fcar (tem1); |
9133
48820d57a24c
(get_doc_string, Fdocumentation, Fdocumentation_property,
Karl Heuer <kwzh@gnu.org>
parents:
9087
diff
changeset
|
426 if (STRINGP (tem)) |
570 | 427 doc = tem; |
13521
13e55327ef5e
(Fdocumentation): Reject a file reference
Richard M. Stallman <rms@gnu.org>
parents:
13244
diff
changeset
|
428 /* Handle a doc reference--but these never come last |
13e55327ef5e
(Fdocumentation): Reject a file reference
Richard M. Stallman <rms@gnu.org>
parents:
13244
diff
changeset
|
429 in the function body, so reject them if they are last. */ |
41823
e192139240f2
(Fsnarf_documentation): Add prototype.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41218
diff
changeset
|
430 else if ((NATNUMP (tem) || (CONSP (tem) && INTEGERP (XCDR (tem)))) |
e192139240f2
(Fsnarf_documentation): Add prototype.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41218
diff
changeset
|
431 && !NILP (XCDR (tem1))) |
e192139240f2
(Fsnarf_documentation): Add prototype.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41218
diff
changeset
|
432 doc = tem; |
570 | 433 else |
434 return Qnil; | |
297 | 435 } |
647 | 436 else if (EQ (funcar, Qmacro)) |
570 | 437 return Fdocumentation (Fcdr (fun), raw); |
10002
5b2b7e378772
(Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9958
diff
changeset
|
438 else |
5b2b7e378772
(Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9958
diff
changeset
|
439 goto oops; |
5b2b7e378772
(Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9958
diff
changeset
|
440 } |
5b2b7e378772
(Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9958
diff
changeset
|
441 else |
5b2b7e378772
(Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9958
diff
changeset
|
442 { |
5b2b7e378772
(Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9958
diff
changeset
|
443 oops: |
5b2b7e378772
(Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9958
diff
changeset
|
444 Fsignal (Qinvalid_function, Fcons (fun, Qnil)); |
297 | 445 } |
570 | 446 |
44348
80c9e94bec17
(reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44324
diff
changeset
|
447 /* If DOC is 0, it's typically because of a dumped file missing |
80c9e94bec17
(reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44324
diff
changeset
|
448 from the DOC file (bug in src/Makefile.in). */ |
44385
d5cf9afe17d6
(Fdocumentation): More brainos. I need sleep.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44383
diff
changeset
|
449 if (EQ (doc, make_number (0))) |
d5cf9afe17d6
(Fdocumentation): More brainos. I need sleep.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44383
diff
changeset
|
450 doc = Qnil; |
44381
15b5489c78d6
(Fdocumentation, Fdocumentation_property): When the doc
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44355
diff
changeset
|
451 if (INTEGERP (doc) || CONSP (doc)) |
44324
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
452 { |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
453 Lisp_Object tem; |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
454 tem = get_doc_string (doc, 0, 0); |
44348
80c9e94bec17
(reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44324
diff
changeset
|
455 if (NILP (tem) && try_reload) |
44324
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
456 { |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
457 /* The file is newer, we need to reset the pointers. */ |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
458 struct gcpro gcpro1, gcpro2; |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
459 GCPRO2 (function, raw); |
44348
80c9e94bec17
(reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44324
diff
changeset
|
460 try_reload = reread_doc_file (Fcar_safe (doc)); |
44324
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
461 UNGCPRO; |
44348
80c9e94bec17
(reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44324
diff
changeset
|
462 if (try_reload) |
80c9e94bec17
(reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44324
diff
changeset
|
463 { |
80c9e94bec17
(reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44324
diff
changeset
|
464 try_reload = 0; |
80c9e94bec17
(reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44324
diff
changeset
|
465 goto documentation; |
80c9e94bec17
(reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44324
diff
changeset
|
466 } |
44324
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
467 } |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
468 else |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
469 doc = tem; |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
470 } |
41823
e192139240f2
(Fsnarf_documentation): Add prototype.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41218
diff
changeset
|
471 |
577 | 472 if (NILP (raw)) |
26471
b1863c0b8f9c
(Fdocumentation): Remove gcpro here too.
Dave Love <fx@gnu.org>
parents:
26420
diff
changeset
|
473 doc = Fsubstitute_command_keys (doc); |
570 | 474 return doc; |
297 | 475 } |
476 | |
28036
ec8b11f3d3da
(Fdocumentation_property): If value is not a string,
Gerd Moellmann <gerd@gnu.org>
parents:
27560
diff
changeset
|
477 DEFUN ("documentation-property", Fdocumentation_property, |
ec8b11f3d3da
(Fdocumentation_property): If value is not a string,
Gerd Moellmann <gerd@gnu.org>
parents:
27560
diff
changeset
|
478 Sdocumentation_property, 2, 3, 0, |
41001
a17c8b15ef1b
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40702
diff
changeset
|
479 doc: /* Return the documentation string that is SYMBOL's PROP property. |
a17c8b15ef1b
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40702
diff
changeset
|
480 Third argument RAW omitted or nil means pass the result through |
a17c8b15ef1b
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40702
diff
changeset
|
481 `substitute-command-keys' if it is a string. |
a17c8b15ef1b
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40702
diff
changeset
|
482 |
a17c8b15ef1b
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40702
diff
changeset
|
483 This differs from `get' in that it can refer to strings stored in the |
a17c8b15ef1b
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40702
diff
changeset
|
484 `etc/DOC' file; and that it evaluates documentation properties that |
a17c8b15ef1b
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40702
diff
changeset
|
485 aren't strings. */) |
14069
a45a97ebdf1c
(Fdocumentation, Fdocumentation_property, Fsubstitute_command_keys):
Erik Naggum <erik@naggum.no>
parents:
13521
diff
changeset
|
486 (symbol, prop, raw) |
a45a97ebdf1c
(Fdocumentation, Fdocumentation_property, Fsubstitute_command_keys):
Erik Naggum <erik@naggum.no>
parents:
13521
diff
changeset
|
487 Lisp_Object symbol, prop, raw; |
297 | 488 { |
44348
80c9e94bec17
(reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44324
diff
changeset
|
489 int try_reload = 1; |
26076
edbfca66058d
(Fdocumentation_property): Remove register declaration for `tem'.
Dave Love <fx@gnu.org>
parents:
26075
diff
changeset
|
490 Lisp_Object tem; |
297 | 491 |
44348
80c9e94bec17
(reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44324
diff
changeset
|
492 documentation_property: |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
493 |
14069
a45a97ebdf1c
(Fdocumentation, Fdocumentation_property, Fsubstitute_command_keys):
Erik Naggum <erik@naggum.no>
parents:
13521
diff
changeset
|
494 tem = Fget (symbol, prop); |
44383
e44eec58a815
(Fdocumentation): Add missing parentheses.
Juanma Barranquero <lekktu@gmail.com>
parents:
44381
diff
changeset
|
495 if (EQ (tem, make_number (0))) |
44385
d5cf9afe17d6
(Fdocumentation): More brainos. I need sleep.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44383
diff
changeset
|
496 tem = Qnil; |
44381
15b5489c78d6
(Fdocumentation, Fdocumentation_property): When the doc
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44355
diff
changeset
|
497 if (INTEGERP (tem) || (CONSP (tem) && INTEGERP (XCDR (tem)))) |
44324
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
498 { |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
499 Lisp_Object doc = tem; |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
500 tem = get_doc_string (tem, 0, 0); |
44348
80c9e94bec17
(reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44324
diff
changeset
|
501 if (NILP (tem) && try_reload) |
44324
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
502 { |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
503 /* The file is newer, we need to reset the pointers. */ |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
504 struct gcpro gcpro1, gcpro2, gcpro3; |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
505 GCPRO3 (symbol, prop, raw); |
44348
80c9e94bec17
(reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44324
diff
changeset
|
506 try_reload = reread_doc_file (Fcar_safe (doc)); |
44324
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
507 UNGCPRO; |
44348
80c9e94bec17
(reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44324
diff
changeset
|
508 if (try_reload) |
80c9e94bec17
(reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44324
diff
changeset
|
509 { |
80c9e94bec17
(reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44324
diff
changeset
|
510 try_reload = 0; |
80c9e94bec17
(reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44324
diff
changeset
|
511 goto documentation_property; |
80c9e94bec17
(reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44324
diff
changeset
|
512 } |
44324
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
513 } |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
514 } |
28036
ec8b11f3d3da
(Fdocumentation_property): If value is not a string,
Gerd Moellmann <gerd@gnu.org>
parents:
27560
diff
changeset
|
515 else if (!STRINGP (tem)) |
ec8b11f3d3da
(Fdocumentation_property): If value is not a string,
Gerd Moellmann <gerd@gnu.org>
parents:
27560
diff
changeset
|
516 /* Feval protects its argument. */ |
ec8b11f3d3da
(Fdocumentation_property): If value is not a string,
Gerd Moellmann <gerd@gnu.org>
parents:
27560
diff
changeset
|
517 tem = Feval (tem); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
518 |
9133
48820d57a24c
(get_doc_string, Fdocumentation, Fdocumentation_property,
Karl Heuer <kwzh@gnu.org>
parents:
9087
diff
changeset
|
519 if (NILP (raw) && STRINGP (tem)) |
26420
00b7d6135be4
(Fdocumentation_property): Remove GCPRO because
Gerd Moellmann <gerd@gnu.org>
parents:
26317
diff
changeset
|
520 tem = Fsubstitute_command_keys (tem); |
312
adba7439e87c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
297
diff
changeset
|
521 return tem; |
297 | 522 } |
523 | |
1651
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
524 /* Scanning the DOC files and placing docstring offsets into functions. */ |
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
525 |
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
526 static void |
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
527 store_function_docstring (fun, offset) |
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
528 Lisp_Object fun; |
10330
240a2c88d439
(store_function_docstring): Arg is now EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents:
10202
diff
changeset
|
529 /* Use EMACS_INT because we get this from pointer subtraction. */ |
240a2c88d439
(store_function_docstring): Arg is now EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents:
10202
diff
changeset
|
530 EMACS_INT offset; |
1651
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
531 { |
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
532 fun = indirect_function (fun); |
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
533 |
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
534 /* The type determines where the docstring is stored. */ |
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
535 |
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
536 /* Lisp_Subrs have a slot for it. */ |
9133
48820d57a24c
(get_doc_string, Fdocumentation, Fdocumentation_property,
Karl Heuer <kwzh@gnu.org>
parents:
9087
diff
changeset
|
537 if (SUBRP (fun)) |
1651
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
538 XSUBR (fun)->doc = (char *) - offset; |
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
539 |
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
540 /* If it's a lisp form, stick it in the form. */ |
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
541 else if (CONSP (fun)) |
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
542 { |
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
543 Lisp_Object tem; |
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
544 |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
24573
diff
changeset
|
545 tem = XCAR (fun); |
1651
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
546 if (EQ (tem, Qlambda) || EQ (tem, Qautoload)) |
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
547 { |
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
548 tem = Fcdr (Fcdr (fun)); |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
24573
diff
changeset
|
549 if (CONSP (tem) && INTEGERP (XCAR (tem))) |
39973
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39697
diff
changeset
|
550 XSETCARFASTINT (tem, offset); |
1651
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
551 } |
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
552 else if (EQ (tem, Qmacro)) |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
24573
diff
changeset
|
553 store_function_docstring (XCDR (fun), offset); |
1651
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
554 } |
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
555 |
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
556 /* Bytecode objects sometimes have slots for it. */ |
9133
48820d57a24c
(get_doc_string, Fdocumentation, Fdocumentation_property,
Karl Heuer <kwzh@gnu.org>
parents:
9087
diff
changeset
|
557 else if (COMPILEDP (fun)) |
1651
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
558 { |
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
559 /* This bytecode object must have a slot for the |
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
560 docstring, since we've found a docstring for it. */ |
41823
e192139240f2
(Fsnarf_documentation): Add prototype.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41218
diff
changeset
|
561 if ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) > COMPILED_DOC_STRING) |
e192139240f2
(Fsnarf_documentation): Add prototype.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41218
diff
changeset
|
562 XSETFASTINT (AREF (fun, COMPILED_DOC_STRING), offset); |
1651
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
563 } |
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
564 } |
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
565 |
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
566 |
297 | 567 DEFUN ("Snarf-documentation", Fsnarf_documentation, Ssnarf_documentation, |
41001
a17c8b15ef1b
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40702
diff
changeset
|
568 1, 1, 0, |
41218
ace002127a1c
(Fsnarf_documentation): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
41001
diff
changeset
|
569 doc: /* Used during Emacs initialization to scan the `etc/DOC...' file. |
ace002127a1c
(Fsnarf_documentation): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
41001
diff
changeset
|
570 This searches the `etc/DOC...' file for doc strings and |
ace002127a1c
(Fsnarf_documentation): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
41001
diff
changeset
|
571 records them in function and variable definitions. |
ace002127a1c
(Fsnarf_documentation): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
41001
diff
changeset
|
572 The function takes one argument, FILENAME, a string; |
ace002127a1c
(Fsnarf_documentation): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
41001
diff
changeset
|
573 it specifies the file name (without a directory) of the DOC file. |
ace002127a1c
(Fsnarf_documentation): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
41001
diff
changeset
|
574 That file is found in `../etc' now; later, when the dumped Emacs is run, |
56216
efd6af30bde2
(Fsnarf_documentation): Doc fix.
Luc Teirlinck <teirllm@auburn.edu>
parents:
54927
diff
changeset
|
575 the same file name is found in the `doc-directory'. */) |
41001
a17c8b15ef1b
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40702
diff
changeset
|
576 (filename) |
297 | 577 Lisp_Object filename; |
578 { | |
579 int fd; | |
580 char buf[1024 + 1]; | |
581 register int filled; | |
582 register int pos; | |
583 register char *p, *end; | |
34963
681963400696
(Fsnarf_documentation): Remove unused variables `fun' and
Eli Zaretskii <eliz@gnu.org>
parents:
34363
diff
changeset
|
584 Lisp_Object sym; |
297 | 585 char *name; |
58068
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
586 int skip_file = 0; |
297 | 587 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40139
diff
changeset
|
588 CHECK_STRING (filename); |
297 | 589 |
44324
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
590 if |
297 | 591 #ifndef CANNOT_DUMP |
44324
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
592 (!NILP (Vpurify_flag)) |
297 | 593 #else /* CANNOT_DUMP */ |
44324
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
594 (0) |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
595 #endif /* CANNOT_DUMP */ |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
596 { |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45368
diff
changeset
|
597 name = (char *) alloca (SCHARS (filename) + 14); |
44324
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
598 strcpy (name, "../etc/"); |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
599 } |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
600 else |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
601 { |
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
602 CHECK_STRING (Vdoc_directory); |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45368
diff
changeset
|
603 name = (char *) alloca (SCHARS (filename) |
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45368
diff
changeset
|
604 + SCHARS (Vdoc_directory) + 1); |
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45368
diff
changeset
|
605 strcpy (name, SDATA (Vdoc_directory)); |
44324
def57419f6ec
(get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43155
diff
changeset
|
606 } |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45368
diff
changeset
|
607 strcat (name, SDATA (filename)); /*** Add this line ***/ |
60388
1f66922e7ad0
(munge_doc_file_name) [VMS]: Use NO_HYPHENS_IN_FILENAMES, not VMS4_4.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
60065
diff
changeset
|
608 munge_doc_file_name (name); |
297 | 609 |
58068
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
610 /* Vbuild_files is nil when temacs is run, and non-nil after that. */ |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
611 if (NILP (Vbuild_files)) |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
612 { |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
613 size_t cp_size = 0; |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
614 size_t to_read; |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
615 int nr_read; |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
616 char *cp = NULL; |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
617 char *beg, *end; |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
618 |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
619 fd = emacs_open ("buildobj.lst", O_RDONLY, 0); |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
620 if (fd < 0) |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
621 report_file_error ("Opening file buildobj.lst", Qnil); |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
622 |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
623 filled = 0; |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
624 for (;;) |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
625 { |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
626 cp_size += 1024; |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
627 to_read = cp_size - 1 - filled; |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
628 cp = xrealloc (cp, cp_size); |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
629 nr_read = emacs_read (fd, &cp[filled], to_read); |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
630 filled += nr_read; |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
631 if (nr_read < to_read) |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
632 break; |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
633 } |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
634 |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
635 emacs_close (fd); |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
636 cp[filled] = 0; |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
637 |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
638 for (beg = cp; *beg; beg = end) |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
639 { |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
640 int len; |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
641 |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
642 while (*beg && isspace (*beg)) ++beg; |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
643 |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
644 for (end = beg; *end && ! isspace (*end); ++end) |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
645 if (*end == '/') beg = end+1; /* skip directory part */ |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
646 |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
647 len = end - beg; |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
648 if (len > 4 && end[-4] == '.' && end[-3] == 'o') |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
649 len -= 2; /* Just take .o if it ends in .obj */ |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
650 |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
651 if (len > 0) |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
652 Vbuild_files = Fcons (make_string (beg, len), Vbuild_files); |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
653 } |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
654 |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
655 xfree (cp); |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
656 } |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
657 |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26076
diff
changeset
|
658 fd = emacs_open (name, O_RDONLY, 0); |
297 | 659 if (fd < 0) |
660 report_file_error ("Opening doc string file", | |
661 Fcons (build_string (name), Qnil)); | |
662 Vdoc_file_name = filename; | |
663 filled = 0; | |
664 pos = 0; | |
665 while (1) | |
666 { | |
667 if (filled < 512) | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26076
diff
changeset
|
668 filled += emacs_read (fd, &buf[filled], sizeof buf - 1 - filled); |
297 | 669 if (!filled) |
670 break; | |
671 | |
672 buf[filled] = 0; | |
673 p = buf; | |
674 end = buf + (filled < 512 ? filled : filled - 128); | |
675 while (p != end && *p != '\037') p++; | |
676 /* p points to ^_Ffunctionname\n or ^_Vvarname\n. */ | |
677 if (p != end) | |
678 { | |
31225
7930c46bb365
(toplevel) [HAVE_STRING_H]: Include string.h.
Gerd Moellmann <gerd@gnu.org>
parents:
30154
diff
changeset
|
679 end = (char *) index (p, '\n'); |
58068
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
680 |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
681 /* See if this is a file name, and if it is a file in build-files. */ |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
682 if (p[1] == 'S' && end - p > 4 && end[-2] == '.' |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
683 && (end[-1] == 'o' || end[-1] == 'c')) |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
684 { |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
685 int len = end - p - 2; |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
686 char *fromfile = alloca (len + 1); |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
687 strncpy (fromfile, &p[2], len); |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
688 fromfile[len] = 0; |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
689 if (fromfile[len-1] == 'c') |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
690 fromfile[len-1] = 'o'; |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
691 |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
692 if (EQ (Fmember (build_string (fromfile), Vbuild_files), Qnil)) |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
693 skip_file = 1; |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
694 else |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
695 skip_file = 0; |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
696 } |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
697 |
20619 | 698 sym = oblookup (Vobarray, p + 2, |
699 multibyte_chars_in_text (p + 2, end - p - 2), | |
700 end - p - 2); | |
58068
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
701 if (! skip_file && SYMBOLP (sym)) |
297 | 702 { |
703 /* Attach a docstring to a variable? */ | |
704 if (p[1] == 'V') | |
705 { | |
706 /* Install file-position as variable-documentation property | |
707 and make it negative for a user-variable | |
708 (doc starts with a `*'). */ | |
709 Fput (sym, Qvariable_documentation, | |
710 make_number ((pos + end + 1 - buf) | |
711 * (end[1] == '*' ? -1 : 1))); | |
712 } | |
713 | |
1651
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
714 /* Attach a docstring to a function? */ |
297 | 715 else if (p[1] == 'F') |
1651
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
716 store_function_docstring (sym, pos + end + 1 - buf); |
297 | 717 |
54745
98cf37e32872
(Fsnarf_documentation): Ignore new file name entries.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54234
diff
changeset
|
718 else if (p[1] == 'S') |
98cf37e32872
(Fsnarf_documentation): Ignore new file name entries.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54234
diff
changeset
|
719 ; /* Just a source file name boundary marker. Ignore it. */ |
98cf37e32872
(Fsnarf_documentation): Ignore new file name entries.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54234
diff
changeset
|
720 |
1651
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
721 else |
ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents:
1511
diff
changeset
|
722 error ("DOC file invalid at position %d", pos); |
297 | 723 } |
724 } | |
725 pos += end - buf; | |
726 filled -= end - buf; | |
727 bcopy (end, buf, filled); | |
728 } | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26076
diff
changeset
|
729 emacs_close (fd); |
297 | 730 return Qnil; |
731 } | |
732 | |
733 DEFUN ("substitute-command-keys", Fsubstitute_command_keys, | |
41001
a17c8b15ef1b
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40702
diff
changeset
|
734 Ssubstitute_command_keys, 1, 1, 0, |
a17c8b15ef1b
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40702
diff
changeset
|
735 doc: /* Substitute key descriptions for command names in STRING. |
a17c8b15ef1b
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40702
diff
changeset
|
736 Return a new string which is STRING with substrings of the form \\=\\[COMMAND] |
a17c8b15ef1b
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40702
diff
changeset
|
737 replaced by either: a keystroke sequence that will invoke COMMAND, |
a17c8b15ef1b
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40702
diff
changeset
|
738 or "M-x COMMAND" if COMMAND is not on any keys. |
a17c8b15ef1b
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40702
diff
changeset
|
739 Substrings of the form \\=\\{MAPVAR} are replaced by summaries |
a17c8b15ef1b
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40702
diff
changeset
|
740 \(made by describe-bindings) of the value of MAPVAR, taken as a keymap. |
a17c8b15ef1b
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40702
diff
changeset
|
741 Substrings of the form \\=\\<MAPVAR> specify to use the value of MAPVAR |
a17c8b15ef1b
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40702
diff
changeset
|
742 as the keymap for future \\=\\[COMMAND] substrings. |
a17c8b15ef1b
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40702
diff
changeset
|
743 \\=\\= quotes the following character and is discarded; |
a17c8b15ef1b
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40702
diff
changeset
|
744 thus, \\=\\=\\=\\= puts \\=\\= into the output, and \\=\\=\\=\\[ puts \\=\\[ into the output. */) |
a17c8b15ef1b
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40702
diff
changeset
|
745 (string) |
14069
a45a97ebdf1c
(Fdocumentation, Fdocumentation_property, Fsubstitute_command_keys):
Erik Naggum <erik@naggum.no>
parents:
13521
diff
changeset
|
746 Lisp_Object string; |
297 | 747 { |
748 unsigned char *buf; | |
749 int changed = 0; | |
750 register unsigned char *strp; | |
751 register unsigned char *bufp; | |
752 int idx; | |
753 int bsize; | |
1511
ff88f962a982
* doc.c: #include keyboard.h.
Jim Blandy <jimb@redhat.com>
parents:
1116
diff
changeset
|
754 Lisp_Object tem; |
297 | 755 Lisp_Object keymap; |
756 unsigned char *start; | |
20802
8cd0a6343a84
(Fsubstitute_command_keys): Declare length_byte out of
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
757 int length, length_byte; |
1511
ff88f962a982
* doc.c: #include keyboard.h.
Jim Blandy <jimb@redhat.com>
parents:
1116
diff
changeset
|
758 Lisp_Object name; |
ff88f962a982
* doc.c: #include keyboard.h.
Jim Blandy <jimb@redhat.com>
parents:
1116
diff
changeset
|
759 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
20619 | 760 int multibyte; |
761 int nchars; | |
297 | 762 |
14069
a45a97ebdf1c
(Fdocumentation, Fdocumentation_property, Fsubstitute_command_keys):
Erik Naggum <erik@naggum.no>
parents:
13521
diff
changeset
|
763 if (NILP (string)) |
297 | 764 return Qnil; |
765 | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40139
diff
changeset
|
766 CHECK_STRING (string); |
1511
ff88f962a982
* doc.c: #include keyboard.h.
Jim Blandy <jimb@redhat.com>
parents:
1116
diff
changeset
|
767 tem = Qnil; |
ff88f962a982
* doc.c: #include keyboard.h.
Jim Blandy <jimb@redhat.com>
parents:
1116
diff
changeset
|
768 keymap = Qnil; |
ff88f962a982
* doc.c: #include keyboard.h.
Jim Blandy <jimb@redhat.com>
parents:
1116
diff
changeset
|
769 name = Qnil; |
14069
a45a97ebdf1c
(Fdocumentation, Fdocumentation_property, Fsubstitute_command_keys):
Erik Naggum <erik@naggum.no>
parents:
13521
diff
changeset
|
770 GCPRO4 (string, tem, keymap, name); |
297 | 771 |
20619 | 772 multibyte = STRING_MULTIBYTE (string); |
773 nchars = 0; | |
774 | |
5784
9c3be8e0d2ef
(Fsubstitute_command_keys): Pass keymap as that arg
Richard M. Stallman <rms@gnu.org>
parents:
5550
diff
changeset
|
775 /* KEYMAP is either nil (which means search all the active keymaps) |
9c3be8e0d2ef
(Fsubstitute_command_keys): Pass keymap as that arg
Richard M. Stallman <rms@gnu.org>
parents:
5550
diff
changeset
|
776 or a specified local map (which means search just that and the |
9c3be8e0d2ef
(Fsubstitute_command_keys): Pass keymap as that arg
Richard M. Stallman <rms@gnu.org>
parents:
5550
diff
changeset
|
777 global map). If non-nil, it might come from Voverriding_local_map, |
14069
a45a97ebdf1c
(Fdocumentation, Fdocumentation_property, Fsubstitute_command_keys):
Erik Naggum <erik@naggum.no>
parents:
13521
diff
changeset
|
778 or from a \\<mapname> construct in STRING itself.. */ |
12261 | 779 keymap = current_kboard->Voverriding_terminal_local_map; |
780 if (NILP (keymap)) | |
781 keymap = Voverriding_local_map; | |
297 | 782 |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45368
diff
changeset
|
783 bsize = SBYTES (string); |
297 | 784 bufp = buf = (unsigned char *) xmalloc (bsize); |
785 | |
50629
36d13cf0f114
(Fsubstitute_command_keys): Remove spurious casts.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49600
diff
changeset
|
786 strp = SDATA (string); |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45368
diff
changeset
|
787 while (strp < SDATA (string) + SBYTES (string)) |
297 | 788 { |
789 if (strp[0] == '\\' && strp[1] == '=') | |
790 { | |
791 /* \= quotes the next character; | |
792 thus, to put in \[ without its special meaning, use \=\[. */ | |
793 changed = 1; | |
20619 | 794 strp += 2; |
795 if (multibyte) | |
796 { | |
797 int len; | |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45368
diff
changeset
|
798 int maxlen = SDATA (string) + SBYTES (string) - strp; |
20619 | 799 |
800 STRING_CHAR_AND_LENGTH (strp, maxlen, len); | |
801 if (len == 1) | |
802 *bufp = *strp; | |
803 else | |
804 bcopy (strp, bufp, len); | |
805 strp += len; | |
806 bufp += len; | |
807 nchars++; | |
808 } | |
809 else | |
810 *bufp++ = *strp++, nchars++; | |
297 | 811 } |
812 else if (strp[0] == '\\' && strp[1] == '[') | |
813 { | |
30154
f8e2064c56b1
(Fsubstitute_command_keys): Handle case that a GC
Gerd Moellmann <gerd@gnu.org>
parents:
28334
diff
changeset
|
814 int start_idx; |
5248
27d6275810a7
(Fsubstitute_command_keys): Ignore menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents:
4716
diff
changeset
|
815 |
297 | 816 changed = 1; |
817 strp += 2; /* skip \[ */ | |
818 start = strp; | |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45368
diff
changeset
|
819 start_idx = start - SDATA (string); |
297 | 820 |
50629
36d13cf0f114
(Fsubstitute_command_keys): Remove spurious casts.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49600
diff
changeset
|
821 while ((strp - SDATA (string) |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45368
diff
changeset
|
822 < SBYTES (string)) |
297 | 823 && *strp != ']') |
824 strp++; | |
20619 | 825 length_byte = strp - start; |
826 | |
297 | 827 strp++; /* skip ] */ |
828 | |
829 /* Save STRP in IDX. */ | |
50629
36d13cf0f114
(Fsubstitute_command_keys): Remove spurious casts.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49600
diff
changeset
|
830 idx = strp - SDATA (string); |
57497
0a4c356f307b
(Fsubstitute_command_keys): Fix remap-handling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57441
diff
changeset
|
831 name = Fintern (make_string (start, length_byte), Qnil); |
30154
f8e2064c56b1
(Fsubstitute_command_keys): Handle case that a GC
Gerd Moellmann <gerd@gnu.org>
parents:
28334
diff
changeset
|
832 |
57441
4c881805ff35
(Fsubstitute_command_keys): Ignore remappings unless there
Kim F. Storm <storm@cua.dk>
parents:
56216
diff
changeset
|
833 /* Ignore remappings unless there are no ordinary bindings. */ |
57497
0a4c356f307b
(Fsubstitute_command_keys): Fix remap-handling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57441
diff
changeset
|
834 tem = Fwhere_is_internal (name, keymap, Qt, Qnil, Qt); |
57441
4c881805ff35
(Fsubstitute_command_keys): Ignore remappings unless there
Kim F. Storm <storm@cua.dk>
parents:
56216
diff
changeset
|
835 if (NILP (tem)) |
57497
0a4c356f307b
(Fsubstitute_command_keys): Fix remap-handling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57441
diff
changeset
|
836 tem = Fwhere_is_internal (name, keymap, Qt, Qnil, Qnil); |
57441
4c881805ff35
(Fsubstitute_command_keys): Ignore remappings unless there
Kim F. Storm <storm@cua.dk>
parents:
56216
diff
changeset
|
837 |
30154
f8e2064c56b1
(Fsubstitute_command_keys): Handle case that a GC
Gerd Moellmann <gerd@gnu.org>
parents:
28334
diff
changeset
|
838 /* Note the Fwhere_is_internal can GC, so we have to take |
f8e2064c56b1
(Fsubstitute_command_keys): Handle case that a GC
Gerd Moellmann <gerd@gnu.org>
parents:
28334
diff
changeset
|
839 relocation of string contents into account. */ |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45368
diff
changeset
|
840 strp = SDATA (string) + idx; |
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45368
diff
changeset
|
841 start = SDATA (string) + start_idx; |
297 | 842 |
485 | 843 if (NILP (tem)) /* but not on any keys */ |
297 | 844 { |
34363
62a349fc3d3c
(Fsubstitute_command_keys): Change the way buffers
Gerd Moellmann <gerd@gnu.org>
parents:
32988
diff
changeset
|
845 int offset = bufp - buf; |
62a349fc3d3c
(Fsubstitute_command_keys): Change the way buffers
Gerd Moellmann <gerd@gnu.org>
parents:
32988
diff
changeset
|
846 buf = (unsigned char *) xrealloc (buf, bsize += 4); |
62a349fc3d3c
(Fsubstitute_command_keys): Change the way buffers
Gerd Moellmann <gerd@gnu.org>
parents:
32988
diff
changeset
|
847 bufp = buf + offset; |
297 | 848 bcopy ("M-x ", bufp, 4); |
849 bufp += 4; | |
20619 | 850 nchars += 4; |
851 if (multibyte) | |
852 length = multibyte_chars_in_text (start, length_byte); | |
853 else | |
854 length = length_byte; | |
297 | 855 goto subst; |
856 } | |
857 else | |
858 { /* function is on a key */ | |
54927
7b6b4d9ae726
(Fkey_description): Change callers.
Kim F. Storm <storm@cua.dk>
parents:
54745
diff
changeset
|
859 tem = Fkey_description (tem, Qnil); |
297 | 860 goto subst_string; |
861 } | |
862 } | |
863 /* \{foo} is replaced with a summary of the keymap (symbol-value foo). | |
864 \<foo> just sets the keymap used for \[cmd]. */ | |
865 else if (strp[0] == '\\' && (strp[1] == '{' || strp[1] == '<')) | |
866 { | |
867 struct buffer *oldbuf; | |
30154
f8e2064c56b1
(Fsubstitute_command_keys): Handle case that a GC
Gerd Moellmann <gerd@gnu.org>
parents:
28334
diff
changeset
|
868 int start_idx; |
60065
42e18861b7b8
(Fsubstitute_command_keys): Compute list of shadowing maps
Richard M. Stallman <rms@gnu.org>
parents:
58087
diff
changeset
|
869 /* This is for computing the SHADOWS arg for describe_map_tree. */ |
42e18861b7b8
(Fsubstitute_command_keys): Compute list of shadowing maps
Richard M. Stallman <rms@gnu.org>
parents:
58087
diff
changeset
|
870 Lisp_Object active_maps = Fcurrent_active_maps (Qnil); |
42e18861b7b8
(Fsubstitute_command_keys): Compute list of shadowing maps
Richard M. Stallman <rms@gnu.org>
parents:
58087
diff
changeset
|
871 Lisp_Object earlier_maps; |
297 | 872 |
873 changed = 1; | |
874 strp += 2; /* skip \{ or \< */ | |
875 start = strp; | |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45368
diff
changeset
|
876 start_idx = start - SDATA (string); |
297 | 877 |
54234
e1003d782dc6
(Fsubstitute_command_keys): Fix counding bytes.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
878 while ((strp - SDATA (string) < SBYTES (string)) |
297 | 879 && *strp != '}' && *strp != '>') |
880 strp++; | |
20619 | 881 |
882 length_byte = strp - start; | |
297 | 883 strp++; /* skip } or > */ |
884 | |
885 /* Save STRP in IDX. */ | |
50629
36d13cf0f114
(Fsubstitute_command_keys): Remove spurious casts.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49600
diff
changeset
|
886 idx = strp - SDATA (string); |
297 | 887 |
888 /* Get the value of the keymap in TEM, or nil if undefined. | |
889 Do this while still in the user's current buffer | |
890 in case it is a local variable. */ | |
20619 | 891 name = Fintern (make_string (start, length_byte), Qnil); |
297 | 892 tem = Fboundp (name); |
485 | 893 if (! NILP (tem)) |
297 | 894 { |
895 tem = Fsymbol_value (name); | |
485 | 896 if (! NILP (tem)) |
30154
f8e2064c56b1
(Fsubstitute_command_keys): Handle case that a GC
Gerd Moellmann <gerd@gnu.org>
parents:
28334
diff
changeset
|
897 { |
32988
c3435dc00ed7
* lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31336
diff
changeset
|
898 tem = get_keymap (tem, 0, 1); |
c3435dc00ed7
* lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31336
diff
changeset
|
899 /* Note that get_keymap can GC. */ |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45368
diff
changeset
|
900 strp = SDATA (string) + idx; |
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45368
diff
changeset
|
901 start = SDATA (string) + start_idx; |
30154
f8e2064c56b1
(Fsubstitute_command_keys): Handle case that a GC
Gerd Moellmann <gerd@gnu.org>
parents:
28334
diff
changeset
|
902 } |
297 | 903 } |
904 | |
905 /* Now switch to a temp buffer. */ | |
906 oldbuf = current_buffer; | |
907 set_buffer_internal (XBUFFER (Vprin1_to_string_buffer)); | |
908 | |
485 | 909 if (NILP (tem)) |
297 | 910 { |
911 name = Fsymbol_name (name); | |
912 insert_string ("\nUses keymap \""); | |
20619 | 913 insert_from_string (name, 0, 0, |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45368
diff
changeset
|
914 SCHARS (name), |
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45368
diff
changeset
|
915 SBYTES (name), 1); |
297 | 916 insert_string ("\", which is not currently defined.\n"); |
917 if (start[-1] == '<') keymap = Qnil; | |
918 } | |
919 else if (start[-1] == '<') | |
920 keymap = tem; | |
921 else | |
60065
42e18861b7b8
(Fsubstitute_command_keys): Compute list of shadowing maps
Richard M. Stallman <rms@gnu.org>
parents:
58087
diff
changeset
|
922 { |
42e18861b7b8
(Fsubstitute_command_keys): Compute list of shadowing maps
Richard M. Stallman <rms@gnu.org>
parents:
58087
diff
changeset
|
923 /* Get the list of active keymaps that precede this one. |
42e18861b7b8
(Fsubstitute_command_keys): Compute list of shadowing maps
Richard M. Stallman <rms@gnu.org>
parents:
58087
diff
changeset
|
924 If this one's not active, get nil. */ |
42e18861b7b8
(Fsubstitute_command_keys): Compute list of shadowing maps
Richard M. Stallman <rms@gnu.org>
parents:
58087
diff
changeset
|
925 earlier_maps = Fcdr (Fmemq (tem, Freverse (active_maps))); |
42e18861b7b8
(Fsubstitute_command_keys): Compute list of shadowing maps
Richard M. Stallman <rms@gnu.org>
parents:
58087
diff
changeset
|
926 describe_map_tree (tem, 1, Fnreverse (earlier_maps), |
42e18861b7b8
(Fsubstitute_command_keys): Compute list of shadowing maps
Richard M. Stallman <rms@gnu.org>
parents:
58087
diff
changeset
|
927 Qnil, (char *)0, 1, 0, 0, 1); |
42e18861b7b8
(Fsubstitute_command_keys): Compute list of shadowing maps
Richard M. Stallman <rms@gnu.org>
parents:
58087
diff
changeset
|
928 } |
297 | 929 tem = Fbuffer_string (); |
930 Ferase_buffer (); | |
931 set_buffer_internal (oldbuf); | |
932 | |
933 subst_string: | |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45368
diff
changeset
|
934 start = SDATA (tem); |
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45368
diff
changeset
|
935 length = SCHARS (tem); |
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45368
diff
changeset
|
936 length_byte = SBYTES (tem); |
297 | 937 subst: |
34363
62a349fc3d3c
(Fsubstitute_command_keys): Change the way buffers
Gerd Moellmann <gerd@gnu.org>
parents:
32988
diff
changeset
|
938 { |
62a349fc3d3c
(Fsubstitute_command_keys): Change the way buffers
Gerd Moellmann <gerd@gnu.org>
parents:
32988
diff
changeset
|
939 int offset = bufp - buf; |
62a349fc3d3c
(Fsubstitute_command_keys): Change the way buffers
Gerd Moellmann <gerd@gnu.org>
parents:
32988
diff
changeset
|
940 buf = (unsigned char *) xrealloc (buf, bsize += length_byte); |
62a349fc3d3c
(Fsubstitute_command_keys): Change the way buffers
Gerd Moellmann <gerd@gnu.org>
parents:
32988
diff
changeset
|
941 bufp = buf + offset; |
62a349fc3d3c
(Fsubstitute_command_keys): Change the way buffers
Gerd Moellmann <gerd@gnu.org>
parents:
32988
diff
changeset
|
942 bcopy (start, bufp, length_byte); |
62a349fc3d3c
(Fsubstitute_command_keys): Change the way buffers
Gerd Moellmann <gerd@gnu.org>
parents:
32988
diff
changeset
|
943 bufp += length_byte; |
62a349fc3d3c
(Fsubstitute_command_keys): Change the way buffers
Gerd Moellmann <gerd@gnu.org>
parents:
32988
diff
changeset
|
944 nchars += length; |
62a349fc3d3c
(Fsubstitute_command_keys): Change the way buffers
Gerd Moellmann <gerd@gnu.org>
parents:
32988
diff
changeset
|
945 /* Check STRING again in case gc relocated it. */ |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45368
diff
changeset
|
946 strp = (unsigned char *) SDATA (string) + idx; |
34363
62a349fc3d3c
(Fsubstitute_command_keys): Change the way buffers
Gerd Moellmann <gerd@gnu.org>
parents:
32988
diff
changeset
|
947 } |
297 | 948 } |
20619 | 949 else if (! multibyte) /* just copy other chars */ |
950 *bufp++ = *strp++, nchars++; | |
951 else | |
952 { | |
953 int len; | |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45368
diff
changeset
|
954 int maxlen = SDATA (string) + SBYTES (string) - strp; |
20619 | 955 |
956 STRING_CHAR_AND_LENGTH (strp, maxlen, len); | |
957 if (len == 1) | |
958 *bufp = *strp; | |
959 else | |
960 bcopy (strp, bufp, len); | |
961 strp += len; | |
962 bufp += len; | |
963 nchars++; | |
964 } | |
297 | 965 } |
966 | |
967 if (changed) /* don't bother if nothing substituted */ | |
21252
fce0c8c246d1
(Fsubstitute_command_keys): Use make_string_from_bytes.
Richard M. Stallman <rms@gnu.org>
parents:
21244
diff
changeset
|
968 tem = make_string_from_bytes (buf, nchars, bufp - buf); |
297 | 969 else |
14069
a45a97ebdf1c
(Fdocumentation, Fdocumentation_property, Fsubstitute_command_keys):
Erik Naggum <erik@naggum.no>
parents:
13521
diff
changeset
|
970 tem = string; |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
1651
diff
changeset
|
971 xfree (buf); |
1511
ff88f962a982
* doc.c: #include keyboard.h.
Jim Blandy <jimb@redhat.com>
parents:
1116
diff
changeset
|
972 RETURN_UNGCPRO (tem); |
297 | 973 } |
974 | |
21514 | 975 void |
297 | 976 syms_of_doc () |
977 { | |
28334
f9cb3463ee2a
(Qfunction_documentation): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
28036
diff
changeset
|
978 Qfunction_documentation = intern ("function-documentation"); |
f9cb3463ee2a
(Qfunction_documentation): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
28036
diff
changeset
|
979 staticpro (&Qfunction_documentation); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
980 |
297 | 981 DEFVAR_LISP ("internal-doc-file-name", &Vdoc_file_name, |
41001
a17c8b15ef1b
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
40702
diff
changeset
|
982 doc: /* Name of file containing documentation strings of built-in symbols. */); |
297 | 983 Vdoc_file_name = Qnil; |
984 | |
58068
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
985 DEFVAR_LISP ("build-files", &Vbuild_files, |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
986 doc: /* A list of files used to build this Emacs binary. */); |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
987 Vbuild_files = Qnil; |
df00cdb75fc6
* doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57497
diff
changeset
|
988 |
297 | 989 defsubr (&Sdocumentation); |
990 defsubr (&Sdocumentation_property); | |
991 defsubr (&Ssnarf_documentation); | |
992 defsubr (&Ssubstitute_command_keys); | |
993 } | |
52401 | 994 |
995 /* arch-tag: 56281d4d-6949-43e2-be2e-f6517de744ba | |
996 (do not change this comment) */ |