Mercurial > emacs
annotate src/lread.c @ 2549:5fbd6bdf6b6a
(tc-dissociate): Renamed from tc-kill-association.
Move binding to C-x 6 d.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 17 Apr 1993 04:35:15 +0000 |
parents | d666732c5f41 |
children | ba685dcc3750 |
rev | line source |
---|---|
341 | 1 /* Lisp parsing and input streams. |
692 | 2 Copyright (C) 1985, 1986, 1987, 1988, 1989, |
3 1992 Free Software Foundation, Inc. | |
341 | 4 |
5 This file is part of GNU Emacs. | |
6 | |
7 GNU Emacs is free software; you can redistribute it and/or modify | |
8 it under the terms of the GNU General Public License as published by | |
617 | 9 the Free Software Foundation; either version 2, or (at your option) |
341 | 10 any later version. |
11 | |
12 GNU Emacs is distributed in the hope that it will be useful, | |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 GNU General Public License for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with GNU Emacs; see the file COPYING. If not, write to | |
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
20 | |
21 | |
22 #include <stdio.h> | |
23 #include <sys/types.h> | |
24 #include <sys/stat.h> | |
25 #include <sys/file.h> | |
796 | 26 #include <ctype.h> |
341 | 27 #undef NULL |
28 #include "config.h" | |
29 #include "lisp.h" | |
30 | |
31 #ifndef standalone | |
32 #include "buffer.h" | |
33 #include "paths.h" | |
34 #include "commands.h" | |
1591
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
35 #include "keyboard.h" |
2044
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
36 #include "termhooks.h" |
341 | 37 #endif |
38 | |
39 #ifdef lint | |
40 #include <sys/inode.h> | |
41 #endif /* lint */ | |
42 | |
43 #ifndef X_OK | |
44 #define X_OK 01 | |
45 #endif | |
46 | |
47 #ifdef LISP_FLOAT_TYPE | |
48 #include <math.h> | |
49 #endif /* LISP_FLOAT_TYPE */ | |
50 | |
51 Lisp_Object Qread_char, Qget_file_char, Qstandard_input; | |
52 Lisp_Object Qvariable_documentation, Vvalues, Vstandard_input, Vafter_load_alist; | |
2044
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
53 Lisp_Object Qascii_character; |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
54 |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
55 extern Lisp_Object Qevent_symbol_element_mask; |
341 | 56 |
57 /* non-zero if inside `load' */ | |
58 int load_in_progress; | |
59 | |
60 /* Search path for files to be loaded. */ | |
61 Lisp_Object Vload_path; | |
62 | |
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
63 /* This is the user-visible association list that maps features to |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
64 lists of defs in their load files. */ |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
65 Lisp_Object Vload_history; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
66 |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
67 /* This is useud to build the load history. */ |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
68 Lisp_Object Vcurrent_load_list; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
69 |
341 | 70 /* File for get_file_char to read from. Use by load */ |
71 static FILE *instream; | |
72 | |
73 /* When nonzero, read conses in pure space */ | |
74 static int read_pure; | |
75 | |
76 /* For use within read-from-string (this reader is non-reentrant!!) */ | |
77 static int read_from_string_index; | |
78 static int read_from_string_limit; | |
79 | |
80 /* Handle unreading and rereading of characters. | |
81 Write READCHAR to read a character, | |
82 UNREAD(c) to unread c to be read again. */ | |
83 | |
84 #define READCHAR readchar (readcharfun) | |
85 #define UNREAD(c) unreadchar (readcharfun, c) | |
86 | |
87 static int | |
88 readchar (readcharfun) | |
89 Lisp_Object readcharfun; | |
90 { | |
91 Lisp_Object tem; | |
92 register struct buffer *inbuffer; | |
93 register int c, mpos; | |
94 | |
95 if (XTYPE (readcharfun) == Lisp_Buffer) | |
96 { | |
97 inbuffer = XBUFFER (readcharfun); | |
98 | |
99 if (BUF_PT (inbuffer) >= BUF_ZV (inbuffer)) | |
100 return -1; | |
101 c = *(unsigned char *) BUF_CHAR_ADDRESS (inbuffer, BUF_PT (inbuffer)); | |
102 SET_BUF_PT (inbuffer, BUF_PT (inbuffer) + 1); | |
103 | |
104 return c; | |
105 } | |
106 if (XTYPE (readcharfun) == Lisp_Marker) | |
107 { | |
108 inbuffer = XMARKER (readcharfun)->buffer; | |
109 | |
110 mpos = marker_position (readcharfun); | |
111 | |
112 if (mpos > BUF_ZV (inbuffer) - 1) | |
113 return -1; | |
114 c = *(unsigned char *) BUF_CHAR_ADDRESS (inbuffer, mpos); | |
115 if (mpos != BUF_GPT (inbuffer)) | |
116 XMARKER (readcharfun)->bufpos++; | |
117 else | |
118 Fset_marker (readcharfun, make_number (mpos + 1), | |
119 Fmarker_buffer (readcharfun)); | |
120 return c; | |
121 } | |
122 if (EQ (readcharfun, Qget_file_char)) | |
123 return getc (instream); | |
124 | |
125 if (XTYPE (readcharfun) == Lisp_String) | |
126 { | |
127 register int c; | |
128 /* This used to be return of a conditional expression, | |
129 but that truncated -1 to a char on VMS. */ | |
130 if (read_from_string_index < read_from_string_limit) | |
131 c = XSTRING (readcharfun)->data[read_from_string_index++]; | |
132 else | |
133 c = -1; | |
134 return c; | |
135 } | |
136 | |
137 tem = call0 (readcharfun); | |
138 | |
485 | 139 if (NILP (tem)) |
341 | 140 return -1; |
141 return XINT (tem); | |
142 } | |
143 | |
144 /* Unread the character C in the way appropriate for the stream READCHARFUN. | |
145 If the stream is a user function, call it with the char as argument. */ | |
146 | |
147 static void | |
148 unreadchar (readcharfun, c) | |
149 Lisp_Object readcharfun; | |
150 int c; | |
151 { | |
152 if (XTYPE (readcharfun) == Lisp_Buffer) | |
153 { | |
154 if (XBUFFER (readcharfun) == current_buffer) | |
155 SET_PT (point - 1); | |
156 else | |
157 SET_BUF_PT (XBUFFER (readcharfun), BUF_PT (XBUFFER (readcharfun)) - 1); | |
158 } | |
159 else if (XTYPE (readcharfun) == Lisp_Marker) | |
160 XMARKER (readcharfun)->bufpos--; | |
161 else if (XTYPE (readcharfun) == Lisp_String) | |
162 read_from_string_index--; | |
163 else if (EQ (readcharfun, Qget_file_char)) | |
164 ungetc (c, instream); | |
165 else | |
166 call1 (readcharfun, make_number (c)); | |
167 } | |
168 | |
169 static Lisp_Object read0 (), read1 (), read_list (), read_vector (); | |
170 | |
171 /* get a character from the tty */ | |
172 | |
1519
5d0837ebee9c
* lread.c (read_char): Add an extern declaration for this,
Jim Blandy <jimb@redhat.com>
parents:
1092
diff
changeset
|
173 extern Lisp_Object read_char (); |
5d0837ebee9c
* lread.c (read_char): Add an extern declaration for this,
Jim Blandy <jimb@redhat.com>
parents:
1092
diff
changeset
|
174 |
341 | 175 DEFUN ("read-char", Fread_char, Sread_char, 0, 0, 0, |
176 "Read a character from the command input (keyboard or macro).\n\ | |
851 | 177 It is returned as a number.\n\ |
178 If the user generates an event which is not a character (i.e. a mouse\n\ | |
1591
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
179 click or function key event), `read-char' signals an error. As an\n\ |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
180 exception, switch-frame events are put off until non-ASCII events can\n\ |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
181 be read.\n\ |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
182 If you want to read non-character events, or ignore them, call\n\ |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
183 `read-event' or `read-char-exclusive' instead.") |
341 | 184 () |
185 { | |
186 register Lisp_Object val; | |
187 | |
188 #ifndef standalone | |
1591
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
189 { |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
190 register Lisp_Object delayed_switch_frame; |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
191 |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
192 delayed_switch_frame = Qnil; |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
193 |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
194 for (;;) |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
195 { |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
196 val = read_char (0, 0, 0, Qnil, 0); |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
197 |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
198 /* switch-frame events are put off until after the next ASCII |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
199 character. This is better than signalling an error just |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
200 because the last characters were typed to a separate |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
201 minibuffer frame, for example. Eventually, some code which |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
202 can deal with switch-frame events will read it and process |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
203 it. */ |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
204 if (EVENT_HAS_PARAMETERS (val) |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
205 && EQ (EVENT_HEAD (val), Qswitch_frame)) |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
206 delayed_switch_frame = val; |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
207 else |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
208 break; |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
209 } |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
210 |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
211 if (! NILP (delayed_switch_frame)) |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
212 unread_switch_frame = delayed_switch_frame; |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
213 |
2044
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
214 /* Only ASCII characters are acceptable. |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
215 But convert certain symbols to their ASCII equivalents. */ |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
216 if (XTYPE (val) == Lisp_Symbol) |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
217 { |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
218 Lisp_Object tem, tem1, tem2; |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
219 tem = Fget (val, Qevent_symbol_element_mask); |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
220 if (!NILP (tem)) |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
221 { |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
222 tem1 = Fget (Fcar (tem), Qascii_character); |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
223 /* Merge this symbol's modifier bits |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
224 with the ASCII equivalent of its basic code. */ |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
225 if (!NILP (tem1)) |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
226 XFASTINT (val) = XINT (tem1) | XINT (Fcar (Fcdr (tem))); |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
227 } |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
228 } |
1591
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
229 if (XTYPE (val) != Lisp_Int) |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
230 { |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1758
diff
changeset
|
231 unread_command_events = Fcons (val, Qnil); |
2044
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
232 error ("Non-character input-event"); |
1591
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
233 } |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
234 } |
341 | 235 #else |
236 val = getchar (); | |
237 #endif | |
238 | |
239 return val; | |
240 } | |
241 | |
242 DEFUN ("read-event", Fread_event, Sread_event, 0, 0, 0, | |
243 "Read an event object from the input stream.") | |
244 () | |
245 { | |
246 register Lisp_Object val; | |
247 | |
1092
c2259db856ee
(Fread_char): Pass new args to read_char.
Richard M. Stallman <rms@gnu.org>
parents:
1009
diff
changeset
|
248 val = read_char (0, 0, 0, Qnil, 0); |
341 | 249 return val; |
250 } | |
251 | |
252 DEFUN ("read-char-exclusive", Fread_char_exclusive, Sread_char_exclusive, 0, 0, 0, | |
253 "Read a character from the command input (keyboard or macro).\n\ | |
254 It is returned as a number. Non character events are ignored.") | |
255 () | |
256 { | |
257 register Lisp_Object val; | |
258 | |
259 #ifndef standalone | |
1591
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
260 { |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
261 Lisp_Object delayed_switch_frame; |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
262 |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
263 delayed_switch_frame = Qnil; |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
264 |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
265 for (;;) |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
266 { |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
267 val = read_char (0, 0, 0, Qnil, 0); |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
268 |
2044
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
269 /* Convert certain symbols (for keys like RET, DEL, TAB) |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
270 to ASCII integers. */ |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
271 if (XTYPE (val) == Lisp_Symbol) |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
272 { |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
273 Lisp_Object tem, tem1; |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
274 tem = Fget (val, Qevent_symbol_element_mask); |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
275 if (!NILP (tem)) |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
276 { |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
277 tem1 = Fget (Fcar (tem), Qascii_character); |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
278 /* Merge this symbol's modifier bits |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
279 with the ASCII equivalent of its basic code. */ |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
280 if (!NILP (tem1)) |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
281 XFASTINT (val) = XINT (tem1) | XINT (Fcar (Fcdr (tem))); |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
282 } |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
283 } |
1591
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
284 if (XTYPE (val) == Lisp_Int) |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
285 break; |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
286 |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
287 /* switch-frame events are put off until after the next ASCII |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
288 character. This is better than signalling an error just |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
289 because the last characters were typed to a separate |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
290 minibuffer frame, for example. Eventually, some code which |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
291 can deal with switch-frame events will read it and process |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
292 it. */ |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
293 else if (EVENT_HAS_PARAMETERS (val) |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
294 && EQ (EVENT_HEAD (val), Qswitch_frame)) |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
295 delayed_switch_frame = val; |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
296 |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
297 /* Drop everything else. */ |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
298 } |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
299 |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
300 if (! NILP (delayed_switch_frame)) |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
301 unread_switch_frame = delayed_switch_frame; |
765cb54fa9af
* lread.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1519
diff
changeset
|
302 } |
341 | 303 #else |
304 val = getchar (); | |
305 #endif | |
306 | |
307 return val; | |
308 } | |
309 | |
310 DEFUN ("get-file-char", Fget_file_char, Sget_file_char, 0, 0, 0, | |
311 "Don't use this yourself.") | |
312 () | |
313 { | |
314 register Lisp_Object val; | |
315 XSET (val, Lisp_Int, getc (instream)); | |
316 return val; | |
317 } | |
318 | |
319 static void readevalloop (); | |
320 static Lisp_Object load_unwind (); | |
321 | |
322 DEFUN ("load", Fload, Sload, 1, 4, 0, | |
323 "Execute a file of Lisp code named FILE.\n\ | |
324 First try FILE with `.elc' appended, then try with `.el',\n\ | |
325 then try FILE unmodified.\n\ | |
326 This function searches the directories in `load-path'.\n\ | |
327 If optional second arg NOERROR is non-nil,\n\ | |
328 report no error if FILE doesn't exist.\n\ | |
329 Print messages at start and end of loading unless\n\ | |
330 optional third arg NOMESSAGE is non-nil.\n\ | |
331 If optional fourth arg NOSUFFIX is non-nil, don't try adding\n\ | |
332 suffixes `.elc' or `.el' to the specified name FILE.\n\ | |
333 Return t if file exists.") | |
334 (str, noerror, nomessage, nosuffix) | |
335 Lisp_Object str, noerror, nomessage, nosuffix; | |
336 { | |
337 register FILE *stream; | |
338 register int fd = -1; | |
339 register Lisp_Object lispstream; | |
340 register FILE **ptr; | |
341 int count = specpdl_ptr - specpdl; | |
342 Lisp_Object temp; | |
343 struct gcpro gcpro1; | |
344 Lisp_Object found; | |
1758
12c730b89ac8
(Fload): If warn that .elc file is older,
Richard M. Stallman <rms@gnu.org>
parents:
1591
diff
changeset
|
345 /* 1 means inhibit the message at the beginning. */ |
12c730b89ac8
(Fload): If warn that .elc file is older,
Richard M. Stallman <rms@gnu.org>
parents:
1591
diff
changeset
|
346 int nomessage1 = 0; |
341 | 347 |
348 CHECK_STRING (str, 0); | |
349 str = Fsubstitute_in_file_name (str); | |
350 | |
351 /* Avoid weird lossage with null string as arg, | |
352 since it would try to load a directory as a Lisp file */ | |
353 if (XSTRING (str)->size > 0) | |
354 { | |
485 | 355 fd = openp (Vload_path, str, !NILP (nosuffix) ? "" : ".elc:.el:", |
341 | 356 &found, 0); |
357 } | |
358 | |
359 if (fd < 0) | |
360 { | |
485 | 361 if (NILP (noerror)) |
341 | 362 while (1) |
363 Fsignal (Qfile_error, Fcons (build_string ("Cannot open load file"), | |
364 Fcons (str, Qnil))); | |
365 else | |
366 return Qnil; | |
367 } | |
368 | |
369 if (!bcmp (&(XSTRING (found)->data[XSTRING (found)->size - 4]), | |
370 ".elc", 4)) | |
371 { | |
372 struct stat s1, s2; | |
373 int result; | |
374 | |
375 stat (XSTRING (found)->data, &s1); | |
376 XSTRING (found)->data[XSTRING (found)->size - 1] = 0; | |
377 result = stat (XSTRING (found)->data, &s2); | |
378 if (result >= 0 && (unsigned) s1.st_mtime < (unsigned) s2.st_mtime) | |
1758
12c730b89ac8
(Fload): If warn that .elc file is older,
Richard M. Stallman <rms@gnu.org>
parents:
1591
diff
changeset
|
379 { |
12c730b89ac8
(Fload): If warn that .elc file is older,
Richard M. Stallman <rms@gnu.org>
parents:
1591
diff
changeset
|
380 message ("Source file `%s' newer than byte-compiled file", |
12c730b89ac8
(Fload): If warn that .elc file is older,
Richard M. Stallman <rms@gnu.org>
parents:
1591
diff
changeset
|
381 XSTRING (found)->data); |
12c730b89ac8
(Fload): If warn that .elc file is older,
Richard M. Stallman <rms@gnu.org>
parents:
1591
diff
changeset
|
382 /* Don't immediately overwrite this message. */ |
12c730b89ac8
(Fload): If warn that .elc file is older,
Richard M. Stallman <rms@gnu.org>
parents:
1591
diff
changeset
|
383 if (!noninteractive) |
12c730b89ac8
(Fload): If warn that .elc file is older,
Richard M. Stallman <rms@gnu.org>
parents:
1591
diff
changeset
|
384 nomessage1 = 1; |
12c730b89ac8
(Fload): If warn that .elc file is older,
Richard M. Stallman <rms@gnu.org>
parents:
1591
diff
changeset
|
385 } |
341 | 386 XSTRING (found)->data[XSTRING (found)->size - 1] = 'c'; |
387 } | |
388 | |
389 stream = fdopen (fd, "r"); | |
390 if (stream == 0) | |
391 { | |
392 close (fd); | |
393 error ("Failure to create stdio stream for %s", XSTRING (str)->data); | |
394 } | |
395 | |
1758
12c730b89ac8
(Fload): If warn that .elc file is older,
Richard M. Stallman <rms@gnu.org>
parents:
1591
diff
changeset
|
396 if (NILP (nomessage) && !nomessage1) |
341 | 397 message ("Loading %s...", XSTRING (str)->data); |
398 | |
399 GCPRO1 (str); | |
400 /* We may not be able to store STREAM itself as a Lisp_Object pointer | |
401 since that is guaranteed to work only for data that has been malloc'd. | |
402 So malloc a full-size pointer, and record the address of that pointer. */ | |
403 ptr = (FILE **) xmalloc (sizeof (FILE *)); | |
404 *ptr = stream; | |
405 XSET (lispstream, Lisp_Internal_Stream, (int) ptr); | |
406 record_unwind_protect (load_unwind, lispstream); | |
407 load_in_progress++; | |
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
408 readevalloop (Qget_file_char, stream, str, Feval, 0); |
341 | 409 unbind_to (count, Qnil); |
410 | |
411 /* Run any load-hooks for this file. */ | |
412 temp = Fassoc (str, Vafter_load_alist); | |
485 | 413 if (!NILP (temp)) |
341 | 414 Fprogn (Fcdr (temp)); |
415 UNGCPRO; | |
416 | |
485 | 417 if (!noninteractive && NILP (nomessage)) |
341 | 418 message ("Loading %s...done", XSTRING (str)->data); |
419 return Qt; | |
420 } | |
421 | |
422 static Lisp_Object | |
423 load_unwind (stream) /* used as unwind-protect function in load */ | |
424 Lisp_Object stream; | |
425 { | |
426 fclose (*(FILE **) XSTRING (stream)); | |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2044
diff
changeset
|
427 xfree (XPNTR (stream)); |
341 | 428 if (--load_in_progress < 0) load_in_progress = 0; |
429 return Qnil; | |
430 } | |
431 | |
432 | |
433 static int | |
434 complete_filename_p (pathname) | |
435 Lisp_Object pathname; | |
436 { | |
437 register unsigned char *s = XSTRING (pathname)->data; | |
438 return (*s == '/' | |
439 #ifdef ALTOS | |
440 || *s == '@' | |
441 #endif | |
442 #ifdef VMS | |
443 || index (s, ':') | |
444 #endif /* VMS */ | |
445 ); | |
446 } | |
447 | |
448 /* Search for a file whose name is STR, looking in directories | |
449 in the Lisp list PATH, and trying suffixes from SUFFIX. | |
450 SUFFIX is a string containing possible suffixes separated by colons. | |
451 On success, returns a file descriptor. On failure, returns -1. | |
452 | |
453 EXEC_ONLY nonzero means don't open the files, | |
454 just look for one that is executable. In this case, | |
455 returns 1 on success. | |
456 | |
457 If STOREPTR is nonzero, it points to a slot where the name of | |
458 the file actually found should be stored as a Lisp string. | |
459 Nil is stored there on failure. */ | |
460 | |
461 int | |
462 openp (path, str, suffix, storeptr, exec_only) | |
463 Lisp_Object path, str; | |
464 char *suffix; | |
465 Lisp_Object *storeptr; | |
466 int exec_only; | |
467 { | |
468 register int fd; | |
469 int fn_size = 100; | |
470 char buf[100]; | |
471 register char *fn = buf; | |
472 int absolute = 0; | |
473 int want_size; | |
474 register Lisp_Object filename; | |
475 struct stat st; | |
476 | |
477 if (storeptr) | |
478 *storeptr = Qnil; | |
479 | |
480 if (complete_filename_p (str)) | |
481 absolute = 1; | |
482 | |
485 | 483 for (; !NILP (path); path = Fcdr (path)) |
341 | 484 { |
485 char *nsuffix; | |
486 | |
487 filename = Fexpand_file_name (str, Fcar (path)); | |
488 if (!complete_filename_p (filename)) | |
489 /* If there are non-absolute elts in PATH (eg ".") */ | |
490 /* Of course, this could conceivably lose if luser sets | |
491 default-directory to be something non-absolute... */ | |
492 { | |
493 filename = Fexpand_file_name (filename, current_buffer->directory); | |
494 if (!complete_filename_p (filename)) | |
495 /* Give up on this path element! */ | |
496 continue; | |
497 } | |
498 | |
499 /* Calculate maximum size of any filename made from | |
500 this path element/specified file name and any possible suffix. */ | |
501 want_size = strlen (suffix) + XSTRING (filename)->size + 1; | |
502 if (fn_size < want_size) | |
503 fn = (char *) alloca (fn_size = 100 + want_size); | |
504 | |
505 nsuffix = suffix; | |
506 | |
507 /* Loop over suffixes. */ | |
508 while (1) | |
509 { | |
510 char *esuffix = (char *) index (nsuffix, ':'); | |
511 int lsuffix = esuffix ? esuffix - nsuffix : strlen (nsuffix); | |
512 | |
513 /* Concatenate path element/specified name with the suffix. */ | |
514 strncpy (fn, XSTRING (filename)->data, XSTRING (filename)->size); | |
515 fn[XSTRING (filename)->size] = 0; | |
516 if (lsuffix != 0) /* Bug happens on CCI if lsuffix is 0. */ | |
517 strncat (fn, nsuffix, lsuffix); | |
518 | |
519 /* Ignore file if it's a directory. */ | |
520 if (stat (fn, &st) >= 0 | |
521 && (st.st_mode & S_IFMT) != S_IFDIR) | |
522 { | |
523 /* Check that we can access or open it. */ | |
524 if (exec_only) | |
525 fd = (access (fn, X_OK) == 0) ? 1 : -1; | |
526 else | |
527 fd = open (fn, 0, 0); | |
528 | |
529 if (fd >= 0) | |
530 { | |
531 /* We succeeded; return this descriptor and filename. */ | |
532 if (storeptr) | |
533 *storeptr = build_string (fn); | |
534 return fd; | |
535 } | |
536 } | |
537 | |
538 /* Advance to next suffix. */ | |
539 if (esuffix == 0) | |
540 break; | |
541 nsuffix += lsuffix + 1; | |
542 } | |
543 if (absolute) return -1; | |
544 } | |
545 | |
546 return -1; | |
547 } | |
548 | |
549 | |
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
550 /* Merge the list we've accumulated of globals from the current input source |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
551 into the load_history variable. The details depend on whether |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
552 the source has an associated file name or not. */ |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
553 |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
554 static void |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
555 build_load_history (stream, source) |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
556 FILE *stream; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
557 Lisp_Object source; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
558 { |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
559 register Lisp_Object tail, prev, newelt; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
560 register Lisp_Object tem, tem2; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
561 register int foundit, loading; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
562 |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
563 loading = stream || !NARROWED; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
564 |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
565 tail = Vload_history; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
566 prev = Qnil; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
567 foundit = 0; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
568 while (!NILP (tail)) |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
569 { |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
570 tem = Fcar (tail); |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
571 |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
572 /* Find the feature's previous assoc list... */ |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
573 if (!NILP (Fequal (source, Fcar (tem)))) |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
574 { |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
575 foundit = 1; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
576 |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
577 /* If we're loading, remove it. */ |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
578 if (loading) |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
579 { |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
580 if (NILP (prev)) |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
581 Vload_history = Fcdr (tail); |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
582 else |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
583 Fsetcdr (prev, Fcdr (tail)); |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
584 } |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
585 |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
586 /* Otherwise, cons on new symbols that are not already members. */ |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
587 else |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
588 { |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
589 tem2 = Vcurrent_load_list; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
590 |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
591 while (CONSP (tem2)) |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
592 { |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
593 newelt = Fcar (tem2); |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
594 |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
595 if (NILP (Fmemq (newelt, tem))) |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
596 Fsetcar (tail, Fcons (Fcar (tem), |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
597 Fcons (newelt, Fcdr (tem)))); |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
598 |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
599 tem2 = Fcdr (tem2); |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
600 QUIT; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
601 } |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
602 } |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
603 } |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
604 else |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
605 prev = tail; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
606 tail = Fcdr (tail); |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
607 QUIT; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
608 } |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
609 |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
610 /* If we're loading, cons the new assoc onto the front of load-history, |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
611 the most-recently-loaded position. Also do this if we didn't find |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
612 an existing member for the current source. */ |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
613 if (loading || !foundit) |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
614 Vload_history = Fcons (Fnreverse(Vcurrent_load_list), |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
615 Vload_history); |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
616 } |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
617 |
341 | 618 Lisp_Object |
619 unreadpure () /* Used as unwind-protect function in readevalloop */ | |
620 { | |
621 read_pure = 0; | |
622 return Qnil; | |
623 } | |
624 | |
625 static void | |
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
626 readevalloop (readcharfun, stream, sourcename, evalfun, printflag) |
341 | 627 Lisp_Object readcharfun; |
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
628 FILE *stream; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
629 Lisp_Object sourcename; |
341 | 630 Lisp_Object (*evalfun) (); |
631 int printflag; | |
632 { | |
633 register int c; | |
634 register Lisp_Object val; | |
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
635 Lisp_Object oldlist; |
341 | 636 int count = specpdl_ptr - specpdl; |
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
637 struct gcpro gcpro1, gcpro2; |
341 | 638 |
639 specbind (Qstandard_input, readcharfun); | |
640 | |
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
641 oldlist = Vcurrent_load_list; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
642 GCPRO2 (sourcename, oldlist); |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
643 |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
644 Vcurrent_load_list = Qnil; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
645 LOADHIST_ATTACH (sourcename); |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
646 |
341 | 647 while (1) |
648 { | |
649 instream = stream; | |
650 c = READCHAR; | |
651 if (c == ';') | |
652 { | |
653 while ((c = READCHAR) != '\n' && c != -1); | |
654 continue; | |
655 } | |
656 if (c < 0) break; | |
657 if (c == ' ' || c == '\t' || c == '\n' || c == '\f') continue; | |
658 | |
485 | 659 if (!NILP (Vpurify_flag) && c == '(') |
341 | 660 { |
661 record_unwind_protect (unreadpure, Qnil); | |
662 val = read_list (-1, readcharfun); | |
663 unbind_to (count + 1, Qnil); | |
664 } | |
665 else | |
666 { | |
667 UNREAD (c); | |
668 val = read0 (readcharfun); | |
669 } | |
670 | |
671 val = (*evalfun) (val); | |
672 if (printflag) | |
673 { | |
674 Vvalues = Fcons (val, Vvalues); | |
675 if (EQ (Vstandard_output, Qt)) | |
676 Fprin1 (val, Qnil); | |
677 else | |
678 Fprint (val, Qnil); | |
679 } | |
680 } | |
681 | |
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
682 build_load_history (stream, sourcename); |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
683 |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
684 Vcurrent_load_list = oldlist; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
685 UNGCPRO; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
686 |
341 | 687 unbind_to (count, Qnil); |
688 } | |
689 | |
690 #ifndef standalone | |
691 | |
732 | 692 DEFUN ("eval-buffer", Feval_buffer, Seval_buffer, 0, 2, "", |
675
85fd29f25c75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
673
diff
changeset
|
693 "Execute the current buffer as Lisp code.\n\ |
85fd29f25c75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
673
diff
changeset
|
694 Programs can pass two arguments, BUFFER and PRINTFLAG.\n\ |
85fd29f25c75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
673
diff
changeset
|
695 BUFFER is the buffer to evaluate (nil means use current buffer).\n\ |
85fd29f25c75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
673
diff
changeset
|
696 PRINTFLAG controls printing of output:\n\ |
672 | 697 nil means discard it; anything else is stream for print.\n\ |
698 \n\ | |
699 If there is no error, point does not move. If there is an error,\n\ | |
700 point remains at the end of the last character read from the buffer.") | |
701 (bufname, printflag) | |
702 Lisp_Object bufname, printflag; | |
703 { | |
704 int count = specpdl_ptr - specpdl; | |
705 Lisp_Object tem, buf; | |
706 | |
673 | 707 if (NILP (bufname)) |
672 | 708 buf = Fcurrent_buffer (); |
709 else | |
710 buf = Fget_buffer (bufname); | |
673 | 711 if (NILP (buf)) |
672 | 712 error ("No such buffer."); |
713 | |
673 | 714 if (NILP (printflag)) |
672 | 715 tem = Qsymbolp; |
716 else | |
717 tem = printflag; | |
718 specbind (Qstandard_output, tem); | |
719 record_unwind_protect (save_excursion_restore, save_excursion_save ()); | |
720 BUF_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf))); | |
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
721 readevalloop (buf, 0, XBUFFER (buf)->filename, Feval, !NILP (printflag)); |
1924
21bd3a2189d3
* keyboard.c (recursive_edit_1, command_loop_1): Pass the proper
Jim Blandy <jimb@redhat.com>
parents:
1887
diff
changeset
|
722 unbind_to (count, Qnil); |
672 | 723 |
724 return Qnil; | |
725 } | |
726 | |
727 #if 0 | |
341 | 728 DEFUN ("eval-current-buffer", Feval_current_buffer, Seval_current_buffer, 0, 1, "", |
729 "Execute the current buffer as Lisp code.\n\ | |
730 Programs can pass argument PRINTFLAG which controls printing of output:\n\ | |
731 nil means discard it; anything else is stream for print.\n\ | |
732 \n\ | |
733 If there is no error, point does not move. If there is an error,\n\ | |
734 point remains at the end of the last character read from the buffer.") | |
735 (printflag) | |
736 Lisp_Object printflag; | |
737 { | |
738 int count = specpdl_ptr - specpdl; | |
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
739 Lisp_Object tem, cbuf; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
740 |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
741 cbuf = Fcurrent_buffer () |
341 | 742 |
485 | 743 if (NILP (printflag)) |
341 | 744 tem = Qsymbolp; |
745 else | |
746 tem = printflag; | |
747 specbind (Qstandard_output, tem); | |
748 record_unwind_protect (save_excursion_restore, save_excursion_save ()); | |
749 SET_PT (BEGV); | |
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
750 readevalloop (cbuf, 0, XBUFFER (cbuf)->filename, Feval, !NILP (printflag)); |
341 | 751 return unbind_to (count, Qnil); |
752 } | |
672 | 753 #endif |
341 | 754 |
755 DEFUN ("eval-region", Feval_region, Seval_region, 2, 3, "r", | |
756 "Execute the region as Lisp code.\n\ | |
757 When called from programs, expects two arguments,\n\ | |
758 giving starting and ending indices in the current buffer\n\ | |
759 of the text to be executed.\n\ | |
760 Programs can pass third argument PRINTFLAG which controls output:\n\ | |
761 nil means discard it; anything else is stream for printing it.\n\ | |
762 \n\ | |
763 If there is no error, point does not move. If there is an error,\n\ | |
764 point remains at the end of the last character read from the buffer.") | |
765 (b, e, printflag) | |
766 Lisp_Object b, e, printflag; | |
767 { | |
768 int count = specpdl_ptr - specpdl; | |
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
769 Lisp_Object tem, cbuf; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
770 |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
771 cbuf = Fcurrent_buffer (); |
341 | 772 |
485 | 773 if (NILP (printflag)) |
341 | 774 tem = Qsymbolp; |
775 else | |
776 tem = printflag; | |
777 specbind (Qstandard_output, tem); | |
778 | |
485 | 779 if (NILP (printflag)) |
341 | 780 record_unwind_protect (save_excursion_restore, save_excursion_save ()); |
781 record_unwind_protect (save_restriction_restore, save_restriction_save ()); | |
782 | |
783 /* This both uses b and checks its type. */ | |
784 Fgoto_char (b); | |
785 Fnarrow_to_region (make_number (BEGV), e); | |
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
786 readevalloop (cbuf, 0, XBUFFER (cbuf)->filename, Feval, !NILP (printflag)); |
341 | 787 |
788 return unbind_to (count, Qnil); | |
789 } | |
790 | |
791 #endif /* standalone */ | |
792 | |
793 DEFUN ("read", Fread, Sread, 0, 1, 0, | |
794 "Read one Lisp expression as text from STREAM, return as Lisp object.\n\ | |
795 If STREAM is nil, use the value of `standard-input' (which see).\n\ | |
796 STREAM or the value of `standard-input' may be:\n\ | |
797 a buffer (read from point and advance it)\n\ | |
798 a marker (read from where it points and advance it)\n\ | |
799 a function (call it with no arguments for each character,\n\ | |
800 call it with a char as argument to push a char back)\n\ | |
801 a string (takes text from string, starting at the beginning)\n\ | |
802 t (read text line using minibuffer and use it).") | |
803 (readcharfun) | |
804 Lisp_Object readcharfun; | |
805 { | |
806 extern Lisp_Object Fread_minibuffer (); | |
807 | |
485 | 808 if (NILP (readcharfun)) |
341 | 809 readcharfun = Vstandard_input; |
810 if (EQ (readcharfun, Qt)) | |
811 readcharfun = Qread_char; | |
812 | |
813 #ifndef standalone | |
814 if (EQ (readcharfun, Qread_char)) | |
815 return Fread_minibuffer (build_string ("Lisp expression: "), Qnil); | |
816 #endif | |
817 | |
818 if (XTYPE (readcharfun) == Lisp_String) | |
819 return Fcar (Fread_from_string (readcharfun, Qnil, Qnil)); | |
820 | |
821 return read0 (readcharfun); | |
822 } | |
823 | |
824 DEFUN ("read-from-string", Fread_from_string, Sread_from_string, 1, 3, 0, | |
825 "Read one Lisp expression which is represented as text by STRING.\n\ | |
826 Returns a cons: (OBJECT-READ . FINAL-STRING-INDEX).\n\ | |
827 START and END optionally delimit a substring of STRING from which to read;\n\ | |
828 they default to 0 and (length STRING) respectively.") | |
829 (string, start, end) | |
830 Lisp_Object string, start, end; | |
831 { | |
832 int startval, endval; | |
833 Lisp_Object tem; | |
834 | |
835 CHECK_STRING (string,0); | |
836 | |
485 | 837 if (NILP (end)) |
341 | 838 endval = XSTRING (string)->size; |
839 else | |
840 { CHECK_NUMBER (end,2); | |
841 endval = XINT (end); | |
842 if (endval < 0 || endval > XSTRING (string)->size) | |
843 args_out_of_range (string, end); | |
844 } | |
845 | |
485 | 846 if (NILP (start)) |
341 | 847 startval = 0; |
848 else | |
849 { CHECK_NUMBER (start,1); | |
850 startval = XINT (start); | |
851 if (startval < 0 || startval > endval) | |
852 args_out_of_range (string, start); | |
853 } | |
854 | |
855 read_from_string_index = startval; | |
856 read_from_string_limit = endval; | |
857 | |
858 tem = read0 (string); | |
859 return Fcons (tem, make_number (read_from_string_index)); | |
860 } | |
861 | |
862 /* Use this for recursive reads, in contexts where internal tokens are not allowed. */ | |
863 | |
864 static Lisp_Object | |
865 read0 (readcharfun) | |
866 Lisp_Object readcharfun; | |
867 { | |
868 register Lisp_Object val; | |
869 char c; | |
870 | |
871 val = read1 (readcharfun); | |
872 if (XTYPE (val) == Lisp_Internal) | |
873 { | |
874 c = XINT (val); | |
875 return Fsignal (Qinvalid_read_syntax, Fcons (make_string (&c, 1), Qnil)); | |
876 } | |
877 | |
878 return val; | |
879 } | |
880 | |
881 static int read_buffer_size; | |
882 static char *read_buffer; | |
883 | |
884 static int | |
885 read_escape (readcharfun) | |
886 Lisp_Object readcharfun; | |
887 { | |
888 register int c = READCHAR; | |
889 switch (c) | |
890 { | |
891 case 'a': | |
485 | 892 return '\007'; |
341 | 893 case 'b': |
894 return '\b'; | |
2018
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
895 case 'd': |
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
896 return 0177; |
341 | 897 case 'e': |
898 return 033; | |
899 case 'f': | |
900 return '\f'; | |
901 case 'n': | |
902 return '\n'; | |
903 case 'r': | |
904 return '\r'; | |
905 case 't': | |
906 return '\t'; | |
907 case 'v': | |
908 return '\v'; | |
909 case '\n': | |
910 return -1; | |
911 | |
912 case 'M': | |
913 c = READCHAR; | |
914 if (c != '-') | |
915 error ("Invalid escape character syntax"); | |
916 c = READCHAR; | |
917 if (c == '\\') | |
918 c = read_escape (readcharfun); | |
2044
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
919 return c | meta_modifier; |
2018
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
920 |
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
921 case 'S': |
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
922 c = READCHAR; |
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
923 if (c != '-') |
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
924 error ("Invalid escape character syntax"); |
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
925 c = READCHAR; |
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
926 if (c == '\\') |
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
927 c = read_escape (readcharfun); |
2044
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
928 return c | shift_modifier; |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
929 |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
930 case 'H': |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
931 c = READCHAR; |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
932 if (c != '-') |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
933 error ("Invalid escape character syntax"); |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
934 c = READCHAR; |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
935 if (c == '\\') |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
936 c = read_escape (readcharfun); |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
937 return c | hyper_modifier; |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
938 |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
939 case 'A': |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
940 c = READCHAR; |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
941 if (c != '-') |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
942 error ("Invalid escape character syntax"); |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
943 c = READCHAR; |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
944 if (c == '\\') |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
945 c = read_escape (readcharfun); |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
946 return c | alt_modifier; |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
947 |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
948 case 's': |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
949 c = READCHAR; |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
950 if (c != '-') |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
951 error ("Invalid escape character syntax"); |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
952 c = READCHAR; |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
953 if (c == '\\') |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
954 c = read_escape (readcharfun); |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
955 return c | super_modifier; |
341 | 956 |
957 case 'C': | |
958 c = READCHAR; | |
959 if (c != '-') | |
960 error ("Invalid escape character syntax"); | |
961 case '^': | |
962 c = READCHAR; | |
963 if (c == '\\') | |
964 c = read_escape (readcharfun); | |
2018
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
965 if ((c & 0177) == '?') |
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
966 return 0177 | c; |
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
967 /* ASCII control chars are made from letters (both cases), |
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
968 as well as the non-letters within 0100...0137. */ |
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
969 else if ((c & 0137) >= 0101 && (c & 0137) <= 0132) |
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
970 return (c & (037 | ~0177)); |
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
971 else if ((c & 0177) >= 0100 && (c & 0177) <= 0137) |
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
972 return (c & (037 | ~0177)); |
341 | 973 else |
2044
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
974 return c | ctrl_modifier; |
341 | 975 |
976 case '0': | |
977 case '1': | |
978 case '2': | |
979 case '3': | |
980 case '4': | |
981 case '5': | |
982 case '6': | |
983 case '7': | |
984 /* An octal escape, as in ANSI C. */ | |
985 { | |
986 register int i = c - '0'; | |
987 register int count = 0; | |
988 while (++count < 3) | |
989 { | |
990 if ((c = READCHAR) >= '0' && c <= '7') | |
991 { | |
992 i *= 8; | |
993 i += c - '0'; | |
994 } | |
995 else | |
996 { | |
997 UNREAD (c); | |
998 break; | |
999 } | |
1000 } | |
1001 return i; | |
1002 } | |
1003 | |
1004 case 'x': | |
1005 /* A hex escape, as in ANSI C. */ | |
1006 { | |
1007 int i = 0; | |
1008 while (1) | |
1009 { | |
1010 c = READCHAR; | |
1011 if (c >= '0' && c <= '9') | |
1012 { | |
1013 i *= 16; | |
1014 i += c - '0'; | |
1015 } | |
1016 else if ((c >= 'a' && c <= 'f') | |
1017 || (c >= 'A' && c <= 'F')) | |
1018 { | |
1019 i *= 16; | |
1020 if (c >= 'a' && c <= 'f') | |
1021 i += c - 'a' + 10; | |
1022 else | |
1023 i += c - 'A' + 10; | |
1024 } | |
1025 else | |
1026 { | |
1027 UNREAD (c); | |
1028 break; | |
1029 } | |
1030 } | |
1031 return i; | |
1032 } | |
1033 | |
1034 default: | |
1035 return c; | |
1036 } | |
1037 } | |
1038 | |
1039 static Lisp_Object | |
1040 read1 (readcharfun) | |
1041 register Lisp_Object readcharfun; | |
1042 { | |
1043 register int c; | |
1044 | |
1045 retry: | |
1046 | |
1047 c = READCHAR; | |
1048 if (c < 0) return Fsignal (Qend_of_file, Qnil); | |
1049 | |
1050 switch (c) | |
1051 { | |
1052 case '(': | |
1053 return read_list (0, readcharfun); | |
1054 | |
1055 case '[': | |
1056 return read_vector (readcharfun); | |
1057 | |
1058 case ')': | |
1059 case ']': | |
1060 { | |
1061 register Lisp_Object val; | |
1062 XSET (val, Lisp_Internal, c); | |
1063 return val; | |
1064 } | |
1065 | |
1066 case '#': | |
373
7c6f74ef31a3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
364
diff
changeset
|
1067 c = READCHAR; |
7c6f74ef31a3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
364
diff
changeset
|
1068 if (c == '[') |
7c6f74ef31a3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
364
diff
changeset
|
1069 { |
7c6f74ef31a3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
364
diff
changeset
|
1070 /* Accept compiled functions at read-time so that we don't have to |
7c6f74ef31a3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
364
diff
changeset
|
1071 build them using function calls. */ |
1966
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1072 Lisp_Object tmp; |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1073 tmp = read_vector (readcharfun); |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1074 return Fmake_byte_code (XVECTOR (tmp)->size, |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1075 XVECTOR (tmp)->contents); |
373
7c6f74ef31a3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
364
diff
changeset
|
1076 } |
1966
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1077 #ifdef USE_TEXT_PROPERTIES |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1078 if (c == '(') |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1079 { |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1080 Lisp_Object tmp; |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1081 struct gcpro gcpro1; |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1082 |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1083 /* Read the string itself. */ |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1084 tmp = read1 (readcharfun); |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1085 if (XTYPE (tmp) != Lisp_String) |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1086 Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#", 1), Qnil)); |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1087 GCPRO1 (tmp); |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1088 /* Read the intervals and their properties. */ |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1089 while (1) |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1090 { |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1091 Lisp_Object beg, end, plist; |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1092 |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1093 beg = read1 (readcharfun); |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1094 if (XTYPE (beg) == Lisp_Internal) |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1095 { |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1096 if (XINT (beg) == ')') |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1097 break; |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1098 Fsignal (Qinvalid_read_syntax, Fcons (make_string ("invalid string property list", 28), Qnil)); |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1099 } |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1100 end = read1 (readcharfun); |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1101 if (XTYPE (end) == Lisp_Internal) |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1102 Fsignal (Qinvalid_read_syntax, |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1103 Fcons (make_string ("invalid string property list", 28), Qnil)); |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1104 |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1105 plist = read1 (readcharfun); |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1106 if (XTYPE (plist) == Lisp_Internal) |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1107 Fsignal (Qinvalid_read_syntax, |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1108 Fcons (make_string ("invalid string property list", 28), Qnil)); |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1109 Fset_text_properties (beg, end, plist, tmp); |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1110 } |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1111 UNGCPRO; |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1112 return tmp; |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1113 } |
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1114 #endif |
373
7c6f74ef31a3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
364
diff
changeset
|
1115 UNREAD (c); |
1966
bcc34323a475
(read1--strings with properties case):
Richard M. Stallman <rms@gnu.org>
parents:
1924
diff
changeset
|
1116 Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#", 1), Qnil)); |
341 | 1117 |
1118 case ';': | |
1119 while ((c = READCHAR) >= 0 && c != '\n'); | |
1120 goto retry; | |
1121 | |
1122 case '\'': | |
1123 { | |
1124 return Fcons (Qquote, Fcons (read0 (readcharfun), Qnil)); | |
1125 } | |
1126 | |
1127 case '?': | |
1128 { | |
1129 register Lisp_Object val; | |
1130 | |
1131 c = READCHAR; | |
1132 if (c < 0) return Fsignal (Qend_of_file, Qnil); | |
1133 | |
1134 if (c == '\\') | |
1135 XSET (val, Lisp_Int, read_escape (readcharfun)); | |
1136 else | |
1137 XSET (val, Lisp_Int, c); | |
1138 | |
1139 return val; | |
1140 } | |
1141 | |
1142 case '\"': | |
1143 { | |
1144 register char *p = read_buffer; | |
1145 register char *end = read_buffer + read_buffer_size; | |
1146 register int c; | |
1147 int cancel = 0; | |
1148 | |
1149 while ((c = READCHAR) >= 0 | |
1150 && c != '\"') | |
1151 { | |
1152 if (p == end) | |
1153 { | |
1154 char *new = (char *) xrealloc (read_buffer, read_buffer_size *= 2); | |
1155 p += new - read_buffer; | |
1156 read_buffer += new - read_buffer; | |
1157 end = read_buffer + read_buffer_size; | |
1158 } | |
1159 if (c == '\\') | |
1160 c = read_escape (readcharfun); | |
1161 /* c is -1 if \ newline has just been seen */ | |
2018
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1162 if (c == -1) |
341 | 1163 { |
1164 if (p == read_buffer) | |
1165 cancel = 1; | |
1166 } | |
2018
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1167 else if (c & CHAR_META) |
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1168 /* Move the meta bit to the right place for a string. */ |
7c970ef8949d
(read_escape): Handle M-, C- and S- for new convention.
Richard M. Stallman <rms@gnu.org>
parents:
1966
diff
changeset
|
1169 *p++ = (c & ~CHAR_META) | 0x80; |
341 | 1170 else |
1171 *p++ = c; | |
1172 } | |
1173 if (c < 0) return Fsignal (Qend_of_file, Qnil); | |
1174 | |
1175 /* If purifying, and string starts with \ newline, | |
1176 return zero instead. This is for doc strings | |
604 | 1177 that we are really going to find in etc/DOC.nn.nn */ |
485 | 1178 if (!NILP (Vpurify_flag) && NILP (Vdoc_file_name) && cancel) |
341 | 1179 return make_number (0); |
1180 | |
1181 if (read_pure) | |
1182 return make_pure_string (read_buffer, p - read_buffer); | |
1183 else | |
1184 return make_string (read_buffer, p - read_buffer); | |
1185 } | |
1186 | |
762 | 1187 case '.': |
1188 { | |
1189 #ifdef LISP_FLOAT_TYPE | |
1190 /* If a period is followed by a number, then we should read it | |
1191 as a floating point number. Otherwise, it denotes a dotted | |
1192 pair. */ | |
1193 int next_char = READCHAR; | |
1194 UNREAD (next_char); | |
1195 | |
1196 if (! isdigit (next_char)) | |
1197 #endif | |
1198 { | |
1199 register Lisp_Object val; | |
1200 XSET (val, Lisp_Internal, c); | |
1201 return val; | |
1202 } | |
1203 | |
1204 /* Otherwise, we fall through! Note that the atom-reading loop | |
1205 below will now loop at least once, assuring that we will not | |
1206 try to UNREAD two characters in a row. */ | |
1207 } | |
341 | 1208 default: |
1209 if (c <= 040) goto retry; | |
1210 { | |
1211 register char *p = read_buffer; | |
1212 | |
1213 { | |
1214 register char *end = read_buffer + read_buffer_size; | |
1215 | |
1216 while (c > 040 && | |
1217 !(c == '\"' || c == '\'' || c == ';' || c == '?' | |
1218 || c == '(' || c == ')' | |
762 | 1219 #ifndef LISP_FLOAT_TYPE |
1220 /* If we have floating-point support, then we need | |
1221 to allow <digits><dot><digits>. */ | |
341 | 1222 || c =='.' |
1223 #endif /* not LISP_FLOAT_TYPE */ | |
1224 || c == '[' || c == ']' || c == '#' | |
1225 )) | |
1226 { | |
1227 if (p == end) | |
1228 { | |
1229 register char *new = (char *) xrealloc (read_buffer, read_buffer_size *= 2); | |
1230 p += new - read_buffer; | |
1231 read_buffer += new - read_buffer; | |
1232 end = read_buffer + read_buffer_size; | |
1233 } | |
1234 if (c == '\\') | |
1235 c = READCHAR; | |
1236 *p++ = c; | |
1237 c = READCHAR; | |
1238 } | |
1239 | |
1240 if (p == end) | |
1241 { | |
1242 char *new = (char *) xrealloc (read_buffer, read_buffer_size *= 2); | |
1243 p += new - read_buffer; | |
1244 read_buffer += new - read_buffer; | |
1245 /* end = read_buffer + read_buffer_size; */ | |
1246 } | |
1247 *p = 0; | |
1248 if (c >= 0) | |
1249 UNREAD (c); | |
1250 } | |
1251 | |
1252 /* Is it an integer? */ | |
1253 { | |
1254 register char *p1; | |
1255 register Lisp_Object val; | |
1256 p1 = read_buffer; | |
1257 if (*p1 == '+' || *p1 == '-') p1++; | |
1258 if (p1 != p) | |
1259 { | |
1260 while (p1 != p && (c = *p1) >= '0' && c <= '9') p1++; | |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1758
diff
changeset
|
1261 #ifdef LISP_FLOAT_TYPE |
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1758
diff
changeset
|
1262 /* Integers can have trailing decimal points. */ |
1827
e31051f17b9d
* lread.c (read1): Although digits followed by a '.' are an
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1263 if (p1 > read_buffer && p1 < p && *p1 == '.') p1++; |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1758
diff
changeset
|
1264 #endif |
341 | 1265 if (p1 == p) |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1758
diff
changeset
|
1266 /* It is an integer. */ |
341 | 1267 { |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1758
diff
changeset
|
1268 #ifdef LISP_FLOAT_TYPE |
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1758
diff
changeset
|
1269 if (p1[-1] == '.') |
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1758
diff
changeset
|
1270 p1[-1] = '\0'; |
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1758
diff
changeset
|
1271 #endif |
341 | 1272 XSET (val, Lisp_Int, atoi (read_buffer)); |
1273 return val; | |
1274 } | |
1275 } | |
1276 #ifdef LISP_FLOAT_TYPE | |
1277 if (isfloat_string (read_buffer)) | |
1278 return make_float (atof (read_buffer)); | |
1279 #endif | |
1280 } | |
1281 | |
1282 return intern (read_buffer); | |
1283 } | |
1284 } | |
1285 } | |
1286 | |
1287 #ifdef LISP_FLOAT_TYPE | |
1288 | |
1289 #define LEAD_INT 1 | |
1290 #define DOT_CHAR 2 | |
1291 #define TRAIL_INT 4 | |
1292 #define E_CHAR 8 | |
1293 #define EXP_INT 16 | |
1294 | |
1295 int | |
1296 isfloat_string (cp) | |
1297 register char *cp; | |
1298 { | |
1299 register state; | |
1300 | |
1301 state = 0; | |
1302 if (*cp == '+' || *cp == '-') | |
1303 cp++; | |
1304 | |
1305 if (isdigit(*cp)) | |
1306 { | |
1307 state |= LEAD_INT; | |
1308 while (isdigit (*cp)) | |
1309 cp ++; | |
1310 } | |
1311 if (*cp == '.') | |
1312 { | |
1313 state |= DOT_CHAR; | |
1314 cp++; | |
1315 } | |
1316 if (isdigit(*cp)) | |
1317 { | |
1318 state |= TRAIL_INT; | |
1319 while (isdigit (*cp)) | |
1320 cp++; | |
1321 } | |
1322 if (*cp == 'e') | |
1323 { | |
1324 state |= E_CHAR; | |
1325 cp++; | |
1326 } | |
1327 if ((*cp == '+') || (*cp == '-')) | |
1328 cp++; | |
1329 | |
1330 if (isdigit (*cp)) | |
1331 { | |
1332 state |= EXP_INT; | |
1333 while (isdigit (*cp)) | |
1334 cp++; | |
1335 } | |
1336 return (*cp == 0 | |
1337 && (state == (LEAD_INT|DOT_CHAR|TRAIL_INT) | |
826 | 1338 || state == (DOT_CHAR|TRAIL_INT) |
341 | 1339 || state == (LEAD_INT|E_CHAR|EXP_INT) |
826 | 1340 || state == (LEAD_INT|DOT_CHAR|TRAIL_INT|E_CHAR|EXP_INT) |
1341 || state == (DOT_CHAR|TRAIL_INT|E_CHAR|EXP_INT))); | |
341 | 1342 } |
1343 #endif /* LISP_FLOAT_TYPE */ | |
1344 | |
1345 static Lisp_Object | |
1346 read_vector (readcharfun) | |
1347 Lisp_Object readcharfun; | |
1348 { | |
1349 register int i; | |
1350 register int size; | |
1351 register Lisp_Object *ptr; | |
1352 register Lisp_Object tem, vector; | |
1353 register struct Lisp_Cons *otem; | |
1354 Lisp_Object len; | |
1355 | |
1356 tem = read_list (1, readcharfun); | |
1357 len = Flength (tem); | |
1358 vector = (read_pure ? make_pure_vector (XINT (len)) : Fmake_vector (len, Qnil)); | |
1359 | |
1360 | |
1361 size = XVECTOR (vector)->size; | |
1362 ptr = XVECTOR (vector)->contents; | |
1363 for (i = 0; i < size; i++) | |
1364 { | |
1365 ptr[i] = read_pure ? Fpurecopy (Fcar (tem)) : Fcar (tem); | |
1366 otem = XCONS (tem); | |
1367 tem = Fcdr (tem); | |
1368 free_cons (otem); | |
1369 } | |
1370 return vector; | |
1371 } | |
1372 | |
1373 /* flag = 1 means check for ] to terminate rather than ) and . | |
1374 flag = -1 means check for starting with defun | |
1375 and make structure pure. */ | |
1376 | |
1377 static Lisp_Object | |
1378 read_list (flag, readcharfun) | |
1379 int flag; | |
1380 register Lisp_Object readcharfun; | |
1381 { | |
1382 /* -1 means check next element for defun, | |
1383 0 means don't check, | |
1384 1 means already checked and found defun. */ | |
1385 int defunflag = flag < 0 ? -1 : 0; | |
1386 Lisp_Object val, tail; | |
1387 register Lisp_Object elt, tem; | |
1388 struct gcpro gcpro1, gcpro2; | |
1389 | |
1390 val = Qnil; | |
1391 tail = Qnil; | |
1392 | |
1393 while (1) | |
1394 { | |
1395 GCPRO2 (val, tail); | |
1396 elt = read1 (readcharfun); | |
1397 UNGCPRO; | |
1398 if (XTYPE (elt) == Lisp_Internal) | |
1399 { | |
1400 if (flag > 0) | |
1401 { | |
1402 if (XINT (elt) == ']') | |
1403 return val; | |
1404 return Fsignal (Qinvalid_read_syntax, Fcons (make_string (") or . in a vector", 18), Qnil)); | |
1405 } | |
1406 if (XINT (elt) == ')') | |
1407 return val; | |
1408 if (XINT (elt) == '.') | |
1409 { | |
1410 GCPRO2 (val, tail); | |
485 | 1411 if (!NILP (tail)) |
341 | 1412 XCONS (tail)->cdr = read0 (readcharfun); |
1413 else | |
1414 val = read0 (readcharfun); | |
1415 elt = read1 (readcharfun); | |
1416 UNGCPRO; | |
1417 if (XTYPE (elt) == Lisp_Internal && XINT (elt) == ')') | |
1418 return val; | |
1419 return Fsignal (Qinvalid_read_syntax, Fcons (make_string (". in wrong context", 18), Qnil)); | |
1420 } | |
1421 return Fsignal (Qinvalid_read_syntax, Fcons (make_string ("] in a list", 11), Qnil)); | |
1422 } | |
1423 tem = (read_pure && flag <= 0 | |
1424 ? pure_cons (elt, Qnil) | |
1425 : Fcons (elt, Qnil)); | |
485 | 1426 if (!NILP (tail)) |
341 | 1427 XCONS (tail)->cdr = tem; |
1428 else | |
1429 val = tem; | |
1430 tail = tem; | |
1431 if (defunflag < 0) | |
1432 defunflag = EQ (elt, Qdefun); | |
1433 else if (defunflag > 0) | |
1434 read_pure = 1; | |
1435 } | |
1436 } | |
1437 | |
1438 Lisp_Object Vobarray; | |
1439 Lisp_Object initial_obarray; | |
1440 | |
1441 Lisp_Object | |
1442 check_obarray (obarray) | |
1443 Lisp_Object obarray; | |
1444 { | |
1445 while (XTYPE (obarray) != Lisp_Vector || XVECTOR (obarray)->size == 0) | |
1446 { | |
1447 /* If Vobarray is now invalid, force it to be valid. */ | |
1448 if (EQ (Vobarray, obarray)) Vobarray = initial_obarray; | |
1449 | |
1450 obarray = wrong_type_argument (Qvectorp, obarray); | |
1451 } | |
1452 return obarray; | |
1453 } | |
1454 | |
1455 static int hash_string (); | |
1456 Lisp_Object oblookup (); | |
1457 | |
1458 Lisp_Object | |
1459 intern (str) | |
1460 char *str; | |
1461 { | |
1462 Lisp_Object tem; | |
1463 int len = strlen (str); | |
1464 Lisp_Object obarray = Vobarray; | |
1465 | |
1466 if (XTYPE (obarray) != Lisp_Vector || XVECTOR (obarray)->size == 0) | |
1467 obarray = check_obarray (obarray); | |
1468 tem = oblookup (obarray, str, len); | |
1469 if (XTYPE (tem) == Lisp_Symbol) | |
1470 return tem; | |
485 | 1471 return Fintern ((!NILP (Vpurify_flag) |
341 | 1472 ? make_pure_string (str, len) |
1473 : make_string (str, len)), | |
1474 obarray); | |
1475 } | |
1476 | |
1477 DEFUN ("intern", Fintern, Sintern, 1, 2, 0, | |
1478 "Return the canonical symbol whose name is STRING.\n\ | |
1479 If there is none, one is created by this function and returned.\n\ | |
1480 A second optional argument specifies the obarray to use;\n\ | |
1481 it defaults to the value of `obarray'.") | |
1482 (str, obarray) | |
1483 Lisp_Object str, obarray; | |
1484 { | |
1485 register Lisp_Object tem, sym, *ptr; | |
1486 | |
485 | 1487 if (NILP (obarray)) obarray = Vobarray; |
341 | 1488 obarray = check_obarray (obarray); |
1489 | |
1490 CHECK_STRING (str, 0); | |
1491 | |
1492 tem = oblookup (obarray, XSTRING (str)->data, XSTRING (str)->size); | |
1493 if (XTYPE (tem) != Lisp_Int) | |
1494 return tem; | |
1495 | |
485 | 1496 if (!NILP (Vpurify_flag)) |
341 | 1497 str = Fpurecopy (str); |
1498 sym = Fmake_symbol (str); | |
1499 | |
1500 ptr = &XVECTOR (obarray)->contents[XINT (tem)]; | |
1501 if (XTYPE (*ptr) == Lisp_Symbol) | |
1502 XSYMBOL (sym)->next = XSYMBOL (*ptr); | |
1503 else | |
1504 XSYMBOL (sym)->next = 0; | |
1505 *ptr = sym; | |
1506 return sym; | |
1507 } | |
1508 | |
1509 DEFUN ("intern-soft", Fintern_soft, Sintern_soft, 1, 2, 0, | |
1510 "Return the canonical symbol whose name is STRING, or nil if none exists.\n\ | |
1511 A second optional argument specifies the obarray to use;\n\ | |
1512 it defaults to the value of `obarray'.") | |
1513 (str, obarray) | |
1514 Lisp_Object str, obarray; | |
1515 { | |
1516 register Lisp_Object tem; | |
1517 | |
485 | 1518 if (NILP (obarray)) obarray = Vobarray; |
341 | 1519 obarray = check_obarray (obarray); |
1520 | |
1521 CHECK_STRING (str, 0); | |
1522 | |
1523 tem = oblookup (obarray, XSTRING (str)->data, XSTRING (str)->size); | |
1524 if (XTYPE (tem) != Lisp_Int) | |
1525 return tem; | |
1526 return Qnil; | |
1527 } | |
1528 | |
1529 Lisp_Object | |
1530 oblookup (obarray, ptr, size) | |
1531 Lisp_Object obarray; | |
1532 register char *ptr; | |
1533 register int size; | |
1534 { | |
1535 int hash, obsize; | |
1536 register Lisp_Object tail; | |
1537 Lisp_Object bucket, tem; | |
1538 | |
1539 if (XTYPE (obarray) != Lisp_Vector || | |
1540 (obsize = XVECTOR (obarray)->size) == 0) | |
1541 { | |
1542 obarray = check_obarray (obarray); | |
1543 obsize = XVECTOR (obarray)->size; | |
1544 } | |
1545 /* Combining next two lines breaks VMS C 2.3. */ | |
1546 hash = hash_string (ptr, size); | |
1547 hash %= obsize; | |
1548 bucket = XVECTOR (obarray)->contents[hash]; | |
1549 if (XFASTINT (bucket) == 0) | |
1550 ; | |
1551 else if (XTYPE (bucket) != Lisp_Symbol) | |
1552 error ("Bad data in guts of obarray"); /* Like CADR error message */ | |
1553 else for (tail = bucket; ; XSET (tail, Lisp_Symbol, XSYMBOL (tail)->next)) | |
1554 { | |
1555 if (XSYMBOL (tail)->name->size == size && | |
1556 !bcmp (XSYMBOL (tail)->name->data, ptr, size)) | |
1557 return tail; | |
1558 else if (XSYMBOL (tail)->next == 0) | |
1559 break; | |
1560 } | |
1561 XSET (tem, Lisp_Int, hash); | |
1562 return tem; | |
1563 } | |
1564 | |
1565 static int | |
1566 hash_string (ptr, len) | |
1567 unsigned char *ptr; | |
1568 int len; | |
1569 { | |
1570 register unsigned char *p = ptr; | |
1571 register unsigned char *end = p + len; | |
1572 register unsigned char c; | |
1573 register int hash = 0; | |
1574 | |
1575 while (p != end) | |
1576 { | |
1577 c = *p++; | |
1578 if (c >= 0140) c -= 40; | |
1579 hash = ((hash<<3) + (hash>>28) + c); | |
1580 } | |
1581 return hash & 07777777777; | |
1582 } | |
1583 | |
1584 void | |
1585 map_obarray (obarray, fn, arg) | |
1586 Lisp_Object obarray; | |
1587 int (*fn) (); | |
1588 Lisp_Object arg; | |
1589 { | |
1590 register int i; | |
1591 register Lisp_Object tail; | |
1592 CHECK_VECTOR (obarray, 1); | |
1593 for (i = XVECTOR (obarray)->size - 1; i >= 0; i--) | |
1594 { | |
1595 tail = XVECTOR (obarray)->contents[i]; | |
1596 if (XFASTINT (tail) != 0) | |
1597 while (1) | |
1598 { | |
1599 (*fn) (tail, arg); | |
1600 if (XSYMBOL (tail)->next == 0) | |
1601 break; | |
1602 XSET (tail, Lisp_Symbol, XSYMBOL (tail)->next); | |
1603 } | |
1604 } | |
1605 } | |
1606 | |
1607 mapatoms_1 (sym, function) | |
1608 Lisp_Object sym, function; | |
1609 { | |
1610 call1 (function, sym); | |
1611 } | |
1612 | |
1613 DEFUN ("mapatoms", Fmapatoms, Smapatoms, 1, 2, 0, | |
1614 "Call FUNCTION on every symbol in OBARRAY.\n\ | |
1615 OBARRAY defaults to the value of `obarray'.") | |
1616 (function, obarray) | |
1617 Lisp_Object function, obarray; | |
1618 { | |
1619 Lisp_Object tem; | |
1620 | |
485 | 1621 if (NILP (obarray)) obarray = Vobarray; |
341 | 1622 obarray = check_obarray (obarray); |
1623 | |
1624 map_obarray (obarray, mapatoms_1, function); | |
1625 return Qnil; | |
1626 } | |
1627 | |
1628 #define OBARRAY_SIZE 509 | |
1629 | |
1630 void | |
1631 init_obarray () | |
1632 { | |
1633 Lisp_Object oblength; | |
1634 int hash; | |
1635 Lisp_Object *tem; | |
1636 | |
1637 XFASTINT (oblength) = OBARRAY_SIZE; | |
1638 | |
1639 Qnil = Fmake_symbol (make_pure_string ("nil", 3)); | |
1640 Vobarray = Fmake_vector (oblength, make_number (0)); | |
1641 initial_obarray = Vobarray; | |
1642 staticpro (&initial_obarray); | |
1643 /* Intern nil in the obarray */ | |
1644 /* These locals are to kludge around a pyramid compiler bug. */ | |
1645 hash = hash_string ("nil", 3); | |
1646 /* Separate statement here to avoid VAXC bug. */ | |
1647 hash %= OBARRAY_SIZE; | |
1648 tem = &XVECTOR (Vobarray)->contents[hash]; | |
1649 *tem = Qnil; | |
1650 | |
1651 Qunbound = Fmake_symbol (make_pure_string ("unbound", 7)); | |
1652 XSYMBOL (Qnil)->function = Qunbound; | |
1653 XSYMBOL (Qunbound)->value = Qunbound; | |
1654 XSYMBOL (Qunbound)->function = Qunbound; | |
1655 | |
1656 Qt = intern ("t"); | |
1657 XSYMBOL (Qnil)->value = Qnil; | |
1658 XSYMBOL (Qnil)->plist = Qnil; | |
1659 XSYMBOL (Qt)->value = Qt; | |
1660 | |
1661 /* Qt is correct even if CANNOT_DUMP. loadup.el will set to nil at end. */ | |
1662 Vpurify_flag = Qt; | |
1663 | |
1664 Qvariable_documentation = intern ("variable-documentation"); | |
1665 | |
1666 read_buffer_size = 100; | |
1667 read_buffer = (char *) malloc (read_buffer_size); | |
1668 } | |
1669 | |
1670 void | |
1671 defsubr (sname) | |
1672 struct Lisp_Subr *sname; | |
1673 { | |
1674 Lisp_Object sym; | |
1675 sym = intern (sname->symbol_name); | |
1676 XSET (XSYMBOL (sym)->function, Lisp_Subr, sname); | |
1677 } | |
1678 | |
1679 #ifdef NOTDEF /* use fset in subr.el now */ | |
1680 void | |
1681 defalias (sname, string) | |
1682 struct Lisp_Subr *sname; | |
1683 char *string; | |
1684 { | |
1685 Lisp_Object sym; | |
1686 sym = intern (string); | |
1687 XSET (XSYMBOL (sym)->function, Lisp_Subr, sname); | |
1688 } | |
1689 #endif /* NOTDEF */ | |
1690 | |
1691 /* New replacement for DefIntVar; it ignores the doc string argument | |
1692 on the assumption that make-docfile will handle that. */ | |
1693 /* Define an "integer variable"; a symbol whose value is forwarded | |
1694 to a C variable of type int. Sample call: */ | |
1695 /* DEFVARINT ("indent-tabs-mode", &indent_tabs_mode, "Documentation"); */ | |
1696 | |
1697 void | |
1698 defvar_int (namestring, address, doc) | |
1699 char *namestring; | |
1700 int *address; | |
1701 char *doc; | |
1702 { | |
1703 Lisp_Object sym; | |
1704 sym = intern (namestring); | |
1705 XSET (XSYMBOL (sym)->value, Lisp_Intfwd, address); | |
1706 } | |
1707 | |
1708 /* Similar but define a variable whose value is T if address contains 1, | |
1709 NIL if address contains 0 */ | |
1710 | |
1711 void | |
1712 defvar_bool (namestring, address, doc) | |
1713 char *namestring; | |
1714 int *address; | |
1715 char *doc; | |
1716 { | |
1717 Lisp_Object sym; | |
1718 sym = intern (namestring); | |
1719 XSET (XSYMBOL (sym)->value, Lisp_Boolfwd, address); | |
1720 } | |
1721 | |
1722 /* Similar but define a variable whose value is the Lisp Object stored at address. */ | |
1723 | |
1724 void | |
1725 defvar_lisp (namestring, address, doc) | |
1726 char *namestring; | |
1727 Lisp_Object *address; | |
1728 char *doc; | |
1729 { | |
1730 Lisp_Object sym; | |
1731 sym = intern (namestring); | |
1732 XSET (XSYMBOL (sym)->value, Lisp_Objfwd, address); | |
1733 staticpro (address); | |
1734 } | |
1735 | |
1736 /* Similar but don't request gc-marking of the C variable. | |
1737 Used when that variable will be gc-marked for some other reason, | |
1738 since marking the same slot twice can cause trouble with strings. */ | |
1739 | |
1740 void | |
1741 defvar_lisp_nopro (namestring, address, doc) | |
1742 char *namestring; | |
1743 Lisp_Object *address; | |
1744 char *doc; | |
1745 { | |
1746 Lisp_Object sym; | |
1747 sym = intern (namestring); | |
1748 XSET (XSYMBOL (sym)->value, Lisp_Objfwd, address); | |
1749 } | |
1750 | |
1751 #ifndef standalone | |
1752 | |
1753 /* Similar but define a variable whose value is the Lisp Object stored in | |
1754 the current buffer. address is the address of the slot in the buffer that is current now. */ | |
1755 | |
1756 void | |
1009
bf78b5ea9b3a
* lread.c (defvar_per_buffer): Support new TYPE argument, by
Jim Blandy <jimb@redhat.com>
parents:
851
diff
changeset
|
1757 defvar_per_buffer (namestring, address, type, doc) |
341 | 1758 char *namestring; |
1759 Lisp_Object *address; | |
1009
bf78b5ea9b3a
* lread.c (defvar_per_buffer): Support new TYPE argument, by
Jim Blandy <jimb@redhat.com>
parents:
851
diff
changeset
|
1760 Lisp_Object type; |
341 | 1761 char *doc; |
1762 { | |
1763 Lisp_Object sym; | |
1764 int offset; | |
1765 extern struct buffer buffer_local_symbols; | |
1766 | |
1767 sym = intern (namestring); | |
1768 offset = (char *)address - (char *)current_buffer; | |
1769 | |
1770 XSET (XSYMBOL (sym)->value, Lisp_Buffer_Objfwd, | |
1771 (Lisp_Object *) offset); | |
1772 *(Lisp_Object *)(offset + (char *)&buffer_local_symbols) = sym; | |
1009
bf78b5ea9b3a
* lread.c (defvar_per_buffer): Support new TYPE argument, by
Jim Blandy <jimb@redhat.com>
parents:
851
diff
changeset
|
1773 *(Lisp_Object *)(offset + (char *)&buffer_local_types) = type; |
341 | 1774 if (*(int *)(offset + (char *)&buffer_local_flags) == 0) |
1775 /* Did a DEFVAR_PER_BUFFER without initializing the corresponding | |
1776 slot of buffer_local_flags */ | |
1777 abort (); | |
1778 } | |
1779 | |
1780 #endif /* standalone */ | |
1781 | |
364 | 1782 init_lread () |
341 | 1783 { |
617 | 1784 char *normal; |
341 | 1785 |
364 | 1786 /* Compute the default load-path. */ |
617 | 1787 #ifdef CANNOT_DUMP |
1788 normal = PATH_LOADSEARCH; | |
638 | 1789 Vload_path = decode_env_path (0, normal); |
617 | 1790 #else |
1791 if (NILP (Vpurify_flag)) | |
1792 normal = PATH_LOADSEARCH; | |
1793 else | |
1794 normal = PATH_DUMPLOADSEARCH; | |
1795 | |
1796 /* In a dumped Emacs, we normally have to reset the value of | |
1797 Vload_path from PATH_LOADSEARCH, since the value that was dumped | |
1798 uses ../lisp, instead of the path of the installed elisp | |
1799 libraries. However, if it appears that Vload_path was changed | |
1800 from the default before dumping, don't override that value. */ | |
621 | 1801 if (initialized) |
1802 { | |
1803 Lisp_Object dump_path; | |
617 | 1804 |
638 | 1805 dump_path = decode_env_path (0, PATH_DUMPLOADSEARCH); |
621 | 1806 if (! NILP (Fequal (dump_path, Vload_path))) |
638 | 1807 Vload_path = decode_env_path (0, normal); |
621 | 1808 } |
1809 else | |
638 | 1810 Vload_path = decode_env_path (0, normal); |
364 | 1811 #endif |
1812 | |
341 | 1813 /* Warn if dirs in the *standard* path don't exist. */ |
617 | 1814 { |
1815 Lisp_Object path_tail; | |
341 | 1816 |
617 | 1817 for (path_tail = Vload_path; |
1818 !NILP (path_tail); | |
1819 path_tail = XCONS (path_tail)->cdr) | |
1820 { | |
1821 Lisp_Object dirfile; | |
1822 dirfile = Fcar (path_tail); | |
1823 if (XTYPE (dirfile) == Lisp_String) | |
1824 { | |
1825 dirfile = Fdirectory_file_name (dirfile); | |
1826 if (access (XSTRING (dirfile)->data, 0) < 0) | |
1827 printf ("Warning: lisp library (%s) does not exist.\n", | |
1828 XSTRING (Fcar (path_tail))->data); | |
1829 } | |
1830 } | |
1831 } | |
1832 | |
1833 /* If the EMACSLOADPATH environment variable is set, use its value. | |
1834 This doesn't apply if we're dumping. */ | |
1835 if (NILP (Vpurify_flag) | |
1836 && egetenv ("EMACSLOADPATH")) | |
364 | 1837 Vload_path = decode_env_path ("EMACSLOADPATH", normal); |
1838 | |
1839 Vvalues = Qnil; | |
1840 | |
341 | 1841 load_in_progress = 0; |
1842 } | |
1843 | |
1844 void | |
364 | 1845 syms_of_lread () |
341 | 1846 { |
1847 defsubr (&Sread); | |
1848 defsubr (&Sread_from_string); | |
1849 defsubr (&Sintern); | |
1850 defsubr (&Sintern_soft); | |
1851 defsubr (&Sload); | |
672 | 1852 defsubr (&Seval_buffer); |
341 | 1853 defsubr (&Seval_region); |
1854 defsubr (&Sread_char); | |
1855 defsubr (&Sread_char_exclusive); | |
1856 defsubr (&Sread_event); | |
1857 defsubr (&Sget_file_char); | |
1858 defsubr (&Smapatoms); | |
1859 | |
1860 DEFVAR_LISP ("obarray", &Vobarray, | |
1861 "Symbol table for use by `intern' and `read'.\n\ | |
1862 It is a vector whose length ought to be prime for best results.\n\ | |
1863 The vector's contents don't make sense if examined from Lisp programs;\n\ | |
1864 to find all the symbols in an obarray, use `mapatoms'."); | |
1865 | |
1866 DEFVAR_LISP ("values", &Vvalues, | |
1867 "List of values of all expressions which were read, evaluated and printed.\n\ | |
1868 Order is reverse chronological."); | |
1869 | |
1870 DEFVAR_LISP ("standard-input", &Vstandard_input, | |
1871 "Stream for read to get input from.\n\ | |
1872 See documentation of `read' for possible values."); | |
1873 Vstandard_input = Qt; | |
1874 | |
1875 DEFVAR_LISP ("load-path", &Vload_path, | |
1876 "*List of directories to search for files to load.\n\ | |
1877 Each element is a string (directory name) or nil (try default directory).\n\ | |
1878 Initialized based on EMACSLOADPATH environment variable, if any,\n\ | |
1887
ab56990c27c4
(syms_of_lread): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
1827
diff
changeset
|
1879 otherwise to default specified by file `paths.h' when Emacs was built."); |
341 | 1880 |
1881 DEFVAR_BOOL ("load-in-progress", &load_in_progress, | |
1882 "Non-nil iff inside of `load'."); | |
1883 | |
1884 DEFVAR_LISP ("after-load-alist", &Vafter_load_alist, | |
1885 "An alist of expressions to be evalled when particular files are loaded.\n\ | |
1886 Each element looks like (FILENAME FORMS...).\n\ | |
1887 When `load' is run and the file-name argument is FILENAME,\n\ | |
1888 the FORMS in the corresponding element are executed at the end of loading.\n\n\ | |
1889 FILENAME must match exactly! Normally FILENAME is the name of a library,\n\ | |
1890 with no directory specified, since that is how `load' is normally called.\n\ | |
1891 An error in FORMS does not undo the load,\n\ | |
1892 but does prevent execution of the rest of the FORMS."); | |
1893 Vafter_load_alist = Qnil; | |
1894 | |
2545
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1895 DEFVAR_LISP ("load-history", &Vload_history, |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1896 "Alist mapping source file names to symbols and features.\n\ |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1897 Each alist element is a list that starts with a file name,\n\ |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1898 except for one element (optional) that starts with nil and describes\n\ |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1899 definitions evaluated from buffers not visiting files.\n\ |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1900 The remaining elements of each list are symbols defined as functions\n\ |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1901 or variables, and cons cells `(provide . FEATURE)' and `(require . FEATURE)'."); |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1902 Vload_history = Qnil; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1903 |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1904 staticpro (&Vcurrent_load_list); |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1905 Vcurrent_load_list = Qnil; |
d666732c5f41
(readevalloop): New argument is the source file name (or nil if none).
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1906 |
341 | 1907 Qstandard_input = intern ("standard-input"); |
1908 staticpro (&Qstandard_input); | |
1909 | |
1910 Qread_char = intern ("read-char"); | |
1911 staticpro (&Qread_char); | |
1912 | |
1913 Qget_file_char = intern ("get-file-char"); | |
1914 staticpro (&Qget_file_char); | |
2044
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1915 |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1916 Qascii_character = intern ("ascii-character"); |
258362f03d90
(syms_of_lread): Set up Qascii_character.
Richard M. Stallman <rms@gnu.org>
parents:
2018
diff
changeset
|
1917 staticpro (&Qascii_character); |
341 | 1918 } |