annotate src/doc.c @ 10022:30e0dc7c07cd

(face-color-supported-p): New function. (face-try-color-list): Use that.
author Richard M. Stallman <rms@gnu.org>
date Sat, 19 Nov 1994 11:12:16 +0000
parents 5b2b7e378772
children 4013c083162e
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.
7307
cd81dba38a49 Update copyright.
Karl Heuer <kwzh@gnu.org>
parents: 6862
diff changeset
2 Copyright (C) 1985, 1986, 1993, 1994 Free Software Foundation, Inc.
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4 This file is part of GNU Emacs.
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8 the Free Software Foundation; either version 1, or (at your option)
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 any later version.
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 GNU General Public License for more details.
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20
4696
1fc792473491 Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents: 3999
diff changeset
21 #include <config.h>
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23 #include <sys/types.h>
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 #include <sys/file.h> /* Must be after sys/types.h for USG and BSD4_1*/
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26 #ifdef USG5
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27 #include <fcntl.h>
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28 #endif
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29
6862
653504b6b5dd [HAVE_UNISTD_H]: Include unistd.h.
Richard M. Stallman <rms@gnu.org>
parents: 6030
diff changeset
30 #ifdef HAVE_UNISTD_H
653504b6b5dd [HAVE_UNISTD_H]: Include unistd.h.
Richard M. Stallman <rms@gnu.org>
parents: 6030
diff changeset
31 #include <unistd.h>
653504b6b5dd [HAVE_UNISTD_H]: Include unistd.h.
Richard M. Stallman <rms@gnu.org>
parents: 6030
diff changeset
32 #endif
653504b6b5dd [HAVE_UNISTD_H]: Include unistd.h.
Richard M. Stallman <rms@gnu.org>
parents: 6030
diff changeset
33
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34 #ifndef O_RDONLY
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 #define O_RDONLY 0
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36 #endif
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 #include "lisp.h"
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39 #include "buffer.h"
1511
ff88f962a982 * doc.c: #include keyboard.h.
Jim Blandy <jimb@redhat.com>
parents: 1116
diff changeset
40 #include "keyboard.h"
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41
961
8d2cbfd93066 * doc.c (Vdata_directory): Removed; this is declared in callproc.c.
Jim Blandy <jimb@redhat.com>
parents: 943
diff changeset
42 Lisp_Object Vdoc_file_name;
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43
5784
9c3be8e0d2ef (Fsubstitute_command_keys): Pass keymap as that arg
Richard M. Stallman <rms@gnu.org>
parents: 5550
diff changeset
44 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
45
9087
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
46 /* For VMS versions with limited file name syntax,
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
47 convert the name to something VMS will allow. */
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
48 static void
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
49 munge_doc_file_name (name)
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
50 char *name;
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52 #ifdef VMS
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 #ifndef VMS4_4
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 /* For VMS versions with limited file name syntax,
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 convert the name to something VMS will allow. */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56 p = name;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57 while (*p)
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 if (*p == '-')
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 *p = '_';
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 p++;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 #endif /* not VMS4_4 */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 #ifdef VMS4_4
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65 strcpy (name, sys_translate_unix (name));
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66 #endif /* VMS4_4 */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67 #endif /* VMS */
9087
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
68 }
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
69
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
70 Lisp_Object
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
71 get_doc_string (filepos)
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
72 long filepos;
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
73 {
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
74 char buf[512 * 32 + 1];
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
75 register int fd;
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
76 register char *name;
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
77 register char *p, *p1;
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
78 register int count;
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
79 int minsize;
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
80 extern char *index ();
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
81
9133
48820d57a24c (get_doc_string, Fdocumentation, Fdocumentation_property,
Karl Heuer <kwzh@gnu.org>
parents: 9087
diff changeset
82 if (!STRINGP (Vdoc_directory) || !STRINGP (Vdoc_file_name))
9087
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
83 return Qnil;
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
84
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
85 minsize = XSTRING (Vdoc_directory)->size;
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
86 /* sizeof ("../etc/") == 8 */
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
87 if (minsize < 8)
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
88 minsize = 8;
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
89 name = (char *) alloca (minsize + XSTRING (Vdoc_file_name)->size + 8);
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
90 strcpy (name, XSTRING (Vdoc_directory)->data);
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
91 strcat (name, XSTRING (Vdoc_file_name)->data);
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
92 munge_doc_file_name (name);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 fd = open (name, O_RDONLY, 0);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95 if (fd < 0)
9087
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
96 {
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
97 #ifndef CANNOT_DUMP
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
98 if (!NILP (Vpurify_flag))
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
99 {
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
100 /* 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
101 So check in ../etc. */
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
102 strcpy (name, "../etc/");
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
103 strcat (name, XSTRING (Vdoc_file_name)->data);
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
104 munge_doc_file_name (name);
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
105
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
106 fd = open (name, O_RDONLY, 0);
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
107 }
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
108 #endif
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
109
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
110 if (fd < 0)
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
111 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
112 }
e3c272c7f4d2 (get_doc_string): Look in ../etc while dumping.
Richard M. Stallman <rms@gnu.org>
parents: 8823
diff changeset
113
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114 if (0 > lseek (fd, filepos, 0))
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116 close (fd);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117 error ("Position %ld out of range in doc string file \"%s\"",
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118 filepos, name);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
120 p = buf;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
121 while (p != buf + sizeof buf - 1)
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
122 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
123 count = read (fd, p, 512);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124 p[count] = 0;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
125 if (!count)
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126 break;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
127 p1 = index (p, '\037');
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 if (p1)
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130 *p1 = 0;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
131 p = p1;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132 break;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134 p += count;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136 close (fd);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137 return make_string (buf, p - buf);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
138 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139
570
c5bfe6e87d93 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 485
diff changeset
140 DEFUN ("documentation", Fdocumentation, Sdocumentation, 1, 2, 0,
604
63a8e7b3c547 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 577
diff changeset
141 "Return the documentation string of FUNCTION.\n\
63a8e7b3c547 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 577
diff changeset
142 Unless a non-nil second argument is given, the\n\
570
c5bfe6e87d93 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 485
diff changeset
143 string is passed through `substitute-command-keys'.")
647
529171c8b71c entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 604
diff changeset
144 (function, raw)
529171c8b71c entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 604
diff changeset
145 Lisp_Object function, raw;
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
147 Lisp_Object fun;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148 Lisp_Object funcar;
570
c5bfe6e87d93 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 485
diff changeset
149 Lisp_Object tem, doc;
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150
647
529171c8b71c entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 604
diff changeset
151 fun = Findirect_function (function);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152
10002
5b2b7e378772 (Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9958
diff changeset
153 if (SUBRP (fun))
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 if (XSUBR (fun)->doc == 0) return Qnil;
8823
fdb7ba55f05c (Fdocumentation): Use EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents: 8552
diff changeset
156 if ((EMACS_INT) XSUBR (fun)->doc >= 0)
570
c5bfe6e87d93 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 485
diff changeset
157 doc = build_string (XSUBR (fun)->doc);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158 else
8823
fdb7ba55f05c (Fdocumentation): Use EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents: 8552
diff changeset
159 doc = get_doc_string (- (EMACS_INT) XSUBR (fun)->doc);
10002
5b2b7e378772 (Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9958
diff changeset
160 }
5b2b7e378772 (Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9958
diff changeset
161 else if (COMPILEDP (fun))
5b2b7e378772 (Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9958
diff changeset
162 {
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163 if (XVECTOR (fun)->size <= COMPILED_DOC_STRING)
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164 return Qnil;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165 tem = XVECTOR (fun)->contents[COMPILED_DOC_STRING];
9133
48820d57a24c (get_doc_string, Fdocumentation, Fdocumentation_property,
Karl Heuer <kwzh@gnu.org>
parents: 9087
diff changeset
166 if (STRINGP (tem))
570
c5bfe6e87d93 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 485
diff changeset
167 doc = tem;
9958
25a7e3557fd3 (Fdocumentation): Use NATNUMP instead of its expansion.
Karl Heuer <kwzh@gnu.org>
parents: 9304
diff changeset
168 else if (NATNUMP (tem))
570
c5bfe6e87d93 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 485
diff changeset
169 doc = get_doc_string (XFASTINT (tem));
c5bfe6e87d93 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 485
diff changeset
170 else
c5bfe6e87d93 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 485
diff changeset
171 return Qnil;
10002
5b2b7e378772 (Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9958
diff changeset
172 }
5b2b7e378772 (Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9958
diff changeset
173 else if (STRINGP (fun) || VECTORP (fun))
5b2b7e378772 (Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9958
diff changeset
174 {
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175 return build_string ("Keyboard macro.");
10002
5b2b7e378772 (Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9958
diff changeset
176 }
5b2b7e378772 (Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9958
diff changeset
177 else if (CONSP (fun))
5b2b7e378772 (Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9958
diff changeset
178 {
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
179 funcar = Fcar (fun);
9133
48820d57a24c (get_doc_string, Fdocumentation, Fdocumentation_property,
Karl Heuer <kwzh@gnu.org>
parents: 9087
diff changeset
180 if (!SYMBOLP (funcar))
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
181 return Fsignal (Qinvalid_function, Fcons (fun, Qnil));
647
529171c8b71c entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 604
diff changeset
182 else if (EQ (funcar, Qkeymap))
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
183 return build_string ("Prefix command (definition is a keymap associating keystrokes with\n\
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
184 subcommands.)");
647
529171c8b71c entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 604
diff changeset
185 else if (EQ (funcar, Qlambda)
529171c8b71c entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 604
diff changeset
186 || EQ (funcar, Qautoload))
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
187 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
188 tem = Fcar (Fcdr (Fcdr (fun)));
9133
48820d57a24c (get_doc_string, Fdocumentation, Fdocumentation_property,
Karl Heuer <kwzh@gnu.org>
parents: 9087
diff changeset
189 if (STRINGP (tem))
570
c5bfe6e87d93 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 485
diff changeset
190 doc = tem;
9958
25a7e3557fd3 (Fdocumentation): Use NATNUMP instead of its expansion.
Karl Heuer <kwzh@gnu.org>
parents: 9304
diff changeset
191 else if (NATNUMP (tem))
570
c5bfe6e87d93 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 485
diff changeset
192 doc = get_doc_string (XFASTINT (tem));
c5bfe6e87d93 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 485
diff changeset
193 else
c5bfe6e87d93 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 485
diff changeset
194 return Qnil;
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195 }
647
529171c8b71c entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 604
diff changeset
196 else if (EQ (funcar, Qmocklisp))
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197 return Qnil;
647
529171c8b71c entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 604
diff changeset
198 else if (EQ (funcar, Qmacro))
570
c5bfe6e87d93 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 485
diff changeset
199 return Fdocumentation (Fcdr (fun), raw);
10002
5b2b7e378772 (Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9958
diff changeset
200 else
5b2b7e378772 (Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9958
diff changeset
201 goto oops;
5b2b7e378772 (Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9958
diff changeset
202 }
5b2b7e378772 (Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9958
diff changeset
203 else
5b2b7e378772 (Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9958
diff changeset
204 {
5b2b7e378772 (Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9958
diff changeset
205 oops:
5b2b7e378772 (Fdocumentation): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9958
diff changeset
206 Fsignal (Qinvalid_function, Fcons (fun, Qnil));
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207 }
570
c5bfe6e87d93 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 485
diff changeset
208
577
53f29271d1b0 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 570
diff changeset
209 if (NILP (raw))
1511
ff88f962a982 * doc.c: #include keyboard.h.
Jim Blandy <jimb@redhat.com>
parents: 1116
diff changeset
210 {
ff88f962a982 * doc.c: #include keyboard.h.
Jim Blandy <jimb@redhat.com>
parents: 1116
diff changeset
211 struct gcpro gcpro1;
ff88f962a982 * doc.c: #include keyboard.h.
Jim Blandy <jimb@redhat.com>
parents: 1116
diff changeset
212
ff88f962a982 * doc.c: #include keyboard.h.
Jim Blandy <jimb@redhat.com>
parents: 1116
diff changeset
213 GCPRO1 (doc);
ff88f962a982 * doc.c: #include keyboard.h.
Jim Blandy <jimb@redhat.com>
parents: 1116
diff changeset
214 doc = Fsubstitute_command_keys (doc);
ff88f962a982 * doc.c: #include keyboard.h.
Jim Blandy <jimb@redhat.com>
parents: 1116
diff changeset
215 UNGCPRO;
ff88f962a982 * doc.c: #include keyboard.h.
Jim Blandy <jimb@redhat.com>
parents: 1116
diff changeset
216 }
570
c5bfe6e87d93 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 485
diff changeset
217 return doc;
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219
5248
27d6275810a7 (Fsubstitute_command_keys): Ignore menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents: 4716
diff changeset
220 DEFUN ("documentation-property", Fdocumentation_property, Sdocumentation_property, 2, 3, 0,
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221 "Return the documentation string that is SYMBOL's PROP property.\n\
570
c5bfe6e87d93 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 485
diff changeset
222 This is like `get', but it can refer to strings stored in the\n\
604
63a8e7b3c547 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 577
diff changeset
223 `etc/DOC' file; and if the value is a string, it is passed through\n\
577
53f29271d1b0 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 570
diff changeset
224 `substitute-command-keys'. A non-nil third argument avoids this\n\
53f29271d1b0 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 570
diff changeset
225 translation.")
570
c5bfe6e87d93 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 485
diff changeset
226 (sym, prop, raw)
c5bfe6e87d93 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 485
diff changeset
227 Lisp_Object sym, prop, raw;
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229 register Lisp_Object tem;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231 tem = Fget (sym, prop);
9133
48820d57a24c (get_doc_string, Fdocumentation, Fdocumentation_property,
Karl Heuer <kwzh@gnu.org>
parents: 9087
diff changeset
232 if (INTEGERP (tem))
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
233 tem = get_doc_string (XINT (tem) > 0 ? XINT (tem) : - XINT (tem));
9133
48820d57a24c (get_doc_string, Fdocumentation, Fdocumentation_property,
Karl Heuer <kwzh@gnu.org>
parents: 9087
diff changeset
234 if (NILP (raw) && STRINGP (tem))
312
adba7439e87c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 297
diff changeset
235 return Fsubstitute_command_keys (tem);
adba7439e87c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 297
diff changeset
236 return tem;
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
237 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
238
1651
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
239 /* 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
240
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
241 static void
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
242 store_function_docstring (fun, offset)
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
243 Lisp_Object fun;
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
244 int offset;
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
245 {
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
246 fun = indirect_function (fun);
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
247
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
248 /* 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
249
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
250 /* Lisp_Subrs have a slot for it. */
9133
48820d57a24c (get_doc_string, Fdocumentation, Fdocumentation_property,
Karl Heuer <kwzh@gnu.org>
parents: 9087
diff changeset
251 if (SUBRP (fun))
1651
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
252 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
253
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
254 /* 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
255 else if (CONSP (fun))
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
256 {
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
257 Lisp_Object tem;
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
258
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
259 tem = XCONS (fun)->car;
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
260 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
261 {
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
262 tem = Fcdr (Fcdr (fun));
9133
48820d57a24c (get_doc_string, Fdocumentation, Fdocumentation_property,
Karl Heuer <kwzh@gnu.org>
parents: 9087
diff changeset
263 if (CONSP (tem) && INTEGERP (XCONS (tem)->car))
9304
1fbc46670cb0 (store_function_docstring): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents: 9133
diff changeset
264 XSETFASTINT (XCONS (tem)->car, offset);
1651
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
265 }
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
266 else if (EQ (tem, Qmacro))
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
267 store_function_docstring (XCONS (fun)->cdr, offset);
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
268 }
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
269
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
270 /* Bytecode objects sometimes have slots for it. */
9133
48820d57a24c (get_doc_string, Fdocumentation, Fdocumentation_property,
Karl Heuer <kwzh@gnu.org>
parents: 9087
diff changeset
271 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
272 {
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
273 /* 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
274 docstring, since we've found a docstring for it. */
8552
1353c008cf8e (store_function_docstring): Do nothing for bytecode object
Richard M. Stallman <rms@gnu.org>
parents: 7307
diff changeset
275 if (XVECTOR (fun)->size > COMPILED_DOC_STRING)
9304
1fbc46670cb0 (store_function_docstring): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents: 9133
diff changeset
276 XSETFASTINT (XVECTOR (fun)->contents[COMPILED_DOC_STRING], offset);
1651
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
277 }
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
278 }
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
279
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
280
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
281 DEFUN ("Snarf-documentation", Fsnarf_documentation, Ssnarf_documentation,
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
282 1, 1, 0,
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
283 "Used during Emacs initialization, before dumping runnable Emacs,\n\
604
63a8e7b3c547 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 577
diff changeset
284 to find pointers to doc strings stored in `etc/DOC...' and\n\
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
285 record them in function definitions.\n\
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286 One arg, FILENAME, a string which does not include a directory.\n\
604
63a8e7b3c547 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 577
diff changeset
287 The file is found in `../etc' now; found in the `data-directory'\n\
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288 when doc strings are referred to later in the dumped Emacs.")
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289 (filename)
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
290 Lisp_Object filename;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
291 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
292 int fd;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
293 char buf[1024 + 1];
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
294 register int filled;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
295 register int pos;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
296 register char *p, *end;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
297 Lisp_Object sym, fun, tem;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
298 char *name;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
299 extern char *index ();
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
300
1116
6d0d442e2ada * doc.c (Fsnarf_documentation): Signal an error if this is
Jim Blandy <jimb@redhat.com>
parents: 961
diff changeset
301 #ifndef CANNOT_DUMP
6d0d442e2ada * doc.c (Fsnarf_documentation): Signal an error if this is
Jim Blandy <jimb@redhat.com>
parents: 961
diff changeset
302 if (NILP (Vpurify_flag))
6d0d442e2ada * doc.c (Fsnarf_documentation): Signal an error if this is
Jim Blandy <jimb@redhat.com>
parents: 961
diff changeset
303 error ("Snarf-documentation can only be called in an undumped Emacs");
6d0d442e2ada * doc.c (Fsnarf_documentation): Signal an error if this is
Jim Blandy <jimb@redhat.com>
parents: 961
diff changeset
304 #endif
6d0d442e2ada * doc.c (Fsnarf_documentation): Signal an error if this is
Jim Blandy <jimb@redhat.com>
parents: 961
diff changeset
305
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
306 CHECK_STRING (filename, 0);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
307
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
308 #ifndef CANNOT_DUMP
463
ffdbf3445088 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 312
diff changeset
309 name = (char *) alloca (XSTRING (filename)->size + 14);
604
63a8e7b3c547 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 577
diff changeset
310 strcpy (name, "../etc/");
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
311 #else /* CANNOT_DUMP */
6030
8b3f54fb451f (get_doc_string, Snarf_documentation): Use new variable doc_directory.
Karl Heuer <kwzh@gnu.org>
parents: 5784
diff changeset
312 CHECK_STRING (Vdoc_directory, 0);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
313 name = (char *) alloca (XSTRING (filename)->size +
6030
8b3f54fb451f (get_doc_string, Snarf_documentation): Use new variable doc_directory.
Karl Heuer <kwzh@gnu.org>
parents: 5784
diff changeset
314 XSTRING (Vdoc_directory)->size + 1);
8b3f54fb451f (get_doc_string, Snarf_documentation): Use new variable doc_directory.
Karl Heuer <kwzh@gnu.org>
parents: 5784
diff changeset
315 strcpy (name, XSTRING (Vdoc_directory)->data);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
316 #endif /* CANNOT_DUMP */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
317 strcat (name, XSTRING (filename)->data); /*** Add this line ***/
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
318 #ifdef VMS
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
319 #ifndef VMS4_4
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
320 /* For VMS versions with limited file name syntax,
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
321 convert the name to something VMS will allow. */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
322 p = name;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
323 while (*p)
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
324 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
325 if (*p == '-')
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
326 *p = '_';
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
327 p++;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
328 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
329 #endif /* not VMS4_4 */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330 #ifdef VMS4_4
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
331 strcpy (name, sys_translate_unix (name));
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
332 #endif /* VMS4_4 */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
333 #endif /* VMS */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
334
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
335 fd = open (name, O_RDONLY, 0);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
336 if (fd < 0)
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
337 report_file_error ("Opening doc string file",
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
338 Fcons (build_string (name), Qnil));
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
339 Vdoc_file_name = filename;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
340 filled = 0;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
341 pos = 0;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
342 while (1)
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
343 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
344 if (filled < 512)
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
345 filled += read (fd, &buf[filled], sizeof buf - 1 - filled);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
346 if (!filled)
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
347 break;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
348
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
349 buf[filled] = 0;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
350 p = buf;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
351 end = buf + (filled < 512 ? filled : filled - 128);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
352 while (p != end && *p != '\037') p++;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
353 /* p points to ^_Ffunctionname\n or ^_Vvarname\n. */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
354 if (p != end)
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
355 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
356 end = index (p, '\n');
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
357 sym = oblookup (Vobarray, p + 2, end - p - 2);
9133
48820d57a24c (get_doc_string, Fdocumentation, Fdocumentation_property,
Karl Heuer <kwzh@gnu.org>
parents: 9087
diff changeset
358 if (SYMBOLP (sym))
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
359 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
360 /* Attach a docstring to a variable? */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
361 if (p[1] == 'V')
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
362 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
363 /* Install file-position as variable-documentation property
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
364 and make it negative for a user-variable
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
365 (doc starts with a `*'). */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
366 Fput (sym, Qvariable_documentation,
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
367 make_number ((pos + end + 1 - buf)
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
368 * (end[1] == '*' ? -1 : 1)));
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
369 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
370
1651
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
371 /* Attach a docstring to a function? */
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
372 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
373 store_function_docstring (sym, pos + end + 1 - buf);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
374
1651
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
375 else
ef09501a0a9b * doc.c (store_function_docstring): New function, made from part
Jim Blandy <jimb@redhat.com>
parents: 1511
diff changeset
376 error ("DOC file invalid at position %d", pos);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
377 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
378 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
379 pos += end - buf;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
380 filled -= end - buf;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
381 bcopy (end, buf, filled);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
382 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
383 close (fd);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
384 return Qnil;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
385 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
386
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
387 DEFUN ("substitute-command-keys", Fsubstitute_command_keys,
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
388 Ssubstitute_command_keys, 1, 1, 0,
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
389 "Substitute key descriptions for command names in STRING.\n\
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
390 Return a new string which is STRING with substrings of the form \\=\\[COMMAND]\n\
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
391 replaced by either: a keystroke sequence that will invoke COMMAND,\n\
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
392 or \"M-x COMMAND\" if COMMAND is not on any keys.\n\
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
393 Substrings of the form \\=\\{MAPVAR} are replaced by summaries\n\
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
394 \(made by describe-bindings) of the value of MAPVAR, taken as a keymap.\n\
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
395 Substrings of the form \\=\\<MAPVAR> specify to use the value of MAPVAR\n\
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
396 as the keymap for future \\=\\[COMMAND] substrings.\n\
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
397 \\=\\= quotes the following character and is discarded;\n\
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
398 thus, \\=\\=\\=\\= puts \\=\\= into the output, and \\=\\=\\=\\[ puts \\=\\[ into the output.")
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
399 (str)
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
400 Lisp_Object str;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
401 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
402 unsigned char *buf;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
403 int changed = 0;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
404 register unsigned char *strp;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
405 register unsigned char *bufp;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
406 int idx;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
407 int bsize;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
408 unsigned char *new;
1511
ff88f962a982 * doc.c: #include keyboard.h.
Jim Blandy <jimb@redhat.com>
parents: 1116
diff changeset
409 Lisp_Object tem;
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
410 Lisp_Object keymap;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
411 unsigned char *start;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
412 int length;
1511
ff88f962a982 * doc.c: #include keyboard.h.
Jim Blandy <jimb@redhat.com>
parents: 1116
diff changeset
413 Lisp_Object name;
ff88f962a982 * doc.c: #include keyboard.h.
Jim Blandy <jimb@redhat.com>
parents: 1116
diff changeset
414 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
415
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 463
diff changeset
416 if (NILP (str))
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
417 return Qnil;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
418
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
419 CHECK_STRING (str, 0);
1511
ff88f962a982 * doc.c: #include keyboard.h.
Jim Blandy <jimb@redhat.com>
parents: 1116
diff changeset
420 tem = Qnil;
ff88f962a982 * doc.c: #include keyboard.h.
Jim Blandy <jimb@redhat.com>
parents: 1116
diff changeset
421 keymap = Qnil;
ff88f962a982 * doc.c: #include keyboard.h.
Jim Blandy <jimb@redhat.com>
parents: 1116
diff changeset
422 name = Qnil;
ff88f962a982 * doc.c: #include keyboard.h.
Jim Blandy <jimb@redhat.com>
parents: 1116
diff changeset
423 GCPRO4 (str, tem, keymap, name);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
424
5784
9c3be8e0d2ef (Fsubstitute_command_keys): Pass keymap as that arg
Richard M. Stallman <rms@gnu.org>
parents: 5550
diff changeset
425 /* 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
426 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
427 global map). If non-nil, it might come from Voverriding_local_map,
9c3be8e0d2ef (Fsubstitute_command_keys): Pass keymap as that arg
Richard M. Stallman <rms@gnu.org>
parents: 5550
diff changeset
428 or from a \\<mapname> construct in STR itself.. */
9c3be8e0d2ef (Fsubstitute_command_keys): Pass keymap as that arg
Richard M. Stallman <rms@gnu.org>
parents: 5550
diff changeset
429 keymap = Voverriding_local_map;
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
430
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
431 bsize = XSTRING (str)->size;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
432 bufp = buf = (unsigned char *) xmalloc (bsize);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
433
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
434 strp = (unsigned char *) XSTRING (str)->data;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
435 while (strp < (unsigned char *) XSTRING (str)->data + XSTRING (str)->size)
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
436 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
437 if (strp[0] == '\\' && strp[1] == '=')
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
438 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
439 /* \= quotes the next character;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
440 thus, to put in \[ without its special meaning, use \=\[. */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
441 changed = 1;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
442 *bufp++ = strp[2];
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
443 strp += 3;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
444 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
445 else if (strp[0] == '\\' && strp[1] == '[')
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
446 {
5248
27d6275810a7 (Fsubstitute_command_keys): Ignore menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents: 4716
diff changeset
447 Lisp_Object firstkey;
27d6275810a7 (Fsubstitute_command_keys): Ignore menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents: 4716
diff changeset
448
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
449 changed = 1;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
450 strp += 2; /* skip \[ */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
451 start = strp;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
452
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
453 while ((strp - (unsigned char *) XSTRING (str)->data
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
454 < XSTRING (str)->size)
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
455 && *strp != ']')
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
456 strp++;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
457 length = strp - start;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
458 strp++; /* skip ] */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
459
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
460 /* Save STRP in IDX. */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
461 idx = strp - (unsigned char *) XSTRING (str)->data;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
462 tem = Fintern (make_string (start, length), Qnil);
5784
9c3be8e0d2ef (Fsubstitute_command_keys): Pass keymap as that arg
Richard M. Stallman <rms@gnu.org>
parents: 5550
diff changeset
463 tem = Fwhere_is_internal (tem, keymap, Qt, Qnil);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
464
5248
27d6275810a7 (Fsubstitute_command_keys): Ignore menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents: 4716
diff changeset
465 /* Disregard menu bar bindings; it is positively annoying to
27d6275810a7 (Fsubstitute_command_keys): Ignore menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents: 4716
diff changeset
466 mention them when there's no menu bar, and it isn't terribly
27d6275810a7 (Fsubstitute_command_keys): Ignore menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents: 4716
diff changeset
467 useful even when there is a menu bar. */
5377
7a8463c07d8f (Fsubstitute_command_keys): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 5248
diff changeset
468 if (!NILP (tem))
7a8463c07d8f (Fsubstitute_command_keys): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 5248
diff changeset
469 {
7a8463c07d8f (Fsubstitute_command_keys): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 5248
diff changeset
470 firstkey = Faref (tem, make_number (0));
7a8463c07d8f (Fsubstitute_command_keys): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 5248
diff changeset
471 if (EQ (firstkey, Qmenu_bar))
7a8463c07d8f (Fsubstitute_command_keys): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 5248
diff changeset
472 tem = Qnil;
7a8463c07d8f (Fsubstitute_command_keys): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 5248
diff changeset
473 }
5248
27d6275810a7 (Fsubstitute_command_keys): Ignore menu bar bindings.
Richard M. Stallman <rms@gnu.org>
parents: 4716
diff changeset
474
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 463
diff changeset
475 if (NILP (tem)) /* but not on any keys */
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
476 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
477 new = (unsigned char *) xrealloc (buf, bsize += 4);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
478 bufp += new - buf;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
479 buf = new;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
480 bcopy ("M-x ", bufp, 4);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
481 bufp += 4;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
482 goto subst;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
483 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
484 else
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
485 { /* function is on a key */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
486 tem = Fkey_description (tem);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
487 goto subst_string;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
488 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
489 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
490 /* \{foo} is replaced with a summary of the keymap (symbol-value foo).
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
491 \<foo> just sets the keymap used for \[cmd]. */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
492 else if (strp[0] == '\\' && (strp[1] == '{' || strp[1] == '<'))
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
493 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
494 struct buffer *oldbuf;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
495
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
496 changed = 1;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
497 strp += 2; /* skip \{ or \< */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
498 start = strp;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
499
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
500 while ((strp - (unsigned char *) XSTRING (str)->data
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
501 < XSTRING (str)->size)
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
502 && *strp != '}' && *strp != '>')
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
503 strp++;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
504 length = strp - start;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
505 strp++; /* skip } or > */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
506
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
507 /* Save STRP in IDX. */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
508 idx = strp - (unsigned char *) XSTRING (str)->data;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
509
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
510 /* Get the value of the keymap in TEM, or nil if undefined.
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
511 Do this while still in the user's current buffer
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
512 in case it is a local variable. */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
513 name = Fintern (make_string (start, length), Qnil);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
514 tem = Fboundp (name);
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 463
diff changeset
515 if (! NILP (tem))
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
516 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
517 tem = Fsymbol_value (name);
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 463
diff changeset
518 if (! NILP (tem))
1511
ff88f962a982 * doc.c: #include keyboard.h.
Jim Blandy <jimb@redhat.com>
parents: 1116
diff changeset
519 tem = get_keymap_1 (tem, 0, 1);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
520 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
521
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
522 /* Now switch to a temp buffer. */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
523 oldbuf = current_buffer;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
524 set_buffer_internal (XBUFFER (Vprin1_to_string_buffer));
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
525
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 463
diff changeset
526 if (NILP (tem))
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
527 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
528 name = Fsymbol_name (name);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
529 insert_string ("\nUses keymap \"");
4716
4382ad05411e (Fsubstitute_command_keys): Pass new arg to insert_from_string.
Richard M. Stallman <rms@gnu.org>
parents: 4696
diff changeset
530 insert_from_string (name, 0, XSTRING (name)->size, 1);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
531 insert_string ("\", which is not currently defined.\n");
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
532 if (start[-1] == '<') keymap = Qnil;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
533 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
534 else if (start[-1] == '<')
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
535 keymap = tem;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
536 else
5550
9e8bbed9a9b6 (Fsubstitute_command_keys): Pass new arg to describe_map_tree.
Richard M. Stallman <rms@gnu.org>
parents: 5377
diff changeset
537 describe_map_tree (tem, 1, Qnil, Qnil, 0, 1);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
538 tem = Fbuffer_string ();
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
539 Ferase_buffer ();
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
540 set_buffer_internal (oldbuf);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
541
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
542 subst_string:
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
543 start = XSTRING (tem)->data;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
544 length = XSTRING (tem)->size;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
545 subst:
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
546 new = (unsigned char *) xrealloc (buf, bsize += length);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
547 bufp += new - buf;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
548 buf = new;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
549 bcopy (start, bufp, length);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
550 bufp += length;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
551 /* Check STR again in case gc relocated it. */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
552 strp = (unsigned char *) XSTRING (str)->data + idx;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
553 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
554 else /* just copy other chars */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
555 *bufp++ = *strp++;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
556 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
557
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
558 if (changed) /* don't bother if nothing substituted */
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
559 tem = make_string (buf, bufp - buf);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
560 else
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
561 tem = str;
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 1651
diff changeset
562 xfree (buf);
1511
ff88f962a982 * doc.c: #include keyboard.h.
Jim Blandy <jimb@redhat.com>
parents: 1116
diff changeset
563 RETURN_UNGCPRO (tem);
297
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
564 }
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
565
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
566 syms_of_doc ()
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
567 {
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
568 DEFVAR_LISP ("internal-doc-file-name", &Vdoc_file_name,
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
569 "Name of file containing documentation strings of built-in symbols.");
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
570 Vdoc_file_name = Qnil;
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
571
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
572 defsubr (&Sdocumentation);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
573 defsubr (&Sdocumentation_property);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
574 defsubr (&Ssnarf_documentation);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
575 defsubr (&Ssubstitute_command_keys);
785f88514b16 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
576 }