annotate src/doc.c @ 109155:194249bde54b

* configure.in (getenv): Remove K&R declaration.
author Dan Nicolaescu <dann@ics.uci.edu>
date Tue, 06 Jul 2010 20:04:31 -0700
parents 18f8e88d3829
children 750db9f3e6d8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1 /* Record indices of function doc strings stored in a file.
64770
a0d1312ede66 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64084
diff changeset
2 Copyright (C) 1985, 1986, 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2001,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 106185
diff changeset
3 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
79759
fc2bcd2a8aad Add 2008 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 78260
diff changeset
4 Free Software Foundation, Inc.
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6 This file is part of GNU Emacs.
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
7
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 91607
diff changeset
8 GNU Emacs is free software: you can redistribute it and/or modify
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 it under the terms of the GNU General Public License as published by
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 91607
diff changeset
10 the Free Software Foundation, either version 3 of the License, or
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 91607
diff changeset
11 (at your option) any later version.
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 GNU Emacs is distributed in the hope that it will be useful,
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 GNU General Public License for more details.
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 91607
diff changeset
19 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21
4696
1fc792473491 Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents: 3999
diff changeset
22 #include <config.h>
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 #include <sys/types.h>
96303
ddedcecb18ef * unexnext.c:
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94963
diff changeset
25 #include <sys/file.h> /* Must be after sys/types.h for USG*/
58087
3eee868b9ed2 Include <ctype.h>.
Kim F. Storm <storm@cua.dk>
parents: 58068
diff changeset
26 #include <ctype.h>
105669
68dd71358159 * alloc.c: Do not define struct catchtag.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 104918
diff changeset
27 #include <setjmp.h>
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28
51402
cc6e47eeb0a8 Use HAVE_FCNTL_H, not USG5.
Dave Love <fx@gnu.org>
parents: 50629
diff changeset
29 #ifdef HAVE_FCNTL_H
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30 #include <fcntl.h>
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 #endif
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 #ifndef O_RDONLY
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 #define O_RDONLY 0
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39 #endif
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41 #include "lisp.h"
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 #include "buffer.h"
1511
ff88f962a982 * doc.c: #include keyboard.h.
Jim Blandy <jimb@redhat.com>
parents: 1116
diff changeset
43 #include "keyboard.h"
88351
aac41b50c875 Include "character.h" instead of "charset.h".
Kenichi Handa <handa@m17n.org>
parents: 43155
diff changeset
44 #include "character.h"
39697
0b986bb45526 Include keymap.h.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39675
diff changeset
45 #include "keymap.h"
104619
90578b9cc2d2 * Makefile.in (buildobj.h): New target.
Ken Raeburn <raeburn@raeburn.org>
parents: 100951
diff changeset
46 #include "buildobj.h"
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47
31336
3ecef4a7b3cd Remove includes of
Gerd Moellmann <gerd@gnu.org>
parents: 31225
diff changeset
48 #ifdef HAVE_INDEX
109100
2bc9a0c04c87 Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents: 108161
diff changeset
49 extern char *index (const char *, int);
31225
7930c46bb365 (toplevel) [HAVE_STRING_H]: Include string.h.
Gerd Moellmann <gerd@gnu.org>
parents: 30154
diff changeset
50 #endif
7930c46bb365 (toplevel) [HAVE_STRING_H]: Include string.h.
Gerd Moellmann <gerd@gnu.org>
parents: 30154
diff changeset
51
40139
0600331ddd52 (Vhelp_manyarg_func_alist): Variable removed.
Miles Bader <miles@gnu.org>
parents: 39973
diff changeset
52 Lisp_Object Vdoc_file_name;
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53
28334
f9cb3463ee2a (Qfunction_documentation): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28036
diff changeset
54 Lisp_Object Qfunction_documentation;
f9cb3463ee2a (Qfunction_documentation): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28036
diff changeset
55
58068
df00cdb75fc6 * doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57497
diff changeset
56 /* 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
57 static Lisp_Object Vbuild_files;
df00cdb75fc6 * doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57497
diff changeset
58
5784
9c3be8e0d2ef (Fsubstitute_command_keys): Pass keymap as that arg
Richard M. Stallman <rms@gnu.org>
parents: 5550
diff changeset
59 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
60
65391
4a6f5ef57ed1 (Fsubstitute_command_keys): Lookup key binding for
Kim F. Storm <storm@cua.dk>
parents: 64770
diff changeset
61 extern Lisp_Object Qremap;
4a6f5ef57ed1 (Fsubstitute_command_keys): Lookup key binding for
Kim F. Storm <storm@cua.dk>
parents: 64770
diff changeset
62
14648
45d13c154bb4 (get_doc_string): Move static vars outside the function,
Richard M. Stallman <rms@gnu.org>
parents: 14552
diff changeset
63 /* 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
64 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
65 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
66
22690
31bc848c5f18 (get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents: 22602
diff changeset
67 static unsigned char *read_bytecode_pointer;
109100
2bc9a0c04c87 Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents: 108161
diff changeset
68 Lisp_Object Fsnarf_documentation (Lisp_Object);
22690
31bc848c5f18 (get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents: 22602
diff changeset
69
31bc848c5f18 (get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents: 22602
diff changeset
70 /* 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
71 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
72
31bc848c5f18 (get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents: 22602
diff changeset
73 int
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
74 read_bytecode_char (int unreadflag)
22690
31bc848c5f18 (get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents: 22602
diff changeset
75 {
31bc848c5f18 (get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents: 22602
diff changeset
76 if (unreadflag)
31bc848c5f18 (get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents: 22602
diff changeset
77 {
31bc848c5f18 (get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents: 22602
diff changeset
78 read_bytecode_pointer--;
31bc848c5f18 (get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents: 22602
diff changeset
79 return 0;
31bc848c5f18 (get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents: 22602
diff changeset
80 }
31bc848c5f18 (get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents: 22602
diff changeset
81 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
82 }
31bc848c5f18 (get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents: 22602
diff changeset
83
10202
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
84 /* 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
85 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
86 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
87 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
88 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
89 (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
90 them without actually fetching the doc string.)
10a9f355a346 (get_doc_string): New arg UNIBYTE
Richard M. Stallman <rms@gnu.org>
parents: 21514
diff changeset
91
44324
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
92 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
93 (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
94 return nil.
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
95
22602
9c6b3b9c3c8f (get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents: 22562
diff changeset
96 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
97
22562
ddb3fd464b77 (get_doc_string): 2nd arg is now DEFINITION;
Richard M. Stallman <rms@gnu.org>
parents: 22268
diff changeset
98 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
99 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
100 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
101 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
102
22268
9308a15aa8f8 (get_doc_string): Make non-static.
Richard M. Stallman <rms@gnu.org>
parents: 22043
diff changeset
103 Lisp_Object
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
104 get_doc_string (Lisp_Object filepos, int unibyte, int definition)
9087
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
105 {
10202
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
106 char *from, *to;
9087
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
107 register int fd;
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
108 register char *name;
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
109 register char *p, *p1;
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
110 int minsize;
14552
e6f31368feeb (get_doc_string): Always read entire disk blocks.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
111 int offset, position;
10202
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
112 Lisp_Object file, tem;
9087
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
113
10202
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
114 if (INTEGERP (filepos))
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
115 {
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
116 file = Vdoc_file_name;
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
117 position = XINT (filepos);
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
118 }
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
119 else if (CONSP (filepos))
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
120 {
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 24573
diff changeset
121 file = XCAR (filepos);
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 24573
diff changeset
122 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
123 }
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
124 else
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
125 return Qnil;
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
126
41823
e192139240f2 (Fsnarf_documentation): Add prototype.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 41218
diff changeset
127 if (position < 0)
e192139240f2 (Fsnarf_documentation): Add prototype.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 41218
diff changeset
128 position = - position;
e192139240f2 (Fsnarf_documentation): Add prototype.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 41218
diff changeset
129
10202
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
130 if (!STRINGP (Vdoc_directory))
9087
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
131 return Qnil;
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
132
10202
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
133 if (!STRINGP (file))
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
134 return Qnil;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46370
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 /* 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
137 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
138
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
139 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
140 if (NILP (tem))
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
141 {
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 45368
diff changeset
142 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
143 /* sizeof ("../etc/") == 8 */
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
144 if (minsize < 8)
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
145 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
146 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
147 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
148 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
149 }
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
150 else
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
151 {
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 45368
diff changeset
152 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
153 }
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154
26088
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 26076
diff changeset
155 fd = emacs_open (name, O_RDONLY, 0);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 if (fd < 0)
9087
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
157 {
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
158 #ifndef CANNOT_DUMP
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
159 if (!NILP (Vpurify_flag))
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
160 {
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
161 /* 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
162 So check in ../etc. */
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
163 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
164 strcat (name, SDATA (file));
9087
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
165
26088
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 26076
diff changeset
166 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
167 }
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
168 #endif
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
169 if (fd < 0)
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
170 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
171 }
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
172
14552
e6f31368feeb (get_doc_string): Always read entire disk blocks.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
173 /* 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
174 /* 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
175 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
176 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
177 if (0 > lseek (fd, position - offset, 0))
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
178 {
26088
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 26076
diff changeset
179 emacs_close (fd);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
180 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
181 position, name);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182 }
10202
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
183
14648
45d13c154bb4 (get_doc_string): Move static vars outside the function,
Richard M. Stallman <rms@gnu.org>
parents: 14552
diff changeset
184 /* 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
185 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
186
14648
45d13c154bb4 (get_doc_string): Move static vars outside the function,
Richard M. Stallman <rms@gnu.org>
parents: 14552
diff changeset
187 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
188 while (1)
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189 {
14648
45d13c154bb4 (get_doc_string): Move static vars outside the function,
Richard M. Stallman <rms@gnu.org>
parents: 14552
diff changeset
190 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
191 - (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
192 int nread;
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
193
14552
e6f31368feeb (get_doc_string): Always read entire disk blocks.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
194 /* 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
195 if (space_left == 0)
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
196 {
14648
45d13c154bb4 (get_doc_string): Move static vars outside the function,
Richard M. Stallman <rms@gnu.org>
parents: 14552
diff changeset
197 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
198 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
199 get_doc_string_buffer
45d13c154bb4 (get_doc_string): Move static vars outside the function,
Richard M. Stallman <rms@gnu.org>
parents: 14552
diff changeset
200 = (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
201 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
202 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
203 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
204 - (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
205 }
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
206
14552
e6f31368feeb (get_doc_string): Always read entire disk blocks.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
207 /* 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
208 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
209 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
210 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
211 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
212 if (nread < 0)
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
213 {
26088
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 26076
diff changeset
214 emacs_close (fd);
10202
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
215 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
216 }
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
217 p[nread] = 0;
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
218 if (!nread)
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219 break;
14648
45d13c154bb4 (get_doc_string): Move static vars outside the function,
Richard M. Stallman <rms@gnu.org>
parents: 14552
diff changeset
220 if (p == get_doc_string_buffer)
31225
7930c46bb365 (toplevel) [HAVE_STRING_H]: Include string.h.
Gerd Moellmann <gerd@gnu.org>
parents: 30154
diff changeset
221 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
222 else
31225
7930c46bb365 (toplevel) [HAVE_STRING_H]: Include string.h.
Gerd Moellmann <gerd@gnu.org>
parents: 30154
diff changeset
223 p1 = (char *) index (p, '\037');
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224 if (p1)
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
225 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
226 *p1 = 0;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227 p = p1;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228 break;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229 }
10202
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
230 p += nread;
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231 }
26088
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 26076
diff changeset
232 emacs_close (fd);
10202
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
233
44324
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
234 /* Sanity checking. */
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
235 if (CONSP (filepos))
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
236 {
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
237 int test = 1;
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
238 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
239 return Qnil;
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
240 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
241 && 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
242 test++;
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
243 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
244 || 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
245 return Qnil;
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
246 }
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
247 else
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
248 {
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
249 int test = 1;
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
250 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
251 return Qnil;
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
252 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
253 test++;
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
254 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
255 return Qnil;
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
256 }
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
257
10202
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
258 /* 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
259 ^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
260 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
261 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
262 while (from != p)
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
263 {
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
264 if (*from == 1)
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
265 {
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
266 int c;
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
267
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
268 from++;
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
269 c = *from++;
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
270 if (c == 1)
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
271 *to++ = c;
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
272 else if (c == '0')
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
273 *to++ = 0;
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
274 else if (c == '_')
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
275 *to++ = 037;
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
276 else
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
277 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
278 }
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
279 else
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
280 *to++ = *from++;
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
281 }
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
282
22690
31bc848c5f18 (get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents: 22602
diff changeset
283 /* 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
284 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
285 if (definition)
ddb3fd464b77 (get_doc_string): 2nd arg is now DEFINITION;
Richard M. Stallman <rms@gnu.org>
parents: 22268
diff changeset
286 {
22690
31bc848c5f18 (get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents: 22602
diff changeset
287 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
288 return Fread (Qlambda);
22562
ddb3fd464b77 (get_doc_string): 2nd arg is now DEFINITION;
Richard M. Stallman <rms@gnu.org>
parents: 22268
diff changeset
289 }
ddb3fd464b77 (get_doc_string): 2nd arg is now DEFINITION;
Richard M. Stallman <rms@gnu.org>
parents: 22268
diff changeset
290
22602
9c6b3b9c3c8f (get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents: 22562
diff changeset
291 if (unibyte)
9c6b3b9c3c8f (get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents: 22562
diff changeset
292 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
293 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
294 else
24573
aa24b1cb428a (get_doc_string): When UNIBYTE and DEFINITION are 0,
Richard M. Stallman <rms@gnu.org>
parents: 23921
diff changeset
295 {
aa24b1cb428a (get_doc_string): When UNIBYTE and DEFINITION are 0,
Richard M. Stallman <rms@gnu.org>
parents: 23921
diff changeset
296 /* 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
297 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
298 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
299 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
300 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
301 nchars,
aa24b1cb428a (get_doc_string): When UNIBYTE and DEFINITION are 0,
Richard M. Stallman <rms@gnu.org>
parents: 23921
diff changeset
302 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
303 }
10202
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
304 }
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 /* 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
307 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
308 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
309
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
310 Lisp_Object
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
311 read_doc_string (Lisp_Object filepos)
10202
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
312 {
22602
9c6b3b9c3c8f (get_doc_string): Take both UNIBYTE and DEFINITION as args.
Richard M. Stallman <rms@gnu.org>
parents: 22562
diff changeset
313 return get_doc_string (filepos, 0, 1);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
314 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
315
44348
80c9e94bec17 (reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44324
diff changeset
316 static int
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
317 reread_doc_file (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
318 {
45368
65ad2c8b301b (reread_doc_file): Don't ask for confirmation.
Richard M. Stallman <rms@gnu.org>
parents: 44385
diff changeset
319 #if 0
44324
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
320 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
321 struct gcpro gcpro1;
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
322 GCPRO1 (file);
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
323 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
324 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
325 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
326 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
327 UNGCPRO;
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
328 if (NILP (reply))
44348
80c9e94bec17 (reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44324
diff changeset
329 return 0;
45368
65ad2c8b301b (reread_doc_file): Don't ask for confirmation.
Richard M. Stallman <rms@gnu.org>
parents: 44385
diff changeset
330 #endif
44324
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
331
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
332 if (NILP (file))
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
333 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
334 else
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
335 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
336
80c9e94bec17 (reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44324
diff changeset
337 return 1;
44324
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
338 }
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
339
570
c5bfe6e87d93 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 485
diff changeset
340 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
341 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
342 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
343 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
344 (function, raw)
647
529171c8b71c entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 604
diff changeset
345 Lisp_Object function, raw;
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
346 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
347 Lisp_Object fun;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
348 Lisp_Object funcar;
570
c5bfe6e87d93 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 485
diff changeset
349 Lisp_Object tem, doc;
44348
80c9e94bec17 (reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44324
diff changeset
350 int try_reload = 1;
80c9e94bec17 (reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44324
diff changeset
351
80c9e94bec17 (reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44324
diff changeset
352 documentation:
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
353
34363
62a349fc3d3c (Fsubstitute_command_keys): Change the way buffers
Gerd Moellmann <gerd@gnu.org>
parents: 32988
diff changeset
354 doc = Qnil;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46370
diff changeset
355
28334
f9cb3463ee2a (Qfunction_documentation): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28036
diff changeset
356 if (SYMBOLP (function)
f9cb3463ee2a (Qfunction_documentation): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28036
diff changeset
357 && (tem = Fget (function, Qfunction_documentation),
f9cb3463ee2a (Qfunction_documentation): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28036
diff changeset
358 !NILP (tem)))
f9cb3463ee2a (Qfunction_documentation): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28036
diff changeset
359 return Fdocumentation_property (function, Qfunction_documentation, raw);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46370
diff changeset
360
68758
13c1b7c5f555 * data.c (Findirect_function): Add NOERROR arg. All callers changed
Kim F. Storm <storm@cua.dk>
parents: 68651
diff changeset
361 fun = Findirect_function (function, Qnil);
10002
5b2b7e378772 (Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9958
diff changeset
362 if (SUBRP (fun))
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
363 {
28334
f9cb3463ee2a (Qfunction_documentation): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28036
diff changeset
364 if (XSUBR (fun)->doc == 0)
f9cb3463ee2a (Qfunction_documentation): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28036
diff changeset
365 return Qnil;
f9cb3463ee2a (Qfunction_documentation): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28036
diff changeset
366 else if ((EMACS_INT) XSUBR (fun)->doc >= 0)
570
c5bfe6e87d93 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 485
diff changeset
367 doc = build_string (XSUBR (fun)->doc);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
368 else
41823
e192139240f2 (Fsnarf_documentation): Add prototype.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 41218
diff changeset
369 doc = make_number ((EMACS_INT) XSUBR (fun)->doc);
10002
5b2b7e378772 (Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9958
diff changeset
370 }
5b2b7e378772 (Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9958
diff changeset
371 else if (COMPILEDP (fun))
5b2b7e378772 (Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9958
diff changeset
372 {
41823
e192139240f2 (Fsnarf_documentation): Add prototype.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 41218
diff changeset
373 if ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) <= COMPILED_DOC_STRING)
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
374 return Qnil;
41823
e192139240f2 (Fsnarf_documentation): Add prototype.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 41218
diff changeset
375 tem = AREF (fun, COMPILED_DOC_STRING);
9133
48820d57a24c (get_doc_string, Fdocumentation, Fdocumentation_property,
Karl Heuer <kwzh@gnu.org>
parents: 9087
diff changeset
376 if (STRINGP (tem))
570
c5bfe6e87d93 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 485
diff changeset
377 doc = tem;
10202
4013c083162e (get_doc_string): Now static. Arg now Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 10002
diff changeset
378 else if (NATNUMP (tem) || CONSP (tem))
41823
e192139240f2 (Fsnarf_documentation): Add prototype.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 41218
diff changeset
379 doc = tem;
570
c5bfe6e87d93 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 485
diff changeset
380 else
c5bfe6e87d93 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 485
diff changeset
381 return Qnil;
10002
5b2b7e378772 (Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9958
diff changeset
382 }
5b2b7e378772 (Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9958
diff changeset
383 else if (STRINGP (fun) || VECTORP (fun))
5b2b7e378772 (Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9958
diff changeset
384 {
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
385 return build_string ("Keyboard macro.");
10002
5b2b7e378772 (Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9958
diff changeset
386 }
5b2b7e378772 (Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9958
diff changeset
387 else if (CONSP (fun))
5b2b7e378772 (Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9958
diff changeset
388 {
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
389 funcar = Fcar (fun);
9133
48820d57a24c (get_doc_string, Fdocumentation, Fdocumentation_property,
Karl Heuer <kwzh@gnu.org>
parents: 9087
diff changeset
390 if (!SYMBOLP (funcar))
71974
9208340e9cad (Fdocumentation): Use xsignal1.
Kim F. Storm <storm@cua.dk>
parents: 68784
diff changeset
391 xsignal1 (Qinvalid_function, fun);
647
529171c8b71c entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 604
diff changeset
392 else if (EQ (funcar, Qkeymap))
23921
81a6345fd5e8 (Fdocumentation): Change the doc string for prefix
Andreas Schwab <schwab@suse.de>
parents: 22890
diff changeset
393 return build_string ("Prefix command (definition is a keymap associating keystrokes with commands).");
647
529171c8b71c entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 604
diff changeset
394 else if (EQ (funcar, Qlambda)
529171c8b71c entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 604
diff changeset
395 || EQ (funcar, Qautoload))
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
396 {
13521
13e55327ef5e (Fdocumentation): Reject a file reference
Richard M. Stallman <rms@gnu.org>
parents: 13244
diff changeset
397 Lisp_Object tem1;
13e55327ef5e (Fdocumentation): Reject a file reference
Richard M. Stallman <rms@gnu.org>
parents: 13244
diff changeset
398 tem1 = Fcdr (Fcdr (fun));
13e55327ef5e (Fdocumentation): Reject a file reference
Richard M. Stallman <rms@gnu.org>
parents: 13244
diff changeset
399 tem = Fcar (tem1);
9133
48820d57a24c (get_doc_string, Fdocumentation, Fdocumentation_property,
Karl Heuer <kwzh@gnu.org>
parents: 9087
diff changeset
400 if (STRINGP (tem))
570
c5bfe6e87d93 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 485
diff changeset
401 doc = tem;
13521
13e55327ef5e (Fdocumentation): Reject a file reference
Richard M. Stallman <rms@gnu.org>
parents: 13244
diff changeset
402 /* 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
403 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
404 else if ((NATNUMP (tem) || (CONSP (tem) && INTEGERP (XCDR (tem))))
e192139240f2 (Fsnarf_documentation): Add prototype.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 41218
diff changeset
405 && !NILP (XCDR (tem1)))
e192139240f2 (Fsnarf_documentation): Add prototype.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 41218
diff changeset
406 doc = tem;
570
c5bfe6e87d93 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 485
diff changeset
407 else
c5bfe6e87d93 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 485
diff changeset
408 return Qnil;
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
409 }
647
529171c8b71c entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 604
diff changeset
410 else if (EQ (funcar, Qmacro))
570
c5bfe6e87d93 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 485
diff changeset
411 return Fdocumentation (Fcdr (fun), raw);
10002
5b2b7e378772 (Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9958
diff changeset
412 else
5b2b7e378772 (Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9958
diff changeset
413 goto oops;
5b2b7e378772 (Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9958
diff changeset
414 }
5b2b7e378772 (Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9958
diff changeset
415 else
5b2b7e378772 (Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9958
diff changeset
416 {
5b2b7e378772 (Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9958
diff changeset
417 oops:
71974
9208340e9cad (Fdocumentation): Use xsignal1.
Kim F. Storm <storm@cua.dk>
parents: 68784
diff changeset
418 xsignal1 (Qinvalid_function, fun);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
419 }
570
c5bfe6e87d93 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 485
diff changeset
420
85493
97bdce721eef (Fdocumentation): Check for advice in all cases.
Juanma Barranquero <lekktu@gmail.com>
parents: 85446
diff changeset
421 /* Check for an advised function. Its doc string
97bdce721eef (Fdocumentation): Check for advice in all cases.
Juanma Barranquero <lekktu@gmail.com>
parents: 85446
diff changeset
422 has an `ad-advice-info' text property. */
97bdce721eef (Fdocumentation): Check for advice in all cases.
Juanma Barranquero <lekktu@gmail.com>
parents: 85446
diff changeset
423 if (STRINGP (doc))
97bdce721eef (Fdocumentation): Check for advice in all cases.
Juanma Barranquero <lekktu@gmail.com>
parents: 85446
diff changeset
424 {
97bdce721eef (Fdocumentation): Check for advice in all cases.
Juanma Barranquero <lekktu@gmail.com>
parents: 85446
diff changeset
425 Lisp_Object innerfunc;
97bdce721eef (Fdocumentation): Check for advice in all cases.
Juanma Barranquero <lekktu@gmail.com>
parents: 85446
diff changeset
426 innerfunc = Fget_text_property (make_number (0),
97bdce721eef (Fdocumentation): Check for advice in all cases.
Juanma Barranquero <lekktu@gmail.com>
parents: 85446
diff changeset
427 intern ("ad-advice-info"),
97bdce721eef (Fdocumentation): Check for advice in all cases.
Juanma Barranquero <lekktu@gmail.com>
parents: 85446
diff changeset
428 doc);
97bdce721eef (Fdocumentation): Check for advice in all cases.
Juanma Barranquero <lekktu@gmail.com>
parents: 85446
diff changeset
429 if (! NILP (innerfunc))
97bdce721eef (Fdocumentation): Check for advice in all cases.
Juanma Barranquero <lekktu@gmail.com>
parents: 85446
diff changeset
430 doc = call1 (intern ("ad-make-advised-docstring"), innerfunc);
97bdce721eef (Fdocumentation): Check for advice in all cases.
Juanma Barranquero <lekktu@gmail.com>
parents: 85446
diff changeset
431 }
97bdce721eef (Fdocumentation): Check for advice in all cases.
Juanma Barranquero <lekktu@gmail.com>
parents: 85446
diff changeset
432
44348
80c9e94bec17 (reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44324
diff changeset
433 /* 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
434 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
435 if (EQ (doc, make_number (0)))
d5cf9afe17d6 (Fdocumentation): More brainos. I need sleep.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44383
diff changeset
436 doc = Qnil;
44381
15b5489c78d6 (Fdocumentation, Fdocumentation_property): When the doc
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44355
diff changeset
437 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
438 {
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
439 Lisp_Object tem;
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
440 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
441 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
442 {
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
443 /* 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
444 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
445 GCPRO2 (function, raw);
44348
80c9e94bec17 (reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44324
diff changeset
446 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
447 UNGCPRO;
44348
80c9e94bec17 (reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44324
diff changeset
448 if (try_reload)
80c9e94bec17 (reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44324
diff changeset
449 {
80c9e94bec17 (reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44324
diff changeset
450 try_reload = 0;
80c9e94bec17 (reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44324
diff changeset
451 goto documentation;
80c9e94bec17 (reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44324
diff changeset
452 }
44324
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
453 }
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
454 else
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
455 doc = tem;
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
456 }
41823
e192139240f2 (Fsnarf_documentation): Add prototype.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 41218
diff changeset
457
577
53f29271d1b0 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 570
diff changeset
458 if (NILP (raw))
26471
b1863c0b8f9c (Fdocumentation): Remove gcpro here too.
Dave Love <fx@gnu.org>
parents: 26420
diff changeset
459 doc = Fsubstitute_command_keys (doc);
570
c5bfe6e87d93 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 485
diff changeset
460 return doc;
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
461 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
462
28036
ec8b11f3d3da (Fdocumentation_property): If value is not a string,
Gerd Moellmann <gerd@gnu.org>
parents: 27560
diff changeset
463 DEFUN ("documentation-property", Fdocumentation_property,
ec8b11f3d3da (Fdocumentation_property): If value is not a string,
Gerd Moellmann <gerd@gnu.org>
parents: 27560
diff changeset
464 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
465 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
466 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
467 `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
468
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40702
diff changeset
469 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
470 `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
471 aren't strings. */)
14069
a45a97ebdf1c (Fdocumentation, Fdocumentation_property, Fsubstitute_command_keys):
Erik Naggum <erik@naggum.no>
parents: 13521
diff changeset
472 (symbol, prop, raw)
a45a97ebdf1c (Fdocumentation, Fdocumentation_property, Fsubstitute_command_keys):
Erik Naggum <erik@naggum.no>
parents: 13521
diff changeset
473 Lisp_Object symbol, prop, raw;
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
474 {
44348
80c9e94bec17 (reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44324
diff changeset
475 int try_reload = 1;
26076
edbfca66058d (Fdocumentation_property): Remove register declaration for `tem'.
Dave Love <fx@gnu.org>
parents: 26075
diff changeset
476 Lisp_Object tem;
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
477
44348
80c9e94bec17 (reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44324
diff changeset
478 documentation_property:
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46370
diff changeset
479
14069
a45a97ebdf1c (Fdocumentation, Fdocumentation_property, Fsubstitute_command_keys):
Erik Naggum <erik@naggum.no>
parents: 13521
diff changeset
480 tem = Fget (symbol, prop);
44383
e44eec58a815 (Fdocumentation): Add missing parentheses.
Juanma Barranquero <lekktu@gmail.com>
parents: 44381
diff changeset
481 if (EQ (tem, make_number (0)))
44385
d5cf9afe17d6 (Fdocumentation): More brainos. I need sleep.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44383
diff changeset
482 tem = Qnil;
44381
15b5489c78d6 (Fdocumentation, Fdocumentation_property): When the doc
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44355
diff changeset
483 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
484 {
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
485 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
486 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
487 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
488 {
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
489 /* 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
490 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
491 GCPRO3 (symbol, prop, raw);
44348
80c9e94bec17 (reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44324
diff changeset
492 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
493 UNGCPRO;
44348
80c9e94bec17 (reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44324
diff changeset
494 if (try_reload)
80c9e94bec17 (reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44324
diff changeset
495 {
80c9e94bec17 (reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44324
diff changeset
496 try_reload = 0;
80c9e94bec17 (reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44324
diff changeset
497 goto documentation_property;
80c9e94bec17 (reread_doc_file): Return whether reload was attempted.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44324
diff changeset
498 }
44324
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
499 }
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
500 }
28036
ec8b11f3d3da (Fdocumentation_property): If value is not a string,
Gerd Moellmann <gerd@gnu.org>
parents: 27560
diff changeset
501 else if (!STRINGP (tem))
ec8b11f3d3da (Fdocumentation_property): If value is not a string,
Gerd Moellmann <gerd@gnu.org>
parents: 27560
diff changeset
502 /* Feval protects its argument. */
ec8b11f3d3da (Fdocumentation_property): If value is not a string,
Gerd Moellmann <gerd@gnu.org>
parents: 27560
diff changeset
503 tem = Feval (tem);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46370
diff changeset
504
9133
48820d57a24c (get_doc_string, Fdocumentation, Fdocumentation_property,
Karl Heuer <kwzh@gnu.org>
parents: 9087
diff changeset
505 if (NILP (raw) && STRINGP (tem))
26420
00b7d6135be4 (Fdocumentation_property): Remove GCPRO because
Gerd Moellmann <gerd@gnu.org>
parents: 26317
diff changeset
506 tem = Fsubstitute_command_keys (tem);
312
adba7439e87c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 297
diff changeset
507 return tem;
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
508 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
509
1651
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
510 /* 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
511
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
512 static void
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
513 store_function_docstring (Lisp_Object fun, EMACS_INT offset)
109131
18f8e88d3829 Fix comments and whitespace.
Juanma Barranquero <lekktu@gmail.com>
parents: 109126
diff changeset
514 /* Use EMACS_INT because we get offset from pointer subtraction. */
1651
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
515 {
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
516 fun = indirect_function (fun);
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
517
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
518 /* 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
519
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
520 /* Lisp_Subrs have a slot for it. */
9133
48820d57a24c (get_doc_string, Fdocumentation, Fdocumentation_property,
Karl Heuer <kwzh@gnu.org>
parents: 9087
diff changeset
521 if (SUBRP (fun))
1651
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
522 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
523
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
524 /* 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
525 else if (CONSP (fun))
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
526 {
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
527 Lisp_Object tem;
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
528
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 24573
diff changeset
529 tem = XCAR (fun);
1651
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
530 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
531 {
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
532 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
533 if (CONSP (tem) && INTEGERP (XCAR (tem)))
108161
514ebf69b289 Fix wrong-docstring problem introduced with hash-consing.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
534 XSETCAR (tem, make_number (offset));
1651
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 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
537 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
538 }
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 /* Bytecode objects sometimes have slots for it. */
9133
48820d57a24c (get_doc_string, Fdocumentation, Fdocumentation_property,
Karl Heuer <kwzh@gnu.org>
parents: 9087
diff changeset
541 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
542 {
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
543 /* 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
544 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
545 if ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) > COMPILED_DOC_STRING)
91607
d1e53221c4aa * xselect.c (x_handle_dnd_message):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91327
diff changeset
546 ASET (fun, COMPILED_DOC_STRING, make_number (offset));
1651
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 }
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
549
104619
90578b9cc2d2 * Makefile.in (buildobj.h): New target.
Ken Raeburn <raeburn@raeburn.org>
parents: 100951
diff changeset
550 static const char buildobj[] = BUILDOBJ;
1651
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
551
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
552 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
553 1, 1, 0,
41218
ace002127a1c (Fsnarf_documentation): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 41001
diff changeset
554 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
555 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
556 records them in function and variable definitions.
ace002127a1c (Fsnarf_documentation): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 41001
diff changeset
557 The function takes one argument, FILENAME, a string;
ace002127a1c (Fsnarf_documentation): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 41001
diff changeset
558 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
559 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
560 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
561 (filename)
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
562 Lisp_Object filename;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
563 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
564 int fd;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
565 char buf[1024 + 1];
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
566 register int filled;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
567 register int pos;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
568 register char *p, *end;
34963
681963400696 (Fsnarf_documentation): Remove unused variables `fun' and
Eli Zaretskii <eliz@gnu.org>
parents: 34363
diff changeset
569 Lisp_Object sym;
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
570 char *name;
58068
df00cdb75fc6 * doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57497
diff changeset
571 int skip_file = 0;
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
572
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40139
diff changeset
573 CHECK_STRING (filename);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
574
44324
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
575 if
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
576 #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
577 (!NILP (Vpurify_flag))
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
578 #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
579 (0)
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
580 #endif /* CANNOT_DUMP */
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
581 {
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 45368
diff changeset
582 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
583 strcpy (name, "../etc/");
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
584 }
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
585 else
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
586 {
def57419f6ec (get_doc_string): Return nil of the location is wrong.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43155
diff changeset
587 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
588 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
589 + 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
590 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
591 }
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 45368
diff changeset
592 strcat (name, SDATA (filename)); /*** Add this line ***/
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
593
58068
df00cdb75fc6 * doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57497
diff changeset
594 /* 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
595 if (NILP (Vbuild_files))
df00cdb75fc6 * doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57497
diff changeset
596 {
104619
90578b9cc2d2 * Makefile.in (buildobj.h): New target.
Ken Raeburn <raeburn@raeburn.org>
parents: 100951
diff changeset
597 const char *beg, *end;
58068
df00cdb75fc6 * doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57497
diff changeset
598
104619
90578b9cc2d2 * Makefile.in (buildobj.h): New target.
Ken Raeburn <raeburn@raeburn.org>
parents: 100951
diff changeset
599 for (beg = buildobj; *beg; beg = end)
58068
df00cdb75fc6 * doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57497
diff changeset
600 {
df00cdb75fc6 * doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57497
diff changeset
601 int len;
df00cdb75fc6 * doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57497
diff changeset
602
df00cdb75fc6 * doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57497
diff changeset
603 while (*beg && isspace (*beg)) ++beg;
df00cdb75fc6 * doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57497
diff changeset
604
df00cdb75fc6 * doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57497
diff changeset
605 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
606 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
607
df00cdb75fc6 * doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57497
diff changeset
608 len = end - beg;
df00cdb75fc6 * doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57497
diff changeset
609 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
610 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
611
df00cdb75fc6 * doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57497
diff changeset
612 if (len > 0)
df00cdb75fc6 * doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57497
diff changeset
613 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
614 }
105942
5fc80e6b5b7c * xfns.c (syms_of_xfns): Use make_pure_string instead of build_string.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105877
diff changeset
615 Vbuild_files = Fpurecopy (Vbuild_files);
58068
df00cdb75fc6 * doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57497
diff changeset
616 }
df00cdb75fc6 * doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57497
diff changeset
617
26088
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 26076
diff changeset
618 fd = emacs_open (name, O_RDONLY, 0);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
619 if (fd < 0)
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
620 report_file_error ("Opening doc string file",
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
621 Fcons (build_string (name), Qnil));
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
622 Vdoc_file_name = filename;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
623 filled = 0;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
624 pos = 0;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
625 while (1)
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
626 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
627 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
628 filled += emacs_read (fd, &buf[filled], sizeof buf - 1 - filled);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
629 if (!filled)
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
630 break;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
631
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
632 buf[filled] = 0;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
633 p = buf;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
634 end = buf + (filled < 512 ? filled : filled - 128);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
635 while (p != end && *p != '\037') p++;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
636 /* p points to ^_Ffunctionname\n or ^_Vvarname\n. */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
637 if (p != end)
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
638 {
31225
7930c46bb365 (toplevel) [HAVE_STRING_H]: Include string.h.
Gerd Moellmann <gerd@gnu.org>
parents: 30154
diff changeset
639 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
640
df00cdb75fc6 * doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57497
diff changeset
641 /* 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
642 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
643 && (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
644 {
df00cdb75fc6 * doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57497
diff changeset
645 int len = end - p - 2;
df00cdb75fc6 * doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57497
diff changeset
646 char *fromfile = alloca (len + 1);
df00cdb75fc6 * doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57497
diff changeset
647 strncpy (fromfile, &p[2], len);
df00cdb75fc6 * doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57497
diff changeset
648 fromfile[len] = 0;
df00cdb75fc6 * doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57497
diff changeset
649 if (fromfile[len-1] == 'c')
df00cdb75fc6 * doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57497
diff changeset
650 fromfile[len-1] = 'o';
df00cdb75fc6 * doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57497
diff changeset
651
85324
228a7fde2f4a (Fsnarf_documentation): Simplify.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82140
diff changeset
652 skip_file = NILP (Fmember (build_string (fromfile),
228a7fde2f4a (Fsnarf_documentation): Simplify.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82140
diff changeset
653 Vbuild_files));
58068
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
20619
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
656 sym = oblookup (Vobarray, p + 2,
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
657 multibyte_chars_in_text (p + 2, end - p - 2),
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
658 end - p - 2);
85324
228a7fde2f4a (Fsnarf_documentation): Simplify.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82140
diff changeset
659 /* Check skip_file so that when a function is defined several
228a7fde2f4a (Fsnarf_documentation): Simplify.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82140
diff changeset
660 times in different files (typically, once in xterm, once in
228a7fde2f4a (Fsnarf_documentation): Simplify.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82140
diff changeset
661 w32term, ...), we only pay attention to the one that
228a7fde2f4a (Fsnarf_documentation): Simplify.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82140
diff changeset
662 matters. */
58068
df00cdb75fc6 * doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57497
diff changeset
663 if (! skip_file && SYMBOLP (sym))
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
664 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
665 /* Attach a docstring to a variable? */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
666 if (p[1] == 'V')
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
667 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
668 /* Install file-position as variable-documentation property
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
669 and make it negative for a user-variable
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
670 (doc starts with a `*'). */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
671 Fput (sym, Qvariable_documentation,
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
672 make_number ((pos + end + 1 - buf)
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
673 * (end[1] == '*' ? -1 : 1)));
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
674 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
675
1651
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
676 /* Attach a docstring to a function? */
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
677 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
678 store_function_docstring (sym, pos + end + 1 - buf);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
679
54745
98cf37e32872 (Fsnarf_documentation): Ignore new file name entries.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54234
diff changeset
680 else if (p[1] == 'S')
98cf37e32872 (Fsnarf_documentation): Ignore new file name entries.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54234
diff changeset
681 ; /* 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
682
1651
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
683 else
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
684 error ("DOC file invalid at position %d", pos);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
685 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
686 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
687 pos += end - buf;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
688 filled -= end - buf;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
689 bcopy (end, buf, filled);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
690 }
26088
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 26076
diff changeset
691 emacs_close (fd);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
692 return Qnil;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
693 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
694
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
695 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
696 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
697 doc: /* Substitute key descriptions for command names in STRING.
66815
b9685771709d (Fsubstitute_command_keys): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 65391
diff changeset
698 Substrings of the form \\=\\[COMMAND] replaced by either: a keystroke
b9685771709d (Fsubstitute_command_keys): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 65391
diff changeset
699 sequence that will invoke COMMAND, or "M-x COMMAND" if COMMAND is not
b9685771709d (Fsubstitute_command_keys): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 65391
diff changeset
700 on any keys.
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40702
diff changeset
701 Substrings of the form \\=\\{MAPVAR} are replaced by summaries
68784
768bd941cf0d (Fsubstitute_command_keys): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 68758
diff changeset
702 \(made by `describe-bindings') of the value of MAPVAR, taken as a keymap.
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40702
diff changeset
703 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
704 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
705 \\=\\= quotes the following character and is discarded;
66815
b9685771709d (Fsubstitute_command_keys): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 65391
diff changeset
706 thus, \\=\\=\\=\\= puts \\=\\= into the output, and \\=\\=\\=\\[ puts \\=\\[ into the output.
b9685771709d (Fsubstitute_command_keys): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 65391
diff changeset
707
75968
88a395ffffbc (Fsubstitute_command_keys): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 75348
diff changeset
708 Returns original STRING if no substitutions were made. Otherwise,
66815
b9685771709d (Fsubstitute_command_keys): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 65391
diff changeset
709 a new string, without any text properties, is returned. */)
41001
a17c8b15ef1b Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40702
diff changeset
710 (string)
14069
a45a97ebdf1c (Fdocumentation, Fdocumentation_property, Fsubstitute_command_keys):
Erik Naggum <erik@naggum.no>
parents: 13521
diff changeset
711 Lisp_Object string;
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
712 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
713 unsigned char *buf;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
714 int changed = 0;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
715 register unsigned char *strp;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
716 register unsigned char *bufp;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
717 int idx;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
718 int bsize;
1511
ff88f962a982 * doc.c: #include keyboard.h.
Jim Blandy <jimb@redhat.com>
parents: 1116
diff changeset
719 Lisp_Object tem;
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
720 Lisp_Object keymap;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
721 unsigned char *start;
20802
8cd0a6343a84 (Fsubstitute_command_keys): Declare length_byte out of
Kenichi Handa <handa@m17n.org>
parents: 20708
diff changeset
722 int length, length_byte;
1511
ff88f962a982 * doc.c: #include keyboard.h.
Jim Blandy <jimb@redhat.com>
parents: 1116
diff changeset
723 Lisp_Object name;
ff88f962a982 * doc.c: #include keyboard.h.
Jim Blandy <jimb@redhat.com>
parents: 1116
diff changeset
724 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
20619
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
725 int multibyte;
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
726 int nchars;
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
727
14069
a45a97ebdf1c (Fdocumentation, Fdocumentation_property, Fsubstitute_command_keys):
Erik Naggum <erik@naggum.no>
parents: 13521
diff changeset
728 if (NILP (string))
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
729 return Qnil;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
730
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40139
diff changeset
731 CHECK_STRING (string);
1511
ff88f962a982 * doc.c: #include keyboard.h.
Jim Blandy <jimb@redhat.com>
parents: 1116
diff changeset
732 tem = Qnil;
ff88f962a982 * doc.c: #include keyboard.h.
Jim Blandy <jimb@redhat.com>
parents: 1116
diff changeset
733 keymap = Qnil;
ff88f962a982 * doc.c: #include keyboard.h.
Jim Blandy <jimb@redhat.com>
parents: 1116
diff changeset
734 name = Qnil;
14069
a45a97ebdf1c (Fdocumentation, Fdocumentation_property, Fsubstitute_command_keys):
Erik Naggum <erik@naggum.no>
parents: 13521
diff changeset
735 GCPRO4 (string, tem, keymap, name);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
736
20619
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
737 multibyte = STRING_MULTIBYTE (string);
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
738 nchars = 0;
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
739
5784
9c3be8e0d2ef (Fsubstitute_command_keys): Pass keymap as that arg
Richard M. Stallman <rms@gnu.org>
parents: 5550
diff changeset
740 /* 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
741 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
742 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
743 or from a \\<mapname> construct in STRING itself.. */
12261
cd2e7821bbf5 (Fsubstitute_command_keys):
Karl Heuer <kwzh@gnu.org>
parents: 11925
diff changeset
744 keymap = current_kboard->Voverriding_terminal_local_map;
cd2e7821bbf5 (Fsubstitute_command_keys):
Karl Heuer <kwzh@gnu.org>
parents: 11925
diff changeset
745 if (NILP (keymap))
cd2e7821bbf5 (Fsubstitute_command_keys):
Karl Heuer <kwzh@gnu.org>
parents: 11925
diff changeset
746 keymap = Voverriding_local_map;
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
747
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 45368
diff changeset
748 bsize = SBYTES (string);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
749 bufp = buf = (unsigned char *) xmalloc (bsize);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
750
50629
36d13cf0f114 (Fsubstitute_command_keys): Remove spurious casts.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49600
diff changeset
751 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
752 while (strp < SDATA (string) + SBYTES (string))
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
753 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
754 if (strp[0] == '\\' && strp[1] == '=')
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
755 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
756 /* \= quotes the next character;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
757 thus, to put in \[ without its special meaning, use \=\[. */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
758 changed = 1;
20619
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
759 strp += 2;
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
760 if (multibyte)
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
761 {
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
762 int len;
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
763
106185
f2cea199b0c4 * character.h (STRING_CHAR, STRING_CHAR_AND_LENGTH): Remove
Andreas Schwab <schwab@linux-m68k.org>
parents: 105942
diff changeset
764 STRING_CHAR_AND_LENGTH (strp, len);
20619
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
765 if (len == 1)
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
766 *bufp = *strp;
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
767 else
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
768 bcopy (strp, bufp, len);
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
769 strp += len;
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
770 bufp += len;
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
771 nchars++;
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
772 }
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
773 else
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
774 *bufp++ = *strp++, nchars++;
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
775 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
776 else if (strp[0] == '\\' && strp[1] == '[')
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
777 {
30154
f8e2064c56b1 (Fsubstitute_command_keys): Handle case that a GC
Gerd Moellmann <gerd@gnu.org>
parents: 28334
diff changeset
778 int start_idx;
65391
4a6f5ef57ed1 (Fsubstitute_command_keys): Lookup key binding for
Kim F. Storm <storm@cua.dk>
parents: 64770
diff changeset
779 int follow_remap = 1;
5248
27d6275810a7 (Fsubstitute_command_keys): Ignore menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents: 4716
diff changeset
780
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
781 changed = 1;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
782 strp += 2; /* skip \[ */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
783 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
784 start_idx = start - SDATA (string);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
785
50629
36d13cf0f114 (Fsubstitute_command_keys): Remove spurious casts.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49600
diff changeset
786 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
787 < SBYTES (string))
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
788 && *strp != ']')
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
789 strp++;
20619
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
790 length_byte = strp - start;
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
791
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
792 strp++; /* skip ] */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
793
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
794 /* Save STRP in IDX. */
50629
36d13cf0f114 (Fsubstitute_command_keys): Remove spurious casts.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49600
diff changeset
795 idx = strp - SDATA (string);
57497
0a4c356f307b (Fsubstitute_command_keys): Fix remap-handling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57441
diff changeset
796 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
797
65391
4a6f5ef57ed1 (Fsubstitute_command_keys): Lookup key binding for
Kim F. Storm <storm@cua.dk>
parents: 64770
diff changeset
798 do_remap:
104918
cd8d62c35d57 * keymap.c (where_is_internal_data): Make noindirect a boolean.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 104619
diff changeset
799 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
800
65391
4a6f5ef57ed1 (Fsubstitute_command_keys): Lookup key binding for
Kim F. Storm <storm@cua.dk>
parents: 64770
diff changeset
801 if (VECTORP (tem) && XVECTOR (tem)->size > 1
4a6f5ef57ed1 (Fsubstitute_command_keys): Lookup key binding for
Kim F. Storm <storm@cua.dk>
parents: 64770
diff changeset
802 && EQ (AREF (tem, 0), Qremap) && SYMBOLP (AREF (tem, 1))
4a6f5ef57ed1 (Fsubstitute_command_keys): Lookup key binding for
Kim F. Storm <storm@cua.dk>
parents: 64770
diff changeset
803 && follow_remap)
4a6f5ef57ed1 (Fsubstitute_command_keys): Lookup key binding for
Kim F. Storm <storm@cua.dk>
parents: 64770
diff changeset
804 {
4a6f5ef57ed1 (Fsubstitute_command_keys): Lookup key binding for
Kim F. Storm <storm@cua.dk>
parents: 64770
diff changeset
805 name = AREF (tem, 1);
4a6f5ef57ed1 (Fsubstitute_command_keys): Lookup key binding for
Kim F. Storm <storm@cua.dk>
parents: 64770
diff changeset
806 follow_remap = 0;
4a6f5ef57ed1 (Fsubstitute_command_keys): Lookup key binding for
Kim F. Storm <storm@cua.dk>
parents: 64770
diff changeset
807 goto do_remap;
4a6f5ef57ed1 (Fsubstitute_command_keys): Lookup key binding for
Kim F. Storm <storm@cua.dk>
parents: 64770
diff changeset
808 }
4a6f5ef57ed1 (Fsubstitute_command_keys): Lookup key binding for
Kim F. Storm <storm@cua.dk>
parents: 64770
diff changeset
809
30154
f8e2064c56b1 (Fsubstitute_command_keys): Handle case that a GC
Gerd Moellmann <gerd@gnu.org>
parents: 28334
diff changeset
810 /* 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
811 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
812 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
813 start = SDATA (string) + start_idx;
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
814
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 463
diff changeset
815 if (NILP (tem)) /* but not on any keys */
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
816 {
34363
62a349fc3d3c (Fsubstitute_command_keys): Change the way buffers
Gerd Moellmann <gerd@gnu.org>
parents: 32988
diff changeset
817 int offset = bufp - buf;
62a349fc3d3c (Fsubstitute_command_keys): Change the way buffers
Gerd Moellmann <gerd@gnu.org>
parents: 32988
diff changeset
818 buf = (unsigned char *) xrealloc (buf, bsize += 4);
62a349fc3d3c (Fsubstitute_command_keys): Change the way buffers
Gerd Moellmann <gerd@gnu.org>
parents: 32988
diff changeset
819 bufp = buf + offset;
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
820 bcopy ("M-x ", bufp, 4);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
821 bufp += 4;
20619
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
822 nchars += 4;
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
823 if (multibyte)
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
824 length = multibyte_chars_in_text (start, length_byte);
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
825 else
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
826 length = length_byte;
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
827 goto subst;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
828 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
829 else
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
830 { /* function is on a key */
54927
7b6b4d9ae726 (Fkey_description): Change callers.
Kim F. Storm <storm@cua.dk>
parents: 54745
diff changeset
831 tem = Fkey_description (tem, Qnil);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
832 goto subst_string;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
833 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
834 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
835 /* \{foo} is replaced with a summary of the keymap (symbol-value foo).
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
836 \<foo> just sets the keymap used for \[cmd]. */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
837 else if (strp[0] == '\\' && (strp[1] == '{' || strp[1] == '<'))
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
838 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
839 struct buffer *oldbuf;
30154
f8e2064c56b1 (Fsubstitute_command_keys): Handle case that a GC
Gerd Moellmann <gerd@gnu.org>
parents: 28334
diff changeset
840 int start_idx;
60065
42e18861b7b8 (Fsubstitute_command_keys): Compute list of shadowing maps
Richard M. Stallman <rms@gnu.org>
parents: 58087
diff changeset
841 /* This is for computing the SHADOWS arg for describe_map_tree. */
81609
7e640eac2dcb * keymaps.texi (Active Keymaps): Document new POSITION argument of
David Kastrup <dak@gnu.org>
parents: 75968
diff changeset
842 Lisp_Object active_maps = Fcurrent_active_maps (Qnil, Qnil);
60065
42e18861b7b8 (Fsubstitute_command_keys): Compute list of shadowing maps
Richard M. Stallman <rms@gnu.org>
parents: 58087
diff changeset
843 Lisp_Object earlier_maps;
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
844
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
845 changed = 1;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
846 strp += 2; /* skip \{ or \< */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
847 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
848 start_idx = start - SDATA (string);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
849
54234
e1003d782dc6 (Fsubstitute_command_keys): Fix counding bytes.
Kenichi Handa <handa@m17n.org>
parents: 52401
diff changeset
850 while ((strp - SDATA (string) < SBYTES (string))
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
851 && *strp != '}' && *strp != '>')
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
852 strp++;
20619
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
853
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
854 length_byte = strp - start;
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
855 strp++; /* skip } or > */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
856
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
857 /* Save STRP in IDX. */
50629
36d13cf0f114 (Fsubstitute_command_keys): Remove spurious casts.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49600
diff changeset
858 idx = strp - SDATA (string);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
859
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
860 /* Get the value of the keymap in TEM, or nil if undefined.
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
861 Do this while still in the user's current buffer
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
862 in case it is a local variable. */
20619
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
863 name = Fintern (make_string (start, length_byte), Qnil);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
864 tem = Fboundp (name);
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 463
diff changeset
865 if (! NILP (tem))
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
866 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
867 tem = Fsymbol_value (name);
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 463
diff changeset
868 if (! NILP (tem))
30154
f8e2064c56b1 (Fsubstitute_command_keys): Handle case that a GC
Gerd Moellmann <gerd@gnu.org>
parents: 28334
diff changeset
869 {
32988
c3435dc00ed7 * lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31336
diff changeset
870 tem = get_keymap (tem, 0, 1);
c3435dc00ed7 * lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31336
diff changeset
871 /* 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
872 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
873 start = SDATA (string) + start_idx;
30154
f8e2064c56b1 (Fsubstitute_command_keys): Handle case that a GC
Gerd Moellmann <gerd@gnu.org>
parents: 28334
diff changeset
874 }
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
875 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
876
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
877 /* Now switch to a temp buffer. */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
878 oldbuf = current_buffer;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
879 set_buffer_internal (XBUFFER (Vprin1_to_string_buffer));
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
880
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 463
diff changeset
881 if (NILP (tem))
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
882 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
883 name = Fsymbol_name (name);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
884 insert_string ("\nUses keymap \"");
20619
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
885 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
886 SCHARS (name),
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 45368
diff changeset
887 SBYTES (name), 1);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
888 insert_string ("\", which is not currently defined.\n");
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
889 if (start[-1] == '<') keymap = Qnil;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
890 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
891 else if (start[-1] == '<')
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
892 keymap = tem;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
893 else
60065
42e18861b7b8 (Fsubstitute_command_keys): Compute list of shadowing maps
Richard M. Stallman <rms@gnu.org>
parents: 58087
diff changeset
894 {
42e18861b7b8 (Fsubstitute_command_keys): Compute list of shadowing maps
Richard M. Stallman <rms@gnu.org>
parents: 58087
diff changeset
895 /* 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
896 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
897 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
898 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
899 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
900 }
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
901 tem = Fbuffer_string ();
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
902 Ferase_buffer ();
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
903 set_buffer_internal (oldbuf);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
904
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
905 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
906 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
907 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
908 length_byte = SBYTES (tem);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
909 subst:
34363
62a349fc3d3c (Fsubstitute_command_keys): Change the way buffers
Gerd Moellmann <gerd@gnu.org>
parents: 32988
diff changeset
910 {
62a349fc3d3c (Fsubstitute_command_keys): Change the way buffers
Gerd Moellmann <gerd@gnu.org>
parents: 32988
diff changeset
911 int offset = bufp - buf;
62a349fc3d3c (Fsubstitute_command_keys): Change the way buffers
Gerd Moellmann <gerd@gnu.org>
parents: 32988
diff changeset
912 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
913 bufp = buf + offset;
62a349fc3d3c (Fsubstitute_command_keys): Change the way buffers
Gerd Moellmann <gerd@gnu.org>
parents: 32988
diff changeset
914 bcopy (start, bufp, length_byte);
62a349fc3d3c (Fsubstitute_command_keys): Change the way buffers
Gerd Moellmann <gerd@gnu.org>
parents: 32988
diff changeset
915 bufp += length_byte;
62a349fc3d3c (Fsubstitute_command_keys): Change the way buffers
Gerd Moellmann <gerd@gnu.org>
parents: 32988
diff changeset
916 nchars += length;
62a349fc3d3c (Fsubstitute_command_keys): Change the way buffers
Gerd Moellmann <gerd@gnu.org>
parents: 32988
diff changeset
917 /* 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
918 strp = (unsigned char *) SDATA (string) + idx;
34363
62a349fc3d3c (Fsubstitute_command_keys): Change the way buffers
Gerd Moellmann <gerd@gnu.org>
parents: 32988
diff changeset
919 }
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
920 }
20619
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
921 else if (! multibyte) /* just copy other chars */
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
922 *bufp++ = *strp++, nchars++;
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
923 else
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
924 {
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
925 int len;
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
926
106185
f2cea199b0c4 * character.h (STRING_CHAR, STRING_CHAR_AND_LENGTH): Remove
Andreas Schwab <schwab@linux-m68k.org>
parents: 105942
diff changeset
927 STRING_CHAR_AND_LENGTH (strp, len);
20619
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
928 if (len == 1)
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
929 *bufp = *strp;
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
930 else
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
931 bcopy (strp, bufp, len);
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
932 strp += len;
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
933 bufp += len;
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
934 nchars++;
0a559893331d Include charset.h.
Richard M. Stallman <rms@gnu.org>
parents: 18746
diff changeset
935 }
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
936 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
937
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
938 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
939 tem = make_string_from_bytes (buf, nchars, bufp - buf);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
940 else
14069
a45a97ebdf1c (Fdocumentation, Fdocumentation_property, Fsubstitute_command_keys):
Erik Naggum <erik@naggum.no>
parents: 13521
diff changeset
941 tem = string;
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 1651
diff changeset
942 xfree (buf);
1511
ff88f962a982 * doc.c: #include keyboard.h.
Jim Blandy <jimb@redhat.com>
parents: 1116
diff changeset
943 RETURN_UNGCPRO (tem);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
944 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
945
21514
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21252
diff changeset
946 void
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
947 syms_of_doc (void)
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
948 {
105877
21bdda3ded62 * xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105669
diff changeset
949 Qfunction_documentation = intern_c_string ("function-documentation");
28334
f9cb3463ee2a (Qfunction_documentation): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28036
diff changeset
950 staticpro (&Qfunction_documentation);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46370
diff changeset
951
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
952 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
953 doc: /* Name of file containing documentation strings of built-in symbols. */);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
954 Vdoc_file_name = Qnil;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
955
58068
df00cdb75fc6 * doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57497
diff changeset
956 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
957 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
958 Vbuild_files = Qnil;
df00cdb75fc6 * doc.c: New variable Vbuild_files.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57497
diff changeset
959
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
960 defsubr (&Sdocumentation);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
961 defsubr (&Sdocumentation_property);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
962 defsubr (&Ssnarf_documentation);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
963 defsubr (&Ssubstitute_command_keys);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
964 }
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51402
diff changeset
965
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51402
diff changeset
966 /* arch-tag: 56281d4d-6949-43e2-be2e-f6517de744ba
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51402
diff changeset
967 (do not change this comment) */