Mercurial > emacs
annotate src/eval.c @ 26163:99c35bcce8c0
netbsd-elf fixes
author | Ken Raeburn <raeburn@raeburn.org> |
---|---|
date | Mon, 25 Oct 1999 04:50:39 +0000 |
parents | b7aa6ac26872 |
children | 4d1e267efd41 |
rev | line source |
---|---|
272 | 1 /* Evaluator for GNU Emacs Lisp interpreter. |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25783
diff
changeset
|
2 Copyright (C) 1985, 86, 87, 93, 94, 95, 1999 Free Software Foundation, Inc. |
272 | 3 |
4 This file is part of GNU Emacs. | |
5 | |
6 GNU Emacs is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
10342
01d13c22797e
(Fcommandp): Use & PSEUDOVECTOR_SIZE_MASK on `size' field of compiled
Roland McGrath <roland@gnu.org>
parents:
10201
diff
changeset
|
8 the Free Software Foundation; either version 2, or (at your option) |
272 | 9 any later version. |
10 | |
11 GNU Emacs is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GNU Emacs; see the file COPYING. If not, write to | |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14073
diff
changeset
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14073
diff
changeset
|
19 Boston, MA 02111-1307, USA. */ |
272 | 20 |
21 | |
4696
1fc792473491
Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents:
4474
diff
changeset
|
22 #include <config.h> |
21514 | 23 |
272 | 24 #include "lisp.h" |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
1564
diff
changeset
|
25 #include "blockinput.h" |
272 | 26 |
27 #ifndef standalone | |
28 #include "commands.h" | |
515 | 29 #include "keyboard.h" |
272 | 30 #else |
31 #define INTERACTIVE 1 | |
32 #endif | |
33 | |
34 #include <setjmp.h> | |
35 | |
36 /* This definition is duplicated in alloc.c and keyboard.c */ | |
37 /* Putting it in lisp.h makes cc bomb out! */ | |
38 | |
39 struct backtrace | |
40 { | |
41 struct backtrace *next; | |
42 Lisp_Object *function; | |
43 Lisp_Object *args; /* Points to vector of args. */ | |
727 | 44 int nargs; /* Length of vector. |
45 If nargs is UNEVALLED, args points to slot holding | |
46 list of unevalled args */ | |
272 | 47 char evalargs; |
48 /* Nonzero means call value of debugger when done with this operation. */ | |
49 char debug_on_exit; | |
50 }; | |
51 | |
52 struct backtrace *backtrace_list; | |
53 | |
1196
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
54 /* This structure helps implement the `catch' and `throw' control |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
55 structure. A struct catchtag contains all the information needed |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
56 to restore the state of the interpreter after a non-local jump. |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
57 |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
58 Handlers for error conditions (represented by `struct handler' |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
59 structures) just point to a catch tag to do the cleanup required |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
60 for their jumps. |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
61 |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
62 catchtag structures are chained together in the C calling stack; |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
63 the `next' member points to the next outer catchtag. |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
64 |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
65 A call like (throw TAG VAL) searches for a catchtag whose `tag' |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
66 member is TAG, and then unbinds to it. The `val' member is used to |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
67 hold VAL while the stack is unwound; `val' is returned as the value |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
68 of the catch form. |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
69 |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
70 All the other members are concerned with restoring the interpreter |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
71 state. */ |
272 | 72 struct catchtag |
73 { | |
74 Lisp_Object tag; | |
75 Lisp_Object val; | |
76 struct catchtag *next; | |
77 struct gcpro *gcpro; | |
78 jmp_buf jmp; | |
79 struct backtrace *backlist; | |
80 struct handler *handlerlist; | |
81 int lisp_eval_depth; | |
82 int pdlcount; | |
83 int poll_suppress_count; | |
84 }; | |
85 | |
86 struct catchtag *catchlist; | |
87 | |
88 Lisp_Object Qautoload, Qmacro, Qexit, Qinteractive, Qcommandp, Qdefun; | |
381 | 89 Lisp_Object Qinhibit_quit, Vinhibit_quit, Vquit_flag; |
272 | 90 Lisp_Object Qmocklisp_arguments, Vmocklisp_arguments, Qmocklisp; |
91 Lisp_Object Qand_rest, Qand_optional; | |
92 Lisp_Object Qdebug_on_error; | |
93 | |
16296
584310941e70
(syms_of_eval): Initialize Vrun_hooks here.
Richard M. Stallman <rms@gnu.org>
parents:
16113
diff
changeset
|
94 /* This holds either the symbol `run-hooks' or nil. |
584310941e70
(syms_of_eval): Initialize Vrun_hooks here.
Richard M. Stallman <rms@gnu.org>
parents:
16113
diff
changeset
|
95 It is nil at an early stage of startup, and when Emacs |
584310941e70
(syms_of_eval): Initialize Vrun_hooks here.
Richard M. Stallman <rms@gnu.org>
parents:
16113
diff
changeset
|
96 is shutting down. */ |
272 | 97 Lisp_Object Vrun_hooks; |
98 | |
99 /* Non-nil means record all fset's and provide's, to be undone | |
100 if the file being autoloaded is not fully loaded. | |
101 They are recorded by being consed onto the front of Vautoload_queue: | |
102 (FUN . ODEF) for a defun, (OFEATURES . nil) for a provide. */ | |
103 | |
104 Lisp_Object Vautoload_queue; | |
105 | |
106 /* Current number of specbindings allocated in specpdl. */ | |
107 int specpdl_size; | |
108 | |
109 /* Pointer to beginning of specpdl. */ | |
110 struct specbinding *specpdl; | |
111 | |
112 /* Pointer to first unused element in specpdl. */ | |
113 struct specbinding *specpdl_ptr; | |
114 | |
115 /* Maximum size allowed for specpdl allocation */ | |
116 int max_specpdl_size; | |
117 | |
118 /* Depth in Lisp evaluations and function calls. */ | |
119 int lisp_eval_depth; | |
120 | |
121 /* Maximum allowed depth in Lisp evaluations and function calls. */ | |
122 int max_lisp_eval_depth; | |
123 | |
124 /* Nonzero means enter debugger before next function call */ | |
125 int debug_on_next_call; | |
126 | |
684 | 127 /* List of conditions (non-nil atom means all) which cause a backtrace |
706
86cb5db0b6c3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
687
diff
changeset
|
128 if an error is handled by the command loop's error handler. */ |
684 | 129 Lisp_Object Vstack_trace_on_error; |
272 | 130 |
684 | 131 /* List of conditions (non-nil atom means all) which enter the debugger |
706
86cb5db0b6c3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
687
diff
changeset
|
132 if an error is handled by the command loop's error handler. */ |
684 | 133 Lisp_Object Vdebug_on_error; |
272 | 134 |
13768 | 135 /* List of conditions and regexps specifying error messages which |
136 do not enter the debugger even if Vdebug_on_errors says they should. */ | |
137 Lisp_Object Vdebug_ignored_errors; | |
138 | |
16355
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
139 /* Non-nil means call the debugger even if the error will be handled. */ |
16443
0128b923d281
(Vdebug_on_signal): Renamed from Vdebug_force.
Richard M. Stallman <rms@gnu.org>
parents:
16355
diff
changeset
|
140 Lisp_Object Vdebug_on_signal; |
16355
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
141 |
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
142 /* Hook for edebug to use. */ |
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
143 Lisp_Object Vsignal_hook_function; |
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
144 |
272 | 145 /* Nonzero means enter debugger if a quit signal |
684 | 146 is handled by the command loop's error handler. */ |
272 | 147 int debug_on_quit; |
148 | |
17872
31b2c6763574
(num_nonmacro_input_events):
Richard M. Stallman <rms@gnu.org>
parents:
17275
diff
changeset
|
149 /* The value of num_nonmacro_input_events as of the last time we |
1196
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
150 started to enter the debugger. If we decide to enter the debugger |
17872
31b2c6763574
(num_nonmacro_input_events):
Richard M. Stallman <rms@gnu.org>
parents:
17275
diff
changeset
|
151 again when this is still equal to num_nonmacro_input_events, then we |
1196
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
152 know that the debugger itself has an error, and we should just |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
153 signal the error instead of entering an infinite loop of debugger |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
154 invocations. */ |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
155 int when_entered_debugger; |
272 | 156 |
157 Lisp_Object Vdebugger; | |
158 | |
159 void specbind (), record_unwind_protect (); | |
160 | |
13314
661060193eb8
(run_hook_with_args): Add forward declaration.
Richard M. Stallman <rms@gnu.org>
parents:
13103
diff
changeset
|
161 Lisp_Object run_hook_with_args (); |
661060193eb8
(run_hook_with_args): Add forward declaration.
Richard M. Stallman <rms@gnu.org>
parents:
13103
diff
changeset
|
162 |
272 | 163 Lisp_Object funcall_lambda (); |
164 extern Lisp_Object ml_apply (); /* Apply a mocklisp function to unevaluated argument list */ | |
165 | |
21514 | 166 void |
272 | 167 init_eval_once () |
168 { | |
169 specpdl_size = 50; | |
7885
bc6406a90796
(init_eval_once): Call xmalloc, not malloc.
Richard M. Stallman <rms@gnu.org>
parents:
7533
diff
changeset
|
170 specpdl = (struct specbinding *) xmalloc (specpdl_size * sizeof (struct specbinding)); |
14600
f32beac333a0
(init_eval_once): Initialize specpdl_ptr.
Karl Heuer <kwzh@gnu.org>
parents:
14218
diff
changeset
|
171 specpdl_ptr = specpdl; |
272 | 172 max_specpdl_size = 600; |
17061
bc9a4db95edb
(init_eval_once): Increase max_lisp_eval_depth to 300.
Karl Heuer <kwzh@gnu.org>
parents:
16930
diff
changeset
|
173 max_lisp_eval_depth = 300; |
8980
e641b60610a1
(init_eval_once): Init Vrun_hooks here.
Richard M. Stallman <rms@gnu.org>
parents:
8902
diff
changeset
|
174 |
e641b60610a1
(init_eval_once): Init Vrun_hooks here.
Richard M. Stallman <rms@gnu.org>
parents:
8902
diff
changeset
|
175 Vrun_hooks = Qnil; |
272 | 176 } |
177 | |
21514 | 178 void |
272 | 179 init_eval () |
180 { | |
181 specpdl_ptr = specpdl; | |
182 catchlist = 0; | |
183 handlerlist = 0; | |
184 backtrace_list = 0; | |
185 Vquit_flag = Qnil; | |
186 debug_on_next_call = 0; | |
187 lisp_eval_depth = 0; | |
17872
31b2c6763574
(num_nonmacro_input_events):
Richard M. Stallman <rms@gnu.org>
parents:
17275
diff
changeset
|
188 /* This is less than the initial value of num_nonmacro_input_events. */ |
7213
bb5db306a305
(init_eval): Initialize when_entered_debugger to -1.
Richard M. Stallman <rms@gnu.org>
parents:
6918
diff
changeset
|
189 when_entered_debugger = -1; |
272 | 190 } |
191 | |
192 Lisp_Object | |
193 call_debugger (arg) | |
194 Lisp_Object arg; | |
195 { | |
196 if (lisp_eval_depth + 20 > max_lisp_eval_depth) | |
197 max_lisp_eval_depth = lisp_eval_depth + 20; | |
198 if (specpdl_size + 40 > max_specpdl_size) | |
199 max_specpdl_size = specpdl_size + 40; | |
200 debug_on_next_call = 0; | |
17872
31b2c6763574
(num_nonmacro_input_events):
Richard M. Stallman <rms@gnu.org>
parents:
17275
diff
changeset
|
201 when_entered_debugger = num_nonmacro_input_events; |
272 | 202 return apply1 (Vdebugger, arg); |
203 } | |
204 | |
21514 | 205 void |
272 | 206 do_debug_on_call (code) |
207 Lisp_Object code; | |
208 { | |
209 debug_on_next_call = 0; | |
210 backtrace_list->debug_on_exit = 1; | |
211 call_debugger (Fcons (code, Qnil)); | |
212 } | |
213 | |
214 /* NOTE!!! Every function that can call EVAL must protect its args | |
215 and temporaries from garbage collection while it needs them. | |
216 The definition of `For' shows what you have to do. */ | |
217 | |
218 DEFUN ("or", For, Sor, 0, UNEVALLED, 0, | |
219 "Eval args until one of them yields non-nil, then return that value.\n\ | |
220 The remaining args are not evalled at all.\n\ | |
221 If all args return nil, return nil.") | |
222 (args) | |
223 Lisp_Object args; | |
224 { | |
225 register Lisp_Object val; | |
226 Lisp_Object args_left; | |
227 struct gcpro gcpro1; | |
228 | |
485 | 229 if (NILP(args)) |
272 | 230 return Qnil; |
231 | |
232 args_left = args; | |
233 GCPRO1 (args_left); | |
234 | |
235 do | |
236 { | |
237 val = Feval (Fcar (args_left)); | |
485 | 238 if (!NILP (val)) |
272 | 239 break; |
240 args_left = Fcdr (args_left); | |
241 } | |
485 | 242 while (!NILP(args_left)); |
272 | 243 |
244 UNGCPRO; | |
245 return val; | |
246 } | |
247 | |
248 DEFUN ("and", Fand, Sand, 0, UNEVALLED, 0, | |
249 "Eval args until one of them yields nil, then return nil.\n\ | |
250 The remaining args are not evalled at all.\n\ | |
251 If no arg yields nil, return the last arg's value.") | |
252 (args) | |
253 Lisp_Object args; | |
254 { | |
255 register Lisp_Object val; | |
256 Lisp_Object args_left; | |
257 struct gcpro gcpro1; | |
258 | |
485 | 259 if (NILP(args)) |
272 | 260 return Qt; |
261 | |
262 args_left = args; | |
263 GCPRO1 (args_left); | |
264 | |
265 do | |
266 { | |
267 val = Feval (Fcar (args_left)); | |
485 | 268 if (NILP (val)) |
272 | 269 break; |
270 args_left = Fcdr (args_left); | |
271 } | |
485 | 272 while (!NILP(args_left)); |
272 | 273 |
274 UNGCPRO; | |
275 return val; | |
276 } | |
277 | |
278 DEFUN ("if", Fif, Sif, 2, UNEVALLED, 0, | |
279 "(if COND THEN ELSE...): if COND yields non-nil, do THEN, else do ELSE...\n\ | |
280 Returns the value of THEN or the value of the last of the ELSE's.\n\ | |
281 THEN must be one expression, but ELSE... can be zero or more expressions.\n\ | |
282 If COND yields nil, and there are no ELSE's, the value is nil.") | |
283 (args) | |
284 Lisp_Object args; | |
285 { | |
286 register Lisp_Object cond; | |
287 struct gcpro gcpro1; | |
288 | |
289 GCPRO1 (args); | |
290 cond = Feval (Fcar (args)); | |
291 UNGCPRO; | |
292 | |
485 | 293 if (!NILP (cond)) |
272 | 294 return Feval (Fcar (Fcdr (args))); |
295 return Fprogn (Fcdr (Fcdr (args))); | |
296 } | |
297 | |
298 DEFUN ("cond", Fcond, Scond, 0, UNEVALLED, 0, | |
299 "(cond CLAUSES...): try each clause until one succeeds.\n\ | |
300 Each clause looks like (CONDITION BODY...). CONDITION is evaluated\n\ | |
301 and, if the value is non-nil, this clause succeeds:\n\ | |
302 then the expressions in BODY are evaluated and the last one's\n\ | |
303 value is the value of the cond-form.\n\ | |
304 If no clause succeeds, cond returns nil.\n\ | |
305 If a clause has one element, as in (CONDITION),\n\ | |
306 CONDITION's value if non-nil is returned from the cond-form.") | |
307 (args) | |
308 Lisp_Object args; | |
309 { | |
310 register Lisp_Object clause, val; | |
311 struct gcpro gcpro1; | |
312 | |
313 val = Qnil; | |
314 GCPRO1 (args); | |
485 | 315 while (!NILP (args)) |
272 | 316 { |
317 clause = Fcar (args); | |
318 val = Feval (Fcar (clause)); | |
485 | 319 if (!NILP (val)) |
272 | 320 { |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
321 if (!EQ (XCDR (clause), Qnil)) |
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
322 val = Fprogn (XCDR (clause)); |
272 | 323 break; |
324 } | |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
325 args = XCDR (args); |
272 | 326 } |
327 UNGCPRO; | |
328 | |
329 return val; | |
330 } | |
331 | |
332 DEFUN ("progn", Fprogn, Sprogn, 0, UNEVALLED, 0, | |
333 "(progn BODY...): eval BODY forms sequentially and return value of last one.") | |
334 (args) | |
335 Lisp_Object args; | |
336 { | |
337 register Lisp_Object val, tem; | |
338 Lisp_Object args_left; | |
339 struct gcpro gcpro1; | |
340 | |
341 /* In Mocklisp code, symbols at the front of the progn arglist | |
342 are to be bound to zero. */ | |
343 if (!EQ (Vmocklisp_arguments, Qt)) | |
344 { | |
345 val = make_number (0); | |
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
346 while (!NILP (args) && (tem = Fcar (args), SYMBOLP (tem))) |
272 | 347 { |
348 QUIT; | |
349 specbind (tem, val), args = Fcdr (args); | |
350 } | |
351 } | |
352 | |
485 | 353 if (NILP(args)) |
272 | 354 return Qnil; |
355 | |
356 args_left = args; | |
357 GCPRO1 (args_left); | |
358 | |
359 do | |
360 { | |
361 val = Feval (Fcar (args_left)); | |
362 args_left = Fcdr (args_left); | |
363 } | |
485 | 364 while (!NILP(args_left)); |
272 | 365 |
366 UNGCPRO; | |
367 return val; | |
368 } | |
369 | |
370 DEFUN ("prog1", Fprog1, Sprog1, 1, UNEVALLED, 0, | |
371 "(prog1 FIRST BODY...): eval FIRST and BODY sequentially; value from FIRST.\n\ | |
372 The value of FIRST is saved during the evaluation of the remaining args,\n\ | |
373 whose values are discarded.") | |
374 (args) | |
375 Lisp_Object args; | |
376 { | |
377 Lisp_Object val; | |
378 register Lisp_Object args_left; | |
379 struct gcpro gcpro1, gcpro2; | |
380 register int argnum = 0; | |
381 | |
485 | 382 if (NILP(args)) |
272 | 383 return Qnil; |
384 | |
385 args_left = args; | |
386 val = Qnil; | |
387 GCPRO2 (args, val); | |
388 | |
389 do | |
390 { | |
391 if (!(argnum++)) | |
392 val = Feval (Fcar (args_left)); | |
393 else | |
394 Feval (Fcar (args_left)); | |
395 args_left = Fcdr (args_left); | |
396 } | |
485 | 397 while (!NILP(args_left)); |
272 | 398 |
399 UNGCPRO; | |
400 return val; | |
401 } | |
402 | |
403 DEFUN ("prog2", Fprog2, Sprog2, 2, UNEVALLED, 0, | |
8412 | 404 "(prog2 X Y BODY...): eval X, Y and BODY sequentially; value from Y.\n\ |
272 | 405 The value of Y is saved during the evaluation of the remaining args,\n\ |
406 whose values are discarded.") | |
407 (args) | |
408 Lisp_Object args; | |
409 { | |
410 Lisp_Object val; | |
411 register Lisp_Object args_left; | |
412 struct gcpro gcpro1, gcpro2; | |
413 register int argnum = -1; | |
414 | |
415 val = Qnil; | |
416 | |
6803 | 417 if (NILP (args)) |
272 | 418 return Qnil; |
419 | |
420 args_left = args; | |
421 val = Qnil; | |
422 GCPRO2 (args, val); | |
423 | |
424 do | |
425 { | |
426 if (!(argnum++)) | |
427 val = Feval (Fcar (args_left)); | |
428 else | |
429 Feval (Fcar (args_left)); | |
430 args_left = Fcdr (args_left); | |
431 } | |
6803 | 432 while (!NILP (args_left)); |
272 | 433 |
434 UNGCPRO; | |
435 return val; | |
436 } | |
437 | |
438 DEFUN ("setq", Fsetq, Ssetq, 0, UNEVALLED, 0, | |
439 "(setq SYM VAL SYM VAL ...): set each SYM to the value of its VAL.\n\ | |
6918 | 440 The symbols SYM are variables; they are literal (not evaluated).\n\ |
441 The values VAL are expressions; they are evaluated.\n\ | |
442 Thus, (setq x (1+ y)) sets `x' to the value of `(1+ y)'.\n\ | |
443 The second VAL is not computed until after the first SYM is set, and so on;\n\ | |
444 each VAL can use the new value of variables set earlier in the `setq'.\n\ | |
6713 | 445 The return value of the `setq' form is the value of the last VAL.") |
272 | 446 (args) |
447 Lisp_Object args; | |
448 { | |
449 register Lisp_Object args_left; | |
450 register Lisp_Object val, sym; | |
451 struct gcpro gcpro1; | |
452 | |
485 | 453 if (NILP(args)) |
272 | 454 return Qnil; |
455 | |
456 args_left = args; | |
457 GCPRO1 (args); | |
458 | |
459 do | |
460 { | |
461 val = Feval (Fcar (Fcdr (args_left))); | |
462 sym = Fcar (args_left); | |
463 Fset (sym, val); | |
464 args_left = Fcdr (Fcdr (args_left)); | |
465 } | |
485 | 466 while (!NILP(args_left)); |
272 | 467 |
468 UNGCPRO; | |
469 return val; | |
470 } | |
471 | |
472 DEFUN ("quote", Fquote, Squote, 1, UNEVALLED, 0, | |
473 "Return the argument, without evaluating it. `(quote x)' yields `x'.") | |
474 (args) | |
475 Lisp_Object args; | |
476 { | |
477 return Fcar (args); | |
478 } | |
479 | |
480 DEFUN ("function", Ffunction, Sfunction, 1, UNEVALLED, 0, | |
481 "Like `quote', but preferred for objects which are functions.\n\ | |
482 In byte compilation, `function' causes its argument to be compiled.\n\ | |
483 `quote' cannot do that.") | |
484 (args) | |
485 Lisp_Object args; | |
486 { | |
487 return Fcar (args); | |
488 } | |
489 | |
490 DEFUN ("interactive-p", Finteractive_p, Sinteractive_p, 0, 0, 0, | |
491 "Return t if function in which this appears was called interactively.\n\ | |
492 This means that the function was called with call-interactively (which\n\ | |
493 includes being called as the binding of a key)\n\ | |
494 and input is currently coming from the keyboard (not in keyboard macro).") | |
495 () | |
496 { | |
497 register struct backtrace *btp; | |
498 register Lisp_Object fun; | |
499 | |
500 if (!INTERACTIVE) | |
501 return Qnil; | |
502 | |
503 btp = backtrace_list; | |
727 | 504 |
505 /* If this isn't a byte-compiled function, there may be a frame at | |
506 the top for Finteractive_p itself. If so, skip it. */ | |
507 fun = Findirect_function (*btp->function); | |
9959
c942c7e6ebbd
(Finteractive_p): Use XSUBR instead of its expansion.
Karl Heuer <kwzh@gnu.org>
parents:
9306
diff
changeset
|
508 if (SUBRP (fun) && XSUBR (fun) == &Sinteractive_p) |
323 | 509 btp = btp->next; |
510 | |
727 | 511 /* If we're running an Emacs 18-style byte-compiled function, there |
512 may be a frame for Fbytecode. Now, given the strictest | |
513 definition, this function isn't really being called | |
514 interactively, but because that's the way Emacs 18 always builds | |
515 byte-compiled functions, we'll accept it for now. */ | |
516 if (EQ (*btp->function, Qbytecode)) | |
517 btp = btp->next; | |
518 | |
519 /* If this isn't a byte-compiled function, then we may now be | |
520 looking at several frames for special forms. Skip past them. */ | |
521 while (btp && | |
522 btp->nargs == UNEVALLED) | |
523 btp = btp->next; | |
524 | |
525 /* btp now points at the frame of the innermost function that isn't | |
526 a special form, ignoring frames for Finteractive_p and/or | |
527 Fbytecode at the top. If this frame is for a built-in function | |
528 (such as load or eval-region) return nil. */ | |
648 | 529 fun = Findirect_function (*btp->function); |
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
530 if (SUBRP (fun)) |
272 | 531 return Qnil; |
532 /* btp points to the frame of a Lisp function that called interactive-p. | |
533 Return t if that function was called interactively. */ | |
534 if (btp && btp->next && EQ (*btp->next->function, Qcall_interactively)) | |
535 return Qt; | |
536 return Qnil; | |
537 } | |
538 | |
539 DEFUN ("defun", Fdefun, Sdefun, 2, UNEVALLED, 0, | |
540 "(defun NAME ARGLIST [DOCSTRING] BODY...): define NAME as a function.\n\ | |
541 The definition is (lambda ARGLIST [DOCSTRING] BODY...).\n\ | |
542 See also the function `interactive'.") | |
543 (args) | |
544 Lisp_Object args; | |
545 { | |
546 register Lisp_Object fn_name; | |
547 register Lisp_Object defn; | |
548 | |
549 fn_name = Fcar (args); | |
550 defn = Fcons (Qlambda, Fcdr (args)); | |
485 | 551 if (!NILP (Vpurify_flag)) |
272 | 552 defn = Fpurecopy (defn); |
553 Ffset (fn_name, defn); | |
2547
c73c68a87cd5
(defun, defmacro, defvar, defconst):
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
554 LOADHIST_ATTACH (fn_name); |
272 | 555 return fn_name; |
556 } | |
557 | |
558 DEFUN ("defmacro", Fdefmacro, Sdefmacro, 2, UNEVALLED, 0, | |
559 "(defmacro NAME ARGLIST [DOCSTRING] BODY...): define NAME as a macro.\n\ | |
560 The definition is (macro lambda ARGLIST [DOCSTRING] BODY...).\n\ | |
561 When the macro is called, as in (NAME ARGS...),\n\ | |
562 the function (lambda ARGLIST BODY...) is applied to\n\ | |
563 the list ARGS... as it appears in the expression,\n\ | |
564 and the result should be a form to be evaluated instead of the original.") | |
565 (args) | |
566 Lisp_Object args; | |
567 { | |
568 register Lisp_Object fn_name; | |
569 register Lisp_Object defn; | |
570 | |
571 fn_name = Fcar (args); | |
572 defn = Fcons (Qmacro, Fcons (Qlambda, Fcdr (args))); | |
485 | 573 if (!NILP (Vpurify_flag)) |
272 | 574 defn = Fpurecopy (defn); |
575 Ffset (fn_name, defn); | |
2547
c73c68a87cd5
(defun, defmacro, defvar, defconst):
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
576 LOADHIST_ATTACH (fn_name); |
272 | 577 return fn_name; |
578 } | |
579 | |
580 DEFUN ("defvar", Fdefvar, Sdefvar, 1, UNEVALLED, 0, | |
581 "(defvar SYMBOL INITVALUE DOCSTRING): define SYMBOL as a variable.\n\ | |
582 You are not required to define a variable in order to use it,\n\ | |
583 but the definition can supply documentation and an initial value\n\ | |
584 in a way that tags can recognize.\n\n\ | |
585 INITVALUE is evaluated, and used to set SYMBOL, only if SYMBOL's value is void.\n\ | |
687
e2b747dd6a6e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
684
diff
changeset
|
586 If SYMBOL is buffer-local, its default value is what is set;\n\ |
e2b747dd6a6e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
684
diff
changeset
|
587 buffer-local values are not affected.\n\ |
272 | 588 INITVALUE and DOCSTRING are optional.\n\ |
589 If DOCSTRING starts with *, this variable is identified as a user option.\n\ | |
590 This means that M-x set-variable and M-x edit-options recognize it.\n\ | |
591 If INITVALUE is missing, SYMBOL's value is not set.") | |
592 (args) | |
593 Lisp_Object args; | |
594 { | |
10161
512a84fb3c75
(Fdefconst, Fdefvar): Error if too many arguments.
Richard M. Stallman <rms@gnu.org>
parents:
9959
diff
changeset
|
595 register Lisp_Object sym, tem, tail; |
272 | 596 |
597 sym = Fcar (args); | |
10161
512a84fb3c75
(Fdefconst, Fdefvar): Error if too many arguments.
Richard M. Stallman <rms@gnu.org>
parents:
9959
diff
changeset
|
598 tail = Fcdr (args); |
512a84fb3c75
(Fdefconst, Fdefvar): Error if too many arguments.
Richard M. Stallman <rms@gnu.org>
parents:
9959
diff
changeset
|
599 if (!NILP (Fcdr (Fcdr (tail)))) |
512a84fb3c75
(Fdefconst, Fdefvar): Error if too many arguments.
Richard M. Stallman <rms@gnu.org>
parents:
9959
diff
changeset
|
600 error ("too many arguments"); |
512a84fb3c75
(Fdefconst, Fdefvar): Error if too many arguments.
Richard M. Stallman <rms@gnu.org>
parents:
9959
diff
changeset
|
601 |
512a84fb3c75
(Fdefconst, Fdefvar): Error if too many arguments.
Richard M. Stallman <rms@gnu.org>
parents:
9959
diff
changeset
|
602 if (!NILP (tail)) |
272 | 603 { |
604 tem = Fdefault_boundp (sym); | |
485 | 605 if (NILP (tem)) |
272 | 606 Fset_default (sym, Feval (Fcar (Fcdr (args)))); |
607 } | |
10161
512a84fb3c75
(Fdefconst, Fdefvar): Error if too many arguments.
Richard M. Stallman <rms@gnu.org>
parents:
9959
diff
changeset
|
608 tail = Fcdr (Fcdr (args)); |
512a84fb3c75
(Fdefconst, Fdefvar): Error if too many arguments.
Richard M. Stallman <rms@gnu.org>
parents:
9959
diff
changeset
|
609 if (!NILP (Fcar (tail))) |
272 | 610 { |
10201
03f3a1f4264a
(Fdefvar): Fix minor error in previous change.
Richard M. Stallman <rms@gnu.org>
parents:
10161
diff
changeset
|
611 tem = Fcar (tail); |
485 | 612 if (!NILP (Vpurify_flag)) |
272 | 613 tem = Fpurecopy (tem); |
614 Fput (sym, Qvariable_documentation, tem); | |
615 } | |
2547
c73c68a87cd5
(defun, defmacro, defvar, defconst):
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
616 LOADHIST_ATTACH (sym); |
272 | 617 return sym; |
618 } | |
619 | |
620 DEFUN ("defconst", Fdefconst, Sdefconst, 2, UNEVALLED, 0, | |
621 "(defconst SYMBOL INITVALUE DOCSTRING): define SYMBOL as a constant variable.\n\ | |
24427 | 622 The intent is that neither programs nor users should ever change this value.\n\ |
272 | 623 Always sets the value of SYMBOL to the result of evalling INITVALUE.\n\ |
687
e2b747dd6a6e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
684
diff
changeset
|
624 If SYMBOL is buffer-local, its default value is what is set;\n\ |
e2b747dd6a6e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
684
diff
changeset
|
625 buffer-local values are not affected.\n\ |
24391 | 626 DOCSTRING is optional.") |
272 | 627 (args) |
628 Lisp_Object args; | |
629 { | |
630 register Lisp_Object sym, tem; | |
631 | |
632 sym = Fcar (args); | |
10161
512a84fb3c75
(Fdefconst, Fdefvar): Error if too many arguments.
Richard M. Stallman <rms@gnu.org>
parents:
9959
diff
changeset
|
633 if (!NILP (Fcdr (Fcdr (Fcdr (args))))) |
512a84fb3c75
(Fdefconst, Fdefvar): Error if too many arguments.
Richard M. Stallman <rms@gnu.org>
parents:
9959
diff
changeset
|
634 error ("too many arguments"); |
512a84fb3c75
(Fdefconst, Fdefvar): Error if too many arguments.
Richard M. Stallman <rms@gnu.org>
parents:
9959
diff
changeset
|
635 |
272 | 636 Fset_default (sym, Feval (Fcar (Fcdr (args)))); |
637 tem = Fcar (Fcdr (Fcdr (args))); | |
485 | 638 if (!NILP (tem)) |
272 | 639 { |
485 | 640 if (!NILP (Vpurify_flag)) |
272 | 641 tem = Fpurecopy (tem); |
642 Fput (sym, Qvariable_documentation, tem); | |
643 } | |
2547
c73c68a87cd5
(defun, defmacro, defvar, defconst):
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
644 LOADHIST_ATTACH (sym); |
272 | 645 return sym; |
646 } | |
647 | |
648 DEFUN ("user-variable-p", Fuser_variable_p, Suser_variable_p, 1, 1, 0, | |
649 "Returns t if VARIABLE is intended to be set and modified by users.\n\ | |
650 \(The alternative is a variable used internally in a Lisp program.)\n\ | |
651 Determined by whether the first character of the documentation\n\ | |
11251
f6bc91242185
(Fuser_variable_p): For (STRING . INTEGER), test sign.
Richard M. Stallman <rms@gnu.org>
parents:
11205
diff
changeset
|
652 for the variable is `*'.") |
272 | 653 (variable) |
654 Lisp_Object variable; | |
655 { | |
656 Lisp_Object documentation; | |
657 | |
17275
03f89f7e614e
(Fuser_variable_p): If not a symbol, return nil.
Richard M. Stallman <rms@gnu.org>
parents:
17061
diff
changeset
|
658 if (!SYMBOLP (variable)) |
03f89f7e614e
(Fuser_variable_p): If not a symbol, return nil.
Richard M. Stallman <rms@gnu.org>
parents:
17061
diff
changeset
|
659 return Qnil; |
03f89f7e614e
(Fuser_variable_p): If not a symbol, return nil.
Richard M. Stallman <rms@gnu.org>
parents:
17061
diff
changeset
|
660 |
272 | 661 documentation = Fget (variable, Qvariable_documentation); |
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
662 if (INTEGERP (documentation) && XINT (documentation) < 0) |
272 | 663 return Qt; |
11251
f6bc91242185
(Fuser_variable_p): For (STRING . INTEGER), test sign.
Richard M. Stallman <rms@gnu.org>
parents:
11205
diff
changeset
|
664 if (STRINGP (documentation) |
f6bc91242185
(Fuser_variable_p): For (STRING . INTEGER), test sign.
Richard M. Stallman <rms@gnu.org>
parents:
11205
diff
changeset
|
665 && ((unsigned char) XSTRING (documentation)->data[0] == '*')) |
f6bc91242185
(Fuser_variable_p): For (STRING . INTEGER), test sign.
Richard M. Stallman <rms@gnu.org>
parents:
11205
diff
changeset
|
666 return Qt; |
f6bc91242185
(Fuser_variable_p): For (STRING . INTEGER), test sign.
Richard M. Stallman <rms@gnu.org>
parents:
11205
diff
changeset
|
667 /* If it is (STRING . INTEGER), a negative integer means a user variable. */ |
f6bc91242185
(Fuser_variable_p): For (STRING . INTEGER), test sign.
Richard M. Stallman <rms@gnu.org>
parents:
11205
diff
changeset
|
668 if (CONSP (documentation) |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
669 && STRINGP (XCAR (documentation)) |
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
670 && INTEGERP (XCDR (documentation)) |
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
671 && XINT (XCDR (documentation)) < 0) |
272 | 672 return Qt; |
673 return Qnil; | |
674 } | |
675 | |
676 DEFUN ("let*", FletX, SletX, 1, UNEVALLED, 0, | |
677 "(let* VARLIST BODY...): bind variables according to VARLIST then eval BODY.\n\ | |
678 The value of the last form in BODY is returned.\n\ | |
679 Each element of VARLIST is a symbol (which is bound to nil)\n\ | |
680 or a list (SYMBOL VALUEFORM) (which binds SYMBOL to the value of VALUEFORM).\n\ | |
681 Each VALUEFORM can refer to the symbols already bound by this VARLIST.") | |
682 (args) | |
683 Lisp_Object args; | |
684 { | |
685 Lisp_Object varlist, val, elt; | |
686 int count = specpdl_ptr - specpdl; | |
687 struct gcpro gcpro1, gcpro2, gcpro3; | |
688 | |
689 GCPRO3 (args, elt, varlist); | |
690 | |
691 varlist = Fcar (args); | |
485 | 692 while (!NILP (varlist)) |
272 | 693 { |
694 QUIT; | |
695 elt = Fcar (varlist); | |
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
696 if (SYMBOLP (elt)) |
272 | 697 specbind (elt, Qnil); |
604 | 698 else if (! NILP (Fcdr (Fcdr (elt)))) |
699 Fsignal (Qerror, | |
700 Fcons (build_string ("`let' bindings can have only one value-form"), | |
701 elt)); | |
272 | 702 else |
703 { | |
704 val = Feval (Fcar (Fcdr (elt))); | |
705 specbind (Fcar (elt), val); | |
706 } | |
707 varlist = Fcdr (varlist); | |
708 } | |
709 UNGCPRO; | |
710 val = Fprogn (Fcdr (args)); | |
711 return unbind_to (count, val); | |
712 } | |
713 | |
714 DEFUN ("let", Flet, Slet, 1, UNEVALLED, 0, | |
715 "(let VARLIST BODY...): bind variables according to VARLIST then eval BODY.\n\ | |
716 The value of the last form in BODY is returned.\n\ | |
717 Each element of VARLIST is a symbol (which is bound to nil)\n\ | |
718 or a list (SYMBOL VALUEFORM) (which binds SYMBOL to the value of VALUEFORM).\n\ | |
719 All the VALUEFORMs are evalled before any symbols are bound.") | |
720 (args) | |
721 Lisp_Object args; | |
722 { | |
723 Lisp_Object *temps, tem; | |
724 register Lisp_Object elt, varlist; | |
725 int count = specpdl_ptr - specpdl; | |
726 register int argnum; | |
727 struct gcpro gcpro1, gcpro2; | |
728 | |
729 varlist = Fcar (args); | |
730 | |
731 /* Make space to hold the values to give the bound variables */ | |
732 elt = Flength (varlist); | |
733 temps = (Lisp_Object *) alloca (XFASTINT (elt) * sizeof (Lisp_Object)); | |
734 | |
735 /* Compute the values and store them in `temps' */ | |
736 | |
737 GCPRO2 (args, *temps); | |
738 gcpro2.nvars = 0; | |
739 | |
485 | 740 for (argnum = 0; !NILP (varlist); varlist = Fcdr (varlist)) |
272 | 741 { |
742 QUIT; | |
743 elt = Fcar (varlist); | |
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
744 if (SYMBOLP (elt)) |
272 | 745 temps [argnum++] = Qnil; |
604 | 746 else if (! NILP (Fcdr (Fcdr (elt)))) |
747 Fsignal (Qerror, | |
748 Fcons (build_string ("`let' bindings can have only one value-form"), | |
749 elt)); | |
272 | 750 else |
751 temps [argnum++] = Feval (Fcar (Fcdr (elt))); | |
752 gcpro2.nvars = argnum; | |
753 } | |
754 UNGCPRO; | |
755 | |
756 varlist = Fcar (args); | |
485 | 757 for (argnum = 0; !NILP (varlist); varlist = Fcdr (varlist)) |
272 | 758 { |
759 elt = Fcar (varlist); | |
760 tem = temps[argnum++]; | |
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
761 if (SYMBOLP (elt)) |
272 | 762 specbind (elt, tem); |
763 else | |
764 specbind (Fcar (elt), tem); | |
765 } | |
766 | |
767 elt = Fprogn (Fcdr (args)); | |
768 return unbind_to (count, elt); | |
769 } | |
770 | |
771 DEFUN ("while", Fwhile, Swhile, 1, UNEVALLED, 0, | |
772 "(while TEST BODY...): if TEST yields non-nil, eval BODY... and repeat.\n\ | |
773 The order of execution is thus TEST, BODY, TEST, BODY and so on\n\ | |
774 until TEST returns nil.") | |
775 (args) | |
776 Lisp_Object args; | |
777 { | |
778 Lisp_Object test, body, tem; | |
779 struct gcpro gcpro1, gcpro2; | |
780 | |
781 GCPRO2 (test, body); | |
782 | |
783 test = Fcar (args); | |
784 body = Fcdr (args); | |
4167
f037b1f51320
(Fwhile): If mocklisp, test for nonzeroness.
Richard M. Stallman <rms@gnu.org>
parents:
3973
diff
changeset
|
785 while (tem = Feval (test), |
f037b1f51320
(Fwhile): If mocklisp, test for nonzeroness.
Richard M. Stallman <rms@gnu.org>
parents:
3973
diff
changeset
|
786 (!EQ (Vmocklisp_arguments, Qt) ? XINT (tem) : !NILP (tem))) |
272 | 787 { |
788 QUIT; | |
789 Fprogn (body); | |
790 } | |
791 | |
792 UNGCPRO; | |
793 return Qnil; | |
794 } | |
795 | |
796 DEFUN ("macroexpand", Fmacroexpand, Smacroexpand, 1, 2, 0, | |
797 "Return result of expanding macros at top level of FORM.\n\ | |
798 If FORM is not a macro call, it is returned unchanged.\n\ | |
799 Otherwise, the macro is expanded and the expansion is considered\n\ | |
800 in place of FORM. When a non-macro-call results, it is returned.\n\n\ | |
801 The second optional arg ENVIRONMENT species an environment of macro\n\ | |
802 definitions to shadow the loaded ones for use in file byte-compilation.") | |
14073
0df4b4f2a2a1
(Fmacroexpand, Fthrow, Fbacktrace_frame): Harmonize arguments with
Erik Naggum <erik@naggum.no>
parents:
13945
diff
changeset
|
803 (form, environment) |
16113
df832a303ce5
(Fmacroexpand): Don't declare `form' as register.
Richard M. Stallman <rms@gnu.org>
parents:
16108
diff
changeset
|
804 Lisp_Object form; |
14073
0df4b4f2a2a1
(Fmacroexpand, Fthrow, Fbacktrace_frame): Harmonize arguments with
Erik Naggum <erik@naggum.no>
parents:
13945
diff
changeset
|
805 Lisp_Object environment; |
272 | 806 { |
753 | 807 /* With cleanups from Hallvard Furuseth. */ |
272 | 808 register Lisp_Object expander, sym, def, tem; |
809 | |
810 while (1) | |
811 { | |
812 /* Come back here each time we expand a macro call, | |
813 in case it expands into another macro call. */ | |
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
814 if (!CONSP (form)) |
272 | 815 break; |
753 | 816 /* Set SYM, give DEF and TEM right values in case SYM is not a symbol. */ |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
817 def = sym = XCAR (form); |
753 | 818 tem = Qnil; |
272 | 819 /* Trace symbols aliases to other symbols |
820 until we get a symbol that is not an alias. */ | |
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
821 while (SYMBOLP (def)) |
272 | 822 { |
823 QUIT; | |
753 | 824 sym = def; |
14073
0df4b4f2a2a1
(Fmacroexpand, Fthrow, Fbacktrace_frame): Harmonize arguments with
Erik Naggum <erik@naggum.no>
parents:
13945
diff
changeset
|
825 tem = Fassq (sym, environment); |
485 | 826 if (NILP (tem)) |
272 | 827 { |
828 def = XSYMBOL (sym)->function; | |
753 | 829 if (!EQ (def, Qunbound)) |
830 continue; | |
272 | 831 } |
753 | 832 break; |
272 | 833 } |
14073
0df4b4f2a2a1
(Fmacroexpand, Fthrow, Fbacktrace_frame): Harmonize arguments with
Erik Naggum <erik@naggum.no>
parents:
13945
diff
changeset
|
834 /* Right now TEM is the result from SYM in ENVIRONMENT, |
272 | 835 and if TEM is nil then DEF is SYM's function definition. */ |
485 | 836 if (NILP (tem)) |
272 | 837 { |
14073
0df4b4f2a2a1
(Fmacroexpand, Fthrow, Fbacktrace_frame): Harmonize arguments with
Erik Naggum <erik@naggum.no>
parents:
13945
diff
changeset
|
838 /* SYM is not mentioned in ENVIRONMENT. |
272 | 839 Look at its function definition. */ |
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
840 if (EQ (def, Qunbound) || !CONSP (def)) |
272 | 841 /* Not defined or definition not suitable */ |
842 break; | |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
843 if (EQ (XCAR (def), Qautoload)) |
272 | 844 { |
845 /* Autoloading function: will it be a macro when loaded? */ | |
1564
b327816041d1
* eval.c (Fautoload): Renamed fifth argument TYPE. Document the
Jim Blandy <jimb@redhat.com>
parents:
1452
diff
changeset
|
846 tem = Fnth (make_number (4), def); |
5254
b38b74fe1722
(Fmacroexpand): For an autoload definition,
Richard M. Stallman <rms@gnu.org>
parents:
4782
diff
changeset
|
847 if (EQ (tem, Qt) || EQ (tem, Qmacro)) |
1564
b327816041d1
* eval.c (Fautoload): Renamed fifth argument TYPE. Document the
Jim Blandy <jimb@redhat.com>
parents:
1452
diff
changeset
|
848 /* Yes, load it and try again. */ |
b327816041d1
* eval.c (Fautoload): Renamed fifth argument TYPE. Document the
Jim Blandy <jimb@redhat.com>
parents:
1452
diff
changeset
|
849 { |
16108
2c9c0c867e00
(Fmacroexpand): gcpro form while calling do_autoload.
Richard M. Stallman <rms@gnu.org>
parents:
15275
diff
changeset
|
850 struct gcpro gcpro1; |
2c9c0c867e00
(Fmacroexpand): gcpro form while calling do_autoload.
Richard M. Stallman <rms@gnu.org>
parents:
15275
diff
changeset
|
851 GCPRO1 (form); |
1564
b327816041d1
* eval.c (Fautoload): Renamed fifth argument TYPE. Document the
Jim Blandy <jimb@redhat.com>
parents:
1452
diff
changeset
|
852 do_autoload (def, sym); |
16108
2c9c0c867e00
(Fmacroexpand): gcpro form while calling do_autoload.
Richard M. Stallman <rms@gnu.org>
parents:
15275
diff
changeset
|
853 UNGCPRO; |
1564
b327816041d1
* eval.c (Fautoload): Renamed fifth argument TYPE. Document the
Jim Blandy <jimb@redhat.com>
parents:
1452
diff
changeset
|
854 continue; |
b327816041d1
* eval.c (Fautoload): Renamed fifth argument TYPE. Document the
Jim Blandy <jimb@redhat.com>
parents:
1452
diff
changeset
|
855 } |
b327816041d1
* eval.c (Fautoload): Renamed fifth argument TYPE. Document the
Jim Blandy <jimb@redhat.com>
parents:
1452
diff
changeset
|
856 else |
272 | 857 break; |
858 } | |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
859 else if (!EQ (XCAR (def), Qmacro)) |
272 | 860 break; |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
861 else expander = XCDR (def); |
272 | 862 } |
863 else | |
864 { | |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
865 expander = XCDR (tem); |
485 | 866 if (NILP (expander)) |
272 | 867 break; |
868 } | |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
869 form = apply1 (expander, XCDR (form)); |
272 | 870 } |
871 return form; | |
872 } | |
873 | |
874 DEFUN ("catch", Fcatch, Scatch, 1, UNEVALLED, 0, | |
875 "(catch TAG BODY...): eval BODY allowing nonlocal exits using `throw'.\n\ | |
21589 | 876 TAG is evalled to get the tag to use; it must not be nil.\n\ |
877 \n\ | |
878 Then the BODY is executed.\n\ | |
272 | 879 Within BODY, (throw TAG) with same tag exits BODY and exits this `catch'.\n\ |
880 If no throw happens, `catch' returns the value of the last BODY form.\n\ | |
881 If a throw happens, it specifies the value to return from `catch'.") | |
882 (args) | |
883 Lisp_Object args; | |
884 { | |
885 register Lisp_Object tag; | |
886 struct gcpro gcpro1; | |
887 | |
888 GCPRO1 (args); | |
889 tag = Feval (Fcar (args)); | |
890 UNGCPRO; | |
891 return internal_catch (tag, Fprogn, Fcdr (args)); | |
892 } | |
893 | |
894 /* Set up a catch, then call C function FUNC on argument ARG. | |
895 FUNC should return a Lisp_Object. | |
896 This is how catches are done from within C code. */ | |
897 | |
898 Lisp_Object | |
899 internal_catch (tag, func, arg) | |
900 Lisp_Object tag; | |
901 Lisp_Object (*func) (); | |
902 Lisp_Object arg; | |
903 { | |
904 /* This structure is made part of the chain `catchlist'. */ | |
905 struct catchtag c; | |
906 | |
907 /* Fill in the components of c, and put it on the list. */ | |
908 c.next = catchlist; | |
909 c.tag = tag; | |
910 c.val = Qnil; | |
911 c.backlist = backtrace_list; | |
912 c.handlerlist = handlerlist; | |
913 c.lisp_eval_depth = lisp_eval_depth; | |
914 c.pdlcount = specpdl_ptr - specpdl; | |
915 c.poll_suppress_count = poll_suppress_count; | |
916 c.gcpro = gcprolist; | |
917 catchlist = &c; | |
918 | |
919 /* Call FUNC. */ | |
920 if (! _setjmp (c.jmp)) | |
921 c.val = (*func) (arg); | |
922 | |
923 /* Throw works by a longjmp that comes right here. */ | |
924 catchlist = c.next; | |
925 return c.val; | |
926 } | |
927 | |
1199
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
928 /* Unwind the specbind, catch, and handler stacks back to CATCH, and |
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
929 jump to that CATCH, returning VALUE as the value of that catch. |
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
930 |
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
931 This is the guts Fthrow and Fsignal; they differ only in the way |
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
932 they choose the catch tag to throw to. A catch tag for a |
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
933 condition-case form has a TAG of Qnil. |
272 | 934 |
1199
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
935 Before each catch is discarded, unbind all special bindings and |
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
936 execute all unwind-protect clauses made above that catch. Unwind |
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
937 the handler stack as we go, so that the proper handlers are in |
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
938 effect for each unwind-protect clause we run. At the end, restore |
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
939 some static info saved in CATCH, and longjmp to the location |
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
940 specified in the |
272 | 941 |
1199
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
942 This is used for correct unwinding in Fthrow and Fsignal. */ |
272 | 943 |
944 static void | |
1199
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
945 unwind_to_catch (catch, value) |
272 | 946 struct catchtag *catch; |
1199
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
947 Lisp_Object value; |
272 | 948 { |
949 register int last_time; | |
950 | |
1199
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
951 /* Save the value in the tag. */ |
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
952 catch->val = value; |
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
953 |
1196
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
954 /* Restore the polling-suppression count. */ |
4474
23d5b09bd218
(unwind_to_catch): Call set_poll_suppress_count.
Richard M. Stallman <rms@gnu.org>
parents:
4462
diff
changeset
|
955 set_poll_suppress_count (catch->poll_suppress_count); |
1196
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
956 |
272 | 957 do |
958 { | |
959 last_time = catchlist == catch; | |
1196
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
960 |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
961 /* Unwind the specpdl stack, and then restore the proper set of |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
962 handlers. */ |
272 | 963 unbind_to (catchlist->pdlcount, Qnil); |
964 handlerlist = catchlist->handlerlist; | |
965 catchlist = catchlist->next; | |
966 } | |
967 while (! last_time); | |
968 | |
969 gcprolist = catch->gcpro; | |
970 backtrace_list = catch->backlist; | |
971 lisp_eval_depth = catch->lisp_eval_depth; | |
1199
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
972 |
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
973 _longjmp (catch->jmp, 1); |
272 | 974 } |
975 | |
976 DEFUN ("throw", Fthrow, Sthrow, 2, 2, 0, | |
977 "(throw TAG VALUE): throw to the catch for TAG and return VALUE from it.\n\ | |
978 Both TAG and VALUE are evalled.") | |
14073
0df4b4f2a2a1
(Fmacroexpand, Fthrow, Fbacktrace_frame): Harmonize arguments with
Erik Naggum <erik@naggum.no>
parents:
13945
diff
changeset
|
979 (tag, value) |
0df4b4f2a2a1
(Fmacroexpand, Fthrow, Fbacktrace_frame): Harmonize arguments with
Erik Naggum <erik@naggum.no>
parents:
13945
diff
changeset
|
980 register Lisp_Object tag, value; |
272 | 981 { |
982 register struct catchtag *c; | |
983 | |
984 while (1) | |
985 { | |
485 | 986 if (!NILP (tag)) |
272 | 987 for (c = catchlist; c; c = c->next) |
988 { | |
989 if (EQ (c->tag, tag)) | |
14073
0df4b4f2a2a1
(Fmacroexpand, Fthrow, Fbacktrace_frame): Harmonize arguments with
Erik Naggum <erik@naggum.no>
parents:
13945
diff
changeset
|
990 unwind_to_catch (c, value); |
272 | 991 } |
14073
0df4b4f2a2a1
(Fmacroexpand, Fthrow, Fbacktrace_frame): Harmonize arguments with
Erik Naggum <erik@naggum.no>
parents:
13945
diff
changeset
|
992 tag = Fsignal (Qno_catch, Fcons (tag, Fcons (value, Qnil))); |
272 | 993 } |
994 } | |
995 | |
996 | |
997 DEFUN ("unwind-protect", Funwind_protect, Sunwind_protect, 1, UNEVALLED, 0, | |
998 "Do BODYFORM, protecting with UNWINDFORMS.\n\ | |
999 Usage looks like (unwind-protect BODYFORM UNWINDFORMS...).\n\ | |
1000 If BODYFORM completes normally, its value is returned\n\ | |
1001 after executing the UNWINDFORMS.\n\ | |
1002 If BODYFORM exits nonlocally, the UNWINDFORMS are executed anyway.") | |
1003 (args) | |
1004 Lisp_Object args; | |
1005 { | |
1006 Lisp_Object val; | |
1007 int count = specpdl_ptr - specpdl; | |
1008 | |
1009 record_unwind_protect (0, Fcdr (args)); | |
1010 val = Feval (Fcar (args)); | |
1011 return unbind_to (count, val); | |
1012 } | |
1013 | |
1014 /* Chain of condition handlers currently in effect. | |
1015 The elements of this chain are contained in the stack frames | |
1016 of Fcondition_case and internal_condition_case. | |
1017 When an error is signaled (by calling Fsignal, below), | |
1018 this chain is searched for an element that applies. */ | |
1019 | |
1020 struct handler *handlerlist; | |
1021 | |
1022 DEFUN ("condition-case", Fcondition_case, Scondition_case, 2, UNEVALLED, 0, | |
1023 "Regain control when an error is signaled.\n\ | |
1024 Usage looks like (condition-case VAR BODYFORM HANDLERS...).\n\ | |
1025 executes BODYFORM and returns its value if no error happens.\n\ | |
1026 Each element of HANDLERS looks like (CONDITION-NAME BODY...)\n\ | |
1027 where the BODY is made of Lisp expressions.\n\n\ | |
1028 A handler is applicable to an error\n\ | |
1029 if CONDITION-NAME is one of the error's condition names.\n\ | |
1030 If an error happens, the first applicable handler is run.\n\ | |
1031 \n\ | |
5567
c61f49e4283a
(Fcondition_case): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
5566
diff
changeset
|
1032 The car of a handler may be a list of condition names\n\ |
c61f49e4283a
(Fcondition_case): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
5566
diff
changeset
|
1033 instead of a single condition name.\n\ |
c61f49e4283a
(Fcondition_case): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
5566
diff
changeset
|
1034 \n\ |
272 | 1035 When a handler handles an error,\n\ |
1036 control returns to the condition-case and the handler BODY... is executed\n\ | |
1037 with VAR bound to (SIGNALED-CONDITIONS . SIGNAL-DATA).\n\ | |
1038 VAR may be nil; then you do not get access to the signal information.\n\ | |
1039 \n\ | |
1040 The value of the last BODY form is returned from the condition-case.\n\ | |
1041 See also the function `signal' for more info.") | |
1042 (args) | |
1043 Lisp_Object args; | |
1044 { | |
1045 Lisp_Object val; | |
1046 struct catchtag c; | |
1047 struct handler h; | |
1196
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1048 register Lisp_Object var, bodyform, handlers; |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1049 |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1050 var = Fcar (args); |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1051 bodyform = Fcar (Fcdr (args)); |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1052 handlers = Fcdr (Fcdr (args)); |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1053 CHECK_SYMBOL (var, 0); |
272 | 1054 |
1196
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1055 for (val = handlers; ! NILP (val); val = Fcdr (val)) |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1056 { |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1057 Lisp_Object tem; |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1058 tem = Fcar (val); |
5563
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1059 if (! (NILP (tem) |
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1060 || (CONSP (tem) |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
1061 && (SYMBOLP (XCAR (tem)) |
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
1062 || CONSP (XCAR (tem)))))) |
1196
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1063 error ("Invalid condition handler", tem); |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1064 } |
272 | 1065 |
1066 c.tag = Qnil; | |
1067 c.val = Qnil; | |
1068 c.backlist = backtrace_list; | |
1069 c.handlerlist = handlerlist; | |
1070 c.lisp_eval_depth = lisp_eval_depth; | |
1071 c.pdlcount = specpdl_ptr - specpdl; | |
1072 c.poll_suppress_count = poll_suppress_count; | |
1073 c.gcpro = gcprolist; | |
1074 if (_setjmp (c.jmp)) | |
1075 { | |
485 | 1076 if (!NILP (h.var)) |
6132
ddf57829cf03
(Fsignal): If DATA is memory_signal_data, don't add to it.
Richard M. Stallman <rms@gnu.org>
parents:
5807
diff
changeset
|
1077 specbind (h.var, c.val); |
ddf57829cf03
(Fsignal): If DATA is memory_signal_data, don't add to it.
Richard M. Stallman <rms@gnu.org>
parents:
5807
diff
changeset
|
1078 val = Fprogn (Fcdr (h.chosen_clause)); |
1196
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1079 |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1080 /* Note that this just undoes the binding of h.var; whoever |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1081 longjumped to us unwound the stack to c.pdlcount before |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1082 throwing. */ |
272 | 1083 unbind_to (c.pdlcount, Qnil); |
1084 return val; | |
1085 } | |
1086 c.next = catchlist; | |
1087 catchlist = &c; | |
1088 | |
1196
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1089 h.var = var; |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1090 h.handler = handlers; |
272 | 1091 h.next = handlerlist; |
1092 h.tag = &c; | |
1093 handlerlist = &h; | |
1094 | |
1196
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1095 val = Feval (bodyform); |
272 | 1096 catchlist = c.next; |
1097 handlerlist = h.next; | |
1098 return val; | |
1099 } | |
1100 | |
14218
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
1101 /* Call the function BFUN with no arguments, catching errors within it |
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
1102 according to HANDLERS. If there is an error, call HFUN with |
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
1103 one argument which is the data that describes the error: |
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
1104 (SIGNALNAME . DATA) |
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
1105 |
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
1106 HANDLERS can be a list of conditions to catch. |
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
1107 If HANDLERS is Qt, catch all errors. |
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
1108 If HANDLERS is Qerror, catch all errors |
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
1109 but allow the debugger to run if that is enabled. */ |
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
1110 |
272 | 1111 Lisp_Object |
1112 internal_condition_case (bfun, handlers, hfun) | |
1113 Lisp_Object (*bfun) (); | |
1114 Lisp_Object handlers; | |
1115 Lisp_Object (*hfun) (); | |
1116 { | |
1117 Lisp_Object val; | |
1118 struct catchtag c; | |
1119 struct handler h; | |
1120 | |
11365
1e2290c04cce
(internal_condition_case): Abort if interrupt_input_blocked>0.
Richard M. Stallman <rms@gnu.org>
parents:
11251
diff
changeset
|
1121 /* Since Fsignal resets this to 0, it had better be 0 now |
1e2290c04cce
(internal_condition_case): Abort if interrupt_input_blocked>0.
Richard M. Stallman <rms@gnu.org>
parents:
11251
diff
changeset
|
1122 or else we have a potential bug. */ |
1e2290c04cce
(internal_condition_case): Abort if interrupt_input_blocked>0.
Richard M. Stallman <rms@gnu.org>
parents:
11251
diff
changeset
|
1123 if (interrupt_input_blocked != 0) |
1e2290c04cce
(internal_condition_case): Abort if interrupt_input_blocked>0.
Richard M. Stallman <rms@gnu.org>
parents:
11251
diff
changeset
|
1124 abort (); |
1e2290c04cce
(internal_condition_case): Abort if interrupt_input_blocked>0.
Richard M. Stallman <rms@gnu.org>
parents:
11251
diff
changeset
|
1125 |
272 | 1126 c.tag = Qnil; |
1127 c.val = Qnil; | |
1128 c.backlist = backtrace_list; | |
1129 c.handlerlist = handlerlist; | |
1130 c.lisp_eval_depth = lisp_eval_depth; | |
1131 c.pdlcount = specpdl_ptr - specpdl; | |
1132 c.poll_suppress_count = poll_suppress_count; | |
1133 c.gcpro = gcprolist; | |
1134 if (_setjmp (c.jmp)) | |
1135 { | |
6132
ddf57829cf03
(Fsignal): If DATA is memory_signal_data, don't add to it.
Richard M. Stallman <rms@gnu.org>
parents:
5807
diff
changeset
|
1136 return (*hfun) (c.val); |
272 | 1137 } |
1138 c.next = catchlist; | |
1139 catchlist = &c; | |
1140 h.handler = handlers; | |
1141 h.var = Qnil; | |
1142 h.next = handlerlist; | |
1143 h.tag = &c; | |
1144 handlerlist = &h; | |
1145 | |
1146 val = (*bfun) (); | |
1147 catchlist = c.next; | |
1148 handlerlist = h.next; | |
1149 return val; | |
1150 } | |
1151 | |
14218
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
1152 /* Like internal_condition_case but call HFUN with ARG as its argument. */ |
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
1153 |
5807
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1154 Lisp_Object |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1155 internal_condition_case_1 (bfun, arg, handlers, hfun) |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1156 Lisp_Object (*bfun) (); |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1157 Lisp_Object arg; |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1158 Lisp_Object handlers; |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1159 Lisp_Object (*hfun) (); |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1160 { |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1161 Lisp_Object val; |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1162 struct catchtag c; |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1163 struct handler h; |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1164 |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1165 c.tag = Qnil; |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1166 c.val = Qnil; |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1167 c.backlist = backtrace_list; |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1168 c.handlerlist = handlerlist; |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1169 c.lisp_eval_depth = lisp_eval_depth; |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1170 c.pdlcount = specpdl_ptr - specpdl; |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1171 c.poll_suppress_count = poll_suppress_count; |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1172 c.gcpro = gcprolist; |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1173 if (_setjmp (c.jmp)) |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1174 { |
6132
ddf57829cf03
(Fsignal): If DATA is memory_signal_data, don't add to it.
Richard M. Stallman <rms@gnu.org>
parents:
5807
diff
changeset
|
1175 return (*hfun) (c.val); |
5807
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1176 } |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1177 c.next = catchlist; |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1178 catchlist = &c; |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1179 h.handler = handlers; |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1180 h.var = Qnil; |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1181 h.next = handlerlist; |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1182 h.tag = &c; |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1183 handlerlist = &h; |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1184 |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1185 val = (*bfun) (arg); |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1186 catchlist = c.next; |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1187 handlerlist = h.next; |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1188 return val; |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1189 } |
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1190 |
272 | 1191 static Lisp_Object find_handler_clause (); |
1192 | |
1193 DEFUN ("signal", Fsignal, Ssignal, 2, 2, 0, | |
5566
e2925466c923
(Fsignal): Rename 1st arg to error_symbol.
Richard M. Stallman <rms@gnu.org>
parents:
5563
diff
changeset
|
1194 "Signal an error. Args are ERROR-SYMBOL and associated DATA.\n\ |
272 | 1195 This function does not return.\n\n\ |
5566
e2925466c923
(Fsignal): Rename 1st arg to error_symbol.
Richard M. Stallman <rms@gnu.org>
parents:
5563
diff
changeset
|
1196 An error symbol is a symbol with an `error-conditions' property\n\ |
272 | 1197 that is a list of condition names.\n\ |
1198 A handler for any of those names will get to handle this signal.\n\ | |
1199 The symbol `error' should normally be one of them.\n\ | |
1200 \n\ | |
1201 DATA should be a list. Its elements are printed as part of the error message.\n\ | |
1202 If the signal is handled, DATA is made available to the handler.\n\ | |
1203 See also the function `condition-case'.") | |
5566
e2925466c923
(Fsignal): Rename 1st arg to error_symbol.
Richard M. Stallman <rms@gnu.org>
parents:
5563
diff
changeset
|
1204 (error_symbol, data) |
e2925466c923
(Fsignal): Rename 1st arg to error_symbol.
Richard M. Stallman <rms@gnu.org>
parents:
5563
diff
changeset
|
1205 Lisp_Object error_symbol, data; |
272 | 1206 { |
24171
44241f56675a
(Fsignal): Move comment to avoid confusing make-docfile.
Andreas Schwab <schwab@suse.de>
parents:
24054
diff
changeset
|
1207 /* When memory is full, ERROR-SYMBOL is nil, |
44241f56675a
(Fsignal): Move comment to avoid confusing make-docfile.
Andreas Schwab <schwab@suse.de>
parents:
24054
diff
changeset
|
1208 and DATA is (REAL-ERROR-SYMBOL . REAL-DATA). */ |
272 | 1209 register struct handler *allhandlers = handlerlist; |
1210 Lisp_Object conditions; | |
1211 extern int gc_in_progress; | |
1212 extern int waiting_for_input; | |
1213 Lisp_Object debugger_value; | |
16895
32945f27ed20
(Fsignal): Call fatal if no error handlers and no catch.
Richard M. Stallman <rms@gnu.org>
parents:
16485
diff
changeset
|
1214 Lisp_Object string; |
18636
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1215 Lisp_Object real_error_symbol; |
25008
39dd5c98a114
(Fsignal): Reset redisplaying_p to zero.
Gerd Moellmann <gerd@gnu.org>
parents:
24605
diff
changeset
|
1216 extern int display_busy_cursor_p; |
39dd5c98a114
(Fsignal): Reset redisplaying_p to zero.
Gerd Moellmann <gerd@gnu.org>
parents:
24605
diff
changeset
|
1217 |
272 | 1218 immediate_quit = 0; |
1219 if (gc_in_progress || waiting_for_input) | |
1220 abort (); | |
1221 | |
1222 TOTALLY_UNBLOCK_INPUT; | |
1223 | |
18636
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1224 if (NILP (error_symbol)) |
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1225 real_error_symbol = Fcar (data); |
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1226 else |
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1227 real_error_symbol = error_symbol; |
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1228 |
25008
39dd5c98a114
(Fsignal): Reset redisplaying_p to zero.
Gerd Moellmann <gerd@gnu.org>
parents:
24605
diff
changeset
|
1229 #ifdef HAVE_X_WINDOWS |
39dd5c98a114
(Fsignal): Reset redisplaying_p to zero.
Gerd Moellmann <gerd@gnu.org>
parents:
24605
diff
changeset
|
1230 if (display_busy_cursor_p) |
39dd5c98a114
(Fsignal): Reset redisplaying_p to zero.
Gerd Moellmann <gerd@gnu.org>
parents:
24605
diff
changeset
|
1231 Fx_hide_busy_cursor (Qt); |
39dd5c98a114
(Fsignal): Reset redisplaying_p to zero.
Gerd Moellmann <gerd@gnu.org>
parents:
24605
diff
changeset
|
1232 #endif |
39dd5c98a114
(Fsignal): Reset redisplaying_p to zero.
Gerd Moellmann <gerd@gnu.org>
parents:
24605
diff
changeset
|
1233 |
16355
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1234 /* This hook is used by edebug. */ |
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1235 if (! NILP (Vsignal_hook_function)) |
18018
2a11f1e4bd6b
(Fsignal): Use call2 to call Vsignal_hook_function.
Richard M. Stallman <rms@gnu.org>
parents:
17872
diff
changeset
|
1236 call2 (Vsignal_hook_function, error_symbol, data); |
16355
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1237 |
18636
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1238 conditions = Fget (real_error_symbol, Qerror_conditions); |
272 | 1239 |
1240 for (; handlerlist; handlerlist = handlerlist->next) | |
1241 { | |
1242 register Lisp_Object clause; | |
1243 clause = find_handler_clause (handlerlist->handler, conditions, | |
5566
e2925466c923
(Fsignal): Rename 1st arg to error_symbol.
Richard M. Stallman <rms@gnu.org>
parents:
5563
diff
changeset
|
1244 error_symbol, data, &debugger_value); |
272 | 1245 |
1246 #if 0 /* Most callers are not prepared to handle gc if this returns. | |
1247 So, since this feature is not very useful, take it out. */ | |
1248 /* If have called debugger and user wants to continue, | |
1249 just return nil. */ | |
1250 if (EQ (clause, Qlambda)) | |
1251 return debugger_value; | |
1252 #else | |
1253 if (EQ (clause, Qlambda)) | |
1196
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1254 { |
13945
6a653c300631
(syms_of_eval): Doc fix for inhibit-quit.
Karl Heuer <kwzh@gnu.org>
parents:
13768
diff
changeset
|
1255 /* We can't return values to code which signaled an error, but we |
6a653c300631
(syms_of_eval): Doc fix for inhibit-quit.
Karl Heuer <kwzh@gnu.org>
parents:
13768
diff
changeset
|
1256 can continue code which has signaled a quit. */ |
18636
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1257 if (EQ (real_error_symbol, Qquit)) |
1196
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1258 return Qnil; |
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1259 else |
3973
ab06b106c490
(Fsignal): Clarify error message.
Richard M. Stallman <rms@gnu.org>
parents:
3703
diff
changeset
|
1260 error ("Cannot return from the debugger in an error"); |
1196
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1261 } |
272 | 1262 #endif |
1263 | |
485 | 1264 if (!NILP (clause)) |
272 | 1265 { |
6132
ddf57829cf03
(Fsignal): If DATA is memory_signal_data, don't add to it.
Richard M. Stallman <rms@gnu.org>
parents:
5807
diff
changeset
|
1266 Lisp_Object unwind_data; |
272 | 1267 struct handler *h = handlerlist; |
6132
ddf57829cf03
(Fsignal): If DATA is memory_signal_data, don't add to it.
Richard M. Stallman <rms@gnu.org>
parents:
5807
diff
changeset
|
1268 |
272 | 1269 handlerlist = allhandlers; |
18636
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1270 |
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1271 if (NILP (error_symbol)) |
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1272 unwind_data = data; |
6132
ddf57829cf03
(Fsignal): If DATA is memory_signal_data, don't add to it.
Richard M. Stallman <rms@gnu.org>
parents:
5807
diff
changeset
|
1273 else |
ddf57829cf03
(Fsignal): If DATA is memory_signal_data, don't add to it.
Richard M. Stallman <rms@gnu.org>
parents:
5807
diff
changeset
|
1274 unwind_data = Fcons (error_symbol, data); |
ddf57829cf03
(Fsignal): If DATA is memory_signal_data, don't add to it.
Richard M. Stallman <rms@gnu.org>
parents:
5807
diff
changeset
|
1275 h->chosen_clause = clause; |
ddf57829cf03
(Fsignal): If DATA is memory_signal_data, don't add to it.
Richard M. Stallman <rms@gnu.org>
parents:
5807
diff
changeset
|
1276 unwind_to_catch (h->tag, unwind_data); |
272 | 1277 } |
1278 } | |
1279 | |
1280 handlerlist = allhandlers; | |
1281 /* If no handler is present now, try to run the debugger, | |
1282 and if that fails, throw to top level. */ | |
5566
e2925466c923
(Fsignal): Rename 1st arg to error_symbol.
Richard M. Stallman <rms@gnu.org>
parents:
5563
diff
changeset
|
1283 find_handler_clause (Qerror, conditions, error_symbol, data, &debugger_value); |
16895
32945f27ed20
(Fsignal): Call fatal if no error handlers and no catch.
Richard M. Stallman <rms@gnu.org>
parents:
16485
diff
changeset
|
1284 if (catchlist != 0) |
32945f27ed20
(Fsignal): Call fatal if no error handlers and no catch.
Richard M. Stallman <rms@gnu.org>
parents:
16485
diff
changeset
|
1285 Fthrow (Qtop_level, Qt); |
32945f27ed20
(Fsignal): Call fatal if no error handlers and no catch.
Richard M. Stallman <rms@gnu.org>
parents:
16485
diff
changeset
|
1286 |
18636
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1287 if (! NILP (error_symbol)) |
16895
32945f27ed20
(Fsignal): Call fatal if no error handlers and no catch.
Richard M. Stallman <rms@gnu.org>
parents:
16485
diff
changeset
|
1288 data = Fcons (error_symbol, data); |
32945f27ed20
(Fsignal): Call fatal if no error handlers and no catch.
Richard M. Stallman <rms@gnu.org>
parents:
16485
diff
changeset
|
1289 |
32945f27ed20
(Fsignal): Call fatal if no error handlers and no catch.
Richard M. Stallman <rms@gnu.org>
parents:
16485
diff
changeset
|
1290 string = Ferror_message_string (data); |
23578
a4b29402f761
(Fsignal): Use a separate format string when passing
Andreas Schwab <schwab@suse.de>
parents:
23206
diff
changeset
|
1291 fatal ("%s", XSTRING (string)->data, 0); |
272 | 1292 } |
1293 | |
684 | 1294 /* Return nonzero iff LIST is a non-nil atom or |
1295 a list containing one of CONDITIONS. */ | |
1296 | |
1297 static int | |
1298 wants_debugger (list, conditions) | |
1299 Lisp_Object list, conditions; | |
1300 { | |
706
86cb5db0b6c3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
687
diff
changeset
|
1301 if (NILP (list)) |
684 | 1302 return 0; |
1303 if (! CONSP (list)) | |
1304 return 1; | |
1305 | |
878
5b1c5b4286e7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
863
diff
changeset
|
1306 while (CONSP (conditions)) |
684 | 1307 { |
878
5b1c5b4286e7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
863
diff
changeset
|
1308 Lisp_Object this, tail; |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
1309 this = XCAR (conditions); |
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
1310 for (tail = list; CONSP (tail); tail = XCDR (tail)) |
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
1311 if (EQ (XCAR (tail), this)) |
684 | 1312 return 1; |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
1313 conditions = XCDR (conditions); |
684 | 1314 } |
878
5b1c5b4286e7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
863
diff
changeset
|
1315 return 0; |
684 | 1316 } |
1317 | |
13768 | 1318 /* Return 1 if an error with condition-symbols CONDITIONS, |
1319 and described by SIGNAL-DATA, should skip the debugger | |
1320 according to debugger-ignore-errors. */ | |
1321 | |
1322 static int | |
1323 skip_debugger (conditions, data) | |
1324 Lisp_Object conditions, data; | |
1325 { | |
1326 Lisp_Object tail; | |
1327 int first_string = 1; | |
1328 Lisp_Object error_message; | |
1329 | |
1330 for (tail = Vdebug_ignored_errors; CONSP (tail); | |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
1331 tail = XCDR (tail)) |
13768 | 1332 { |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
1333 if (STRINGP (XCAR (tail))) |
13768 | 1334 { |
1335 if (first_string) | |
1336 { | |
1337 error_message = Ferror_message_string (data); | |
1338 first_string = 0; | |
1339 } | |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
1340 if (fast_string_match (XCAR (tail), error_message) >= 0) |
13768 | 1341 return 1; |
1342 } | |
1343 else | |
1344 { | |
1345 Lisp_Object contail; | |
1346 | |
1347 for (contail = conditions; CONSP (contail); | |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
1348 contail = XCDR (contail)) |
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
1349 if (EQ (XCAR (tail), XCAR (contail))) |
13768 | 1350 return 1; |
1351 } | |
1352 } | |
1353 | |
1354 return 0; | |
1355 } | |
1356 | |
684 | 1357 /* Value of Qlambda means we have called debugger and user has continued. |
18636
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1358 There are two ways to pass SIG and DATA: |
24054
19ff7845d5f7
(find_handler_clause): If SIG is nil (memory full error),
Richard M. Stallman <rms@gnu.org>
parents:
23578
diff
changeset
|
1359 = SIG is the error symbol, and DATA is the rest of the data. |
18636
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1360 = SIG is nil, and DATA is (SYMBOL . REST-OF-DATA). |
24054
19ff7845d5f7
(find_handler_clause): If SIG is nil (memory full error),
Richard M. Stallman <rms@gnu.org>
parents:
23578
diff
changeset
|
1361 This is for memory-full errors only. |
18636
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1362 |
684 | 1363 Store value returned from debugger into *DEBUGGER_VALUE_PTR. */ |
272 | 1364 |
1365 static Lisp_Object | |
1366 find_handler_clause (handlers, conditions, sig, data, debugger_value_ptr) | |
1367 Lisp_Object handlers, conditions, sig, data; | |
1368 Lisp_Object *debugger_value_ptr; | |
1369 { | |
1370 register Lisp_Object h; | |
1371 register Lisp_Object tem; | |
1372 | |
1373 if (EQ (handlers, Qt)) /* t is used by handlers for all conditions, set up by C code. */ | |
1374 return Qt; | |
16355
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1375 /* error is used similarly, but means print an error message |
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1376 and run the debugger if that is enabled. */ |
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1377 if (EQ (handlers, Qerror) |
16443
0128b923d281
(Vdebug_on_signal): Renamed from Vdebug_force.
Richard M. Stallman <rms@gnu.org>
parents:
16355
diff
changeset
|
1378 || !NILP (Vdebug_on_signal)) /* This says call debugger even if |
0128b923d281
(Vdebug_on_signal): Renamed from Vdebug_force.
Richard M. Stallman <rms@gnu.org>
parents:
16355
diff
changeset
|
1379 there is a handler. */ |
272 | 1380 { |
16355
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1381 int count = specpdl_ptr - specpdl; |
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1382 int debugger_called = 0; |
18636
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1383 Lisp_Object sig_symbol, combined_data; |
24054
19ff7845d5f7
(find_handler_clause): If SIG is nil (memory full error),
Richard M. Stallman <rms@gnu.org>
parents:
23578
diff
changeset
|
1384 /* This is set to 1 if we are handling a memory-full error, |
19ff7845d5f7
(find_handler_clause): If SIG is nil (memory full error),
Richard M. Stallman <rms@gnu.org>
parents:
23578
diff
changeset
|
1385 because these must not run the debugger. |
19ff7845d5f7
(find_handler_clause): If SIG is nil (memory full error),
Richard M. Stallman <rms@gnu.org>
parents:
23578
diff
changeset
|
1386 (There is no room in memory to do that!) */ |
19ff7845d5f7
(find_handler_clause): If SIG is nil (memory full error),
Richard M. Stallman <rms@gnu.org>
parents:
23578
diff
changeset
|
1387 int no_debugger = 0; |
18636
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1388 |
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1389 if (NILP (sig)) |
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1390 { |
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1391 combined_data = data; |
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1392 sig_symbol = Fcar (data); |
24054
19ff7845d5f7
(find_handler_clause): If SIG is nil (memory full error),
Richard M. Stallman <rms@gnu.org>
parents:
23578
diff
changeset
|
1393 no_debugger = 1; |
18636
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1394 } |
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1395 else |
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1396 { |
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1397 combined_data = Fcons (sig, data); |
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1398 sig_symbol = sig; |
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1399 } |
16355
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1400 |
684 | 1401 if (wants_debugger (Vstack_trace_on_error, conditions)) |
21853
6e93713b7d30
(find_handler_clause): Cast Fbacktrace to proper type.
Richard M. Stallman <rms@gnu.org>
parents:
21699
diff
changeset
|
1402 { |
6e93713b7d30
(find_handler_clause): Cast Fbacktrace to proper type.
Richard M. Stallman <rms@gnu.org>
parents:
21699
diff
changeset
|
1403 #ifdef __STDC__ |
6e93713b7d30
(find_handler_clause): Cast Fbacktrace to proper type.
Richard M. Stallman <rms@gnu.org>
parents:
21699
diff
changeset
|
1404 internal_with_output_to_temp_buffer ("*Backtrace*", |
6e93713b7d30
(find_handler_clause): Cast Fbacktrace to proper type.
Richard M. Stallman <rms@gnu.org>
parents:
21699
diff
changeset
|
1405 (Lisp_Object (*) (Lisp_Object)) Fbacktrace, |
6e93713b7d30
(find_handler_clause): Cast Fbacktrace to proper type.
Richard M. Stallman <rms@gnu.org>
parents:
21699
diff
changeset
|
1406 Qnil); |
6e93713b7d30
(find_handler_clause): Cast Fbacktrace to proper type.
Richard M. Stallman <rms@gnu.org>
parents:
21699
diff
changeset
|
1407 #else |
6e93713b7d30
(find_handler_clause): Cast Fbacktrace to proper type.
Richard M. Stallman <rms@gnu.org>
parents:
21699
diff
changeset
|
1408 internal_with_output_to_temp_buffer ("*Backtrace*", |
6e93713b7d30
(find_handler_clause): Cast Fbacktrace to proper type.
Richard M. Stallman <rms@gnu.org>
parents:
21699
diff
changeset
|
1409 Fbacktrace, Qnil); |
6e93713b7d30
(find_handler_clause): Cast Fbacktrace to proper type.
Richard M. Stallman <rms@gnu.org>
parents:
21699
diff
changeset
|
1410 #endif |
6e93713b7d30
(find_handler_clause): Cast Fbacktrace to proper type.
Richard M. Stallman <rms@gnu.org>
parents:
21699
diff
changeset
|
1411 } |
24054
19ff7845d5f7
(find_handler_clause): If SIG is nil (memory full error),
Richard M. Stallman <rms@gnu.org>
parents:
23578
diff
changeset
|
1412 if (! no_debugger |
19ff7845d5f7
(find_handler_clause): If SIG is nil (memory full error),
Richard M. Stallman <rms@gnu.org>
parents:
23578
diff
changeset
|
1413 && (EQ (sig_symbol, Qquit) |
19ff7845d5f7
(find_handler_clause): If SIG is nil (memory full error),
Richard M. Stallman <rms@gnu.org>
parents:
23578
diff
changeset
|
1414 ? debug_on_quit |
19ff7845d5f7
(find_handler_clause): If SIG is nil (memory full error),
Richard M. Stallman <rms@gnu.org>
parents:
23578
diff
changeset
|
1415 : wants_debugger (Vdebug_on_error, conditions)) |
18636
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1416 && ! skip_debugger (conditions, combined_data) |
17872
31b2c6763574
(num_nonmacro_input_events):
Richard M. Stallman <rms@gnu.org>
parents:
17275
diff
changeset
|
1417 && when_entered_debugger < num_nonmacro_input_events) |
272 | 1418 { |
1419 specbind (Qdebug_on_error, Qnil); | |
13768 | 1420 *debugger_value_ptr |
1421 = call_debugger (Fcons (Qerror, | |
18636
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1422 Fcons (combined_data, Qnil))); |
16355
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1423 debugger_called = 1; |
272 | 1424 } |
16355
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1425 /* If there is no handler, return saying whether we ran the debugger. */ |
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1426 if (EQ (handlers, Qerror)) |
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1427 { |
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1428 if (debugger_called) |
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1429 return unbind_to (count, Qlambda); |
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1430 return Qt; |
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1431 } |
272 | 1432 } |
1433 for (h = handlers; CONSP (h); h = Fcdr (h)) | |
1434 { | |
5563
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1435 Lisp_Object handler, condit; |
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1436 |
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1437 handler = Fcar (h); |
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1438 if (!CONSP (handler)) |
272 | 1439 continue; |
5563
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1440 condit = Fcar (handler); |
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1441 /* Handle a single condition name in handler HANDLER. */ |
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1442 if (SYMBOLP (condit)) |
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1443 { |
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1444 tem = Fmemq (Fcar (handler), conditions); |
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1445 if (!NILP (tem)) |
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1446 return handler; |
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1447 } |
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1448 /* Handle a list of condition names in handler HANDLER. */ |
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1449 else if (CONSP (condit)) |
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1450 { |
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1451 while (CONSP (condit)) |
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1452 { |
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1453 tem = Fmemq (Fcar (condit), conditions); |
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1454 if (!NILP (tem)) |
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1455 return handler; |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
1456 condit = XCDR (condit); |
5563
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1457 } |
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1458 } |
272 | 1459 } |
1460 return Qnil; | |
1461 } | |
1462 | |
1463 /* dump an error message; called like printf */ | |
1464 | |
1465 /* VARARGS 1 */ | |
1466 void | |
1467 error (m, a1, a2, a3) | |
1468 char *m; | |
6225
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1469 char *a1, *a2, *a3; |
272 | 1470 { |
1471 char buf[200]; | |
6225
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1472 int size = 200; |
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1473 int mlen; |
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1474 char *buffer = buf; |
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1475 char *args[3]; |
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1476 int allocated = 0; |
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1477 Lisp_Object string; |
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1478 |
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1479 args[0] = a1; |
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1480 args[1] = a2; |
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1481 args[2] = a3; |
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1482 |
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1483 mlen = strlen (m); |
272 | 1484 |
1485 while (1) | |
6225
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1486 { |
23206
a9090a71e969
(error): After enlarging buffer, write to it, not to buf.
Karl Heuer <kwzh@gnu.org>
parents:
21853
diff
changeset
|
1487 int used = doprnt (buffer, size, m, m + mlen, 3, args); |
6225
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1488 if (used < size) |
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1489 break; |
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1490 size *= 2; |
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1491 if (allocated) |
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1492 buffer = (char *) xrealloc (buffer, size); |
7353
334cececa42d
(error): Fix logic in call to xmalloc/xrealloc.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
1493 else |
334cececa42d
(error): Fix logic in call to xmalloc/xrealloc.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
1494 { |
334cececa42d
(error): Fix logic in call to xmalloc/xrealloc.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
1495 buffer = (char *) xmalloc (size); |
334cececa42d
(error): Fix logic in call to xmalloc/xrealloc.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
1496 allocated = 1; |
334cececa42d
(error): Fix logic in call to xmalloc/xrealloc.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
1497 } |
6225
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1498 } |
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1499 |
23206
a9090a71e969
(error): After enlarging buffer, write to it, not to buf.
Karl Heuer <kwzh@gnu.org>
parents:
21853
diff
changeset
|
1500 string = build_string (buffer); |
6225
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1501 if (allocated) |
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1502 free (buffer); |
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1503 |
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1504 Fsignal (Qerror, Fcons (string, Qnil)); |
272 | 1505 } |
1506 | |
1507 DEFUN ("commandp", Fcommandp, Scommandp, 1, 1, 0, | |
1508 "T if FUNCTION makes provisions for interactive calling.\n\ | |
1509 This means it contains a description for how to read arguments to give it.\n\ | |
1510 The value is nil for an invalid function or a symbol with no function\n\ | |
1511 definition.\n\ | |
1512 \n\ | |
1513 Interactively callable functions include strings and vectors (treated\n\ | |
1514 as keyboard macros), lambda-expressions that contain a top-level call\n\ | |
1515 to `interactive', autoload definitions made by `autoload' with non-nil\n\ | |
1516 fourth argument, and some of the built-in functions of Lisp.\n\ | |
1517 \n\ | |
1518 Also, a symbol satisfies `commandp' if its function definition does so.") | |
1519 (function) | |
1520 Lisp_Object function; | |
1521 { | |
1522 register Lisp_Object fun; | |
1523 register Lisp_Object funcar; | |
1524 | |
1525 fun = function; | |
1526 | |
648 | 1527 fun = indirect_function (fun); |
1528 if (EQ (fun, Qunbound)) | |
1529 return Qnil; | |
272 | 1530 |
1531 /* Emacs primitives are interactive if their DEFUN specifies an | |
1532 interactive spec. */ | |
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
1533 if (SUBRP (fun)) |
272 | 1534 { |
1535 if (XSUBR (fun)->prompt) | |
1536 return Qt; | |
1537 else | |
1538 return Qnil; | |
1539 } | |
1540 | |
1541 /* Bytecode objects are interactive if they are long enough to | |
1542 have an element whose index is COMPILED_INTERACTIVE, which is | |
1543 where the interactive spec is stored. */ | |
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
1544 else if (COMPILEDP (fun)) |
10345 | 1545 return ((XVECTOR (fun)->size & PSEUDOVECTOR_SIZE_MASK) > COMPILED_INTERACTIVE |
272 | 1546 ? Qt : Qnil); |
1547 | |
1548 /* Strings and vectors are keyboard macros. */ | |
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
1549 if (STRINGP (fun) || VECTORP (fun)) |
272 | 1550 return Qt; |
1551 | |
1552 /* Lists may represent commands. */ | |
1553 if (!CONSP (fun)) | |
1554 return Qnil; | |
1555 funcar = Fcar (fun); | |
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
1556 if (!SYMBOLP (funcar)) |
272 | 1557 return Fsignal (Qinvalid_function, Fcons (fun, Qnil)); |
1558 if (EQ (funcar, Qlambda)) | |
1559 return Fassq (Qinteractive, Fcdr (Fcdr (fun))); | |
1560 if (EQ (funcar, Qmocklisp)) | |
1561 return Qt; /* All mocklisp functions can be called interactively */ | |
1562 if (EQ (funcar, Qautoload)) | |
1563 return Fcar (Fcdr (Fcdr (Fcdr (fun)))); | |
1564 else | |
1565 return Qnil; | |
1566 } | |
1567 | |
1568 /* ARGSUSED */ | |
1569 DEFUN ("autoload", Fautoload, Sautoload, 2, 5, 0, | |
1570 "Define FUNCTION to autoload from FILE.\n\ | |
1571 FUNCTION is a symbol; FILE is a file name string to pass to `load'.\n\ | |
1572 Third arg DOCSTRING is documentation for the function.\n\ | |
1573 Fourth arg INTERACTIVE if non-nil says function can be called interactively.\n\ | |
1564
b327816041d1
* eval.c (Fautoload): Renamed fifth argument TYPE. Document the
Jim Blandy <jimb@redhat.com>
parents:
1452
diff
changeset
|
1574 Fifth arg TYPE indicates the type of the object:\n\ |
b327816041d1
* eval.c (Fautoload): Renamed fifth argument TYPE. Document the
Jim Blandy <jimb@redhat.com>
parents:
1452
diff
changeset
|
1575 nil or omitted says FUNCTION is a function,\n\ |
b327816041d1
* eval.c (Fautoload): Renamed fifth argument TYPE. Document the
Jim Blandy <jimb@redhat.com>
parents:
1452
diff
changeset
|
1576 `keymap' says FUNCTION is really a keymap, and\n\ |
b327816041d1
* eval.c (Fautoload): Renamed fifth argument TYPE. Document the
Jim Blandy <jimb@redhat.com>
parents:
1452
diff
changeset
|
1577 `macro' or t says FUNCTION is really a macro.\n\ |
272 | 1578 Third through fifth args give info about the real definition.\n\ |
1579 They default to nil.\n\ | |
1580 If FUNCTION is already defined other than as an autoload,\n\ | |
1581 this does nothing and returns nil.") | |
1564
b327816041d1
* eval.c (Fautoload): Renamed fifth argument TYPE. Document the
Jim Blandy <jimb@redhat.com>
parents:
1452
diff
changeset
|
1582 (function, file, docstring, interactive, type) |
b327816041d1
* eval.c (Fautoload): Renamed fifth argument TYPE. Document the
Jim Blandy <jimb@redhat.com>
parents:
1452
diff
changeset
|
1583 Lisp_Object function, file, docstring, interactive, type; |
272 | 1584 { |
1585 #ifdef NO_ARG_ARRAY | |
1586 Lisp_Object args[4]; | |
1587 #endif | |
1588 | |
1589 CHECK_SYMBOL (function, 0); | |
1590 CHECK_STRING (file, 1); | |
1591 | |
1592 /* If function is defined and not as an autoload, don't override */ | |
1593 if (!EQ (XSYMBOL (function)->function, Qunbound) | |
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
1594 && !(CONSP (XSYMBOL (function)->function) |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
1595 && EQ (XCAR (XSYMBOL (function)->function), Qautoload))) |
272 | 1596 return Qnil; |
1597 | |
1598 #ifdef NO_ARG_ARRAY | |
1599 args[0] = file; | |
1600 args[1] = docstring; | |
1601 args[2] = interactive; | |
1564
b327816041d1
* eval.c (Fautoload): Renamed fifth argument TYPE. Document the
Jim Blandy <jimb@redhat.com>
parents:
1452
diff
changeset
|
1602 args[3] = type; |
272 | 1603 |
1604 return Ffset (function, Fcons (Qautoload, Flist (4, &args[0]))); | |
1605 #else /* NO_ARG_ARRAY */ | |
1606 return Ffset (function, Fcons (Qautoload, Flist (4, &file))); | |
1607 #endif /* not NO_ARG_ARRAY */ | |
1608 } | |
1609 | |
1610 Lisp_Object | |
1611 un_autoload (oldqueue) | |
1612 Lisp_Object oldqueue; | |
1613 { | |
1614 register Lisp_Object queue, first, second; | |
1615 | |
1616 /* Queue to unwind is current value of Vautoload_queue. | |
1617 oldqueue is the shadowed value to leave in Vautoload_queue. */ | |
1618 queue = Vautoload_queue; | |
1619 Vautoload_queue = oldqueue; | |
1620 while (CONSP (queue)) | |
1621 { | |
1622 first = Fcar (queue); | |
1623 second = Fcdr (first); | |
1624 first = Fcar (first); | |
1625 if (EQ (second, Qnil)) | |
1626 Vfeatures = first; | |
1627 else | |
1628 Ffset (first, second); | |
1629 queue = Fcdr (queue); | |
1630 } | |
1631 return Qnil; | |
1632 } | |
1633 | |
16108
2c9c0c867e00
(Fmacroexpand): gcpro form while calling do_autoload.
Richard M. Stallman <rms@gnu.org>
parents:
15275
diff
changeset
|
1634 /* Load an autoloaded function. |
2c9c0c867e00
(Fmacroexpand): gcpro form while calling do_autoload.
Richard M. Stallman <rms@gnu.org>
parents:
15275
diff
changeset
|
1635 FUNNAME is the symbol which is the function's name. |
2c9c0c867e00
(Fmacroexpand): gcpro form while calling do_autoload.
Richard M. Stallman <rms@gnu.org>
parents:
15275
diff
changeset
|
1636 FUNDEF is the autoload definition (a list). */ |
2c9c0c867e00
(Fmacroexpand): gcpro form while calling do_autoload.
Richard M. Stallman <rms@gnu.org>
parents:
15275
diff
changeset
|
1637 |
20378
cf1b52f5c34a
(do_autoload): Return void.
Andreas Schwab <schwab@suse.de>
parents:
20312
diff
changeset
|
1638 void |
272 | 1639 do_autoload (fundef, funname) |
1640 Lisp_Object fundef, funname; | |
1641 { | |
1642 int count = specpdl_ptr - specpdl; | |
25783
17eb5827f07b
(Fsignal): Remove unused variables.
Gerd Moellmann <gerd@gnu.org>
parents:
25662
diff
changeset
|
1643 Lisp_Object fun, queue, first, second; |
16108
2c9c0c867e00
(Fmacroexpand): gcpro form while calling do_autoload.
Richard M. Stallman <rms@gnu.org>
parents:
15275
diff
changeset
|
1644 struct gcpro gcpro1, gcpro2, gcpro3; |
272 | 1645 |
1646 fun = funname; | |
1647 CHECK_SYMBOL (funname, 0); | |
16108
2c9c0c867e00
(Fmacroexpand): gcpro form while calling do_autoload.
Richard M. Stallman <rms@gnu.org>
parents:
15275
diff
changeset
|
1648 GCPRO3 (fun, funname, fundef); |
272 | 1649 |
24605
f378efa4aa8a
(do_autoload): Preserve match data.
Richard M. Stallman <rms@gnu.org>
parents:
24427
diff
changeset
|
1650 /* Preserve the match data. */ |
f378efa4aa8a
(do_autoload): Preserve match data.
Richard M. Stallman <rms@gnu.org>
parents:
24427
diff
changeset
|
1651 record_unwind_protect (Fset_match_data, Fmatch_data (Qnil, Qnil)); |
f378efa4aa8a
(do_autoload): Preserve match data.
Richard M. Stallman <rms@gnu.org>
parents:
24427
diff
changeset
|
1652 |
f378efa4aa8a
(do_autoload): Preserve match data.
Richard M. Stallman <rms@gnu.org>
parents:
24427
diff
changeset
|
1653 /* Value saved here is to be restored into Vautoload_queue. */ |
272 | 1654 record_unwind_protect (un_autoload, Vautoload_queue); |
1655 Vautoload_queue = Qt; | |
19237
42cc2b7bc6c6
(do_autoload): Require a suffix for the file.
Richard M. Stallman <rms@gnu.org>
parents:
19116
diff
changeset
|
1656 Fload (Fcar (Fcdr (fundef)), Qnil, noninteractive ? Qt : Qnil, Qnil, Qt); |
2547
c73c68a87cd5
(defun, defmacro, defvar, defconst):
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1657 |
24605
f378efa4aa8a
(do_autoload): Preserve match data.
Richard M. Stallman <rms@gnu.org>
parents:
24427
diff
changeset
|
1658 /* Save the old autoloads, in case we ever do an unload. */ |
2547
c73c68a87cd5
(defun, defmacro, defvar, defconst):
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1659 queue = Vautoload_queue; |
c73c68a87cd5
(defun, defmacro, defvar, defconst):
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1660 while (CONSP (queue)) |
c73c68a87cd5
(defun, defmacro, defvar, defconst):
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1661 { |
c73c68a87cd5
(defun, defmacro, defvar, defconst):
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1662 first = Fcar (queue); |
c73c68a87cd5
(defun, defmacro, defvar, defconst):
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1663 second = Fcdr (first); |
c73c68a87cd5
(defun, defmacro, defvar, defconst):
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1664 first = Fcar (first); |
2599
5122736c0a03
(do_autoload): Fixed the bug in the autoload-saving code.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2596
diff
changeset
|
1665 |
5122736c0a03
(do_autoload): Fixed the bug in the autoload-saving code.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2596
diff
changeset
|
1666 /* Note: This test is subtle. The cdr of an autoload-queue entry |
5122736c0a03
(do_autoload): Fixed the bug in the autoload-saving code.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2596
diff
changeset
|
1667 may be an atom if the autoload entry was generated by a defalias |
24605
f378efa4aa8a
(do_autoload): Preserve match data.
Richard M. Stallman <rms@gnu.org>
parents:
24427
diff
changeset
|
1668 or fset. */ |
2599
5122736c0a03
(do_autoload): Fixed the bug in the autoload-saving code.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2596
diff
changeset
|
1669 if (CONSP (second)) |
4782 | 1670 Fput (first, Qautoload, (Fcdr (second))); |
2599
5122736c0a03
(do_autoload): Fixed the bug in the autoload-saving code.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2596
diff
changeset
|
1671 |
2547
c73c68a87cd5
(defun, defmacro, defvar, defconst):
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1672 queue = Fcdr (queue); |
c73c68a87cd5
(defun, defmacro, defvar, defconst):
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1673 } |
c73c68a87cd5
(defun, defmacro, defvar, defconst):
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1674 |
272 | 1675 /* Once loading finishes, don't undo it. */ |
1676 Vautoload_queue = Qt; | |
1677 unbind_to (count, Qnil); | |
1678 | |
648 | 1679 fun = Findirect_function (fun); |
1680 | |
4462
9fbc6c74cab5
(do_autoload): Don't report autoload failure
Richard M. Stallman <rms@gnu.org>
parents:
4167
diff
changeset
|
1681 if (!NILP (Fequal (fun, fundef))) |
272 | 1682 error ("Autoloading failed to define function %s", |
1683 XSYMBOL (funname)->name->data); | |
16108
2c9c0c867e00
(Fmacroexpand): gcpro form while calling do_autoload.
Richard M. Stallman <rms@gnu.org>
parents:
15275
diff
changeset
|
1684 UNGCPRO; |
272 | 1685 } |
1686 | |
1687 DEFUN ("eval", Feval, Seval, 1, 1, 0, | |
1688 "Evaluate FORM and return its value.") | |
1689 (form) | |
1690 Lisp_Object form; | |
1691 { | |
1692 Lisp_Object fun, val, original_fun, original_args; | |
1693 Lisp_Object funcar; | |
1694 struct backtrace backtrace; | |
1695 struct gcpro gcpro1, gcpro2, gcpro3; | |
1696 | |
25008
39dd5c98a114
(Fsignal): Reset redisplaying_p to zero.
Gerd Moellmann <gerd@gnu.org>
parents:
24605
diff
changeset
|
1697 /* Since Fsignal resets this to 0, it had better be 0 now |
39dd5c98a114
(Fsignal): Reset redisplaying_p to zero.
Gerd Moellmann <gerd@gnu.org>
parents:
24605
diff
changeset
|
1698 or else we have a potential bug. */ |
39dd5c98a114
(Fsignal): Reset redisplaying_p to zero.
Gerd Moellmann <gerd@gnu.org>
parents:
24605
diff
changeset
|
1699 if (interrupt_input_blocked != 0) |
39dd5c98a114
(Fsignal): Reset redisplaying_p to zero.
Gerd Moellmann <gerd@gnu.org>
parents:
24605
diff
changeset
|
1700 abort (); |
39dd5c98a114
(Fsignal): Reset redisplaying_p to zero.
Gerd Moellmann <gerd@gnu.org>
parents:
24605
diff
changeset
|
1701 |
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
1702 if (SYMBOLP (form)) |
272 | 1703 { |
1704 if (EQ (Vmocklisp_arguments, Qt)) | |
1705 return Fsymbol_value (form); | |
1706 val = Fsymbol_value (form); | |
485 | 1707 if (NILP (val)) |
9306
ac852c183fa1
(Feval, Ffuncall, funcall_lambda, Fbacktrace): Don't use XFASTINT as an
Karl Heuer <kwzh@gnu.org>
parents:
9148
diff
changeset
|
1708 XSETFASTINT (val, 0); |
272 | 1709 else if (EQ (val, Qt)) |
9306
ac852c183fa1
(Feval, Ffuncall, funcall_lambda, Fbacktrace): Don't use XFASTINT as an
Karl Heuer <kwzh@gnu.org>
parents:
9148
diff
changeset
|
1710 XSETFASTINT (val, 1); |
272 | 1711 return val; |
1712 } | |
1713 if (!CONSP (form)) | |
1714 return form; | |
1715 | |
1716 QUIT; | |
1717 if (consing_since_gc > gc_cons_threshold) | |
1718 { | |
1719 GCPRO1 (form); | |
1720 Fgarbage_collect (); | |
1721 UNGCPRO; | |
1722 } | |
1723 | |
1724 if (++lisp_eval_depth > max_lisp_eval_depth) | |
1725 { | |
1726 if (max_lisp_eval_depth < 100) | |
1727 max_lisp_eval_depth = 100; | |
1728 if (lisp_eval_depth > max_lisp_eval_depth) | |
1729 error ("Lisp nesting exceeds max-lisp-eval-depth"); | |
1730 } | |
1731 | |
1732 original_fun = Fcar (form); | |
1733 original_args = Fcdr (form); | |
1734 | |
1735 backtrace.next = backtrace_list; | |
1736 backtrace_list = &backtrace; | |
1737 backtrace.function = &original_fun; /* This also protects them from gc */ | |
1738 backtrace.args = &original_args; | |
1739 backtrace.nargs = UNEVALLED; | |
1740 backtrace.evalargs = 1; | |
1741 backtrace.debug_on_exit = 0; | |
1742 | |
1743 if (debug_on_next_call) | |
1744 do_debug_on_call (Qt); | |
1745 | |
1746 /* At this point, only original_fun and original_args | |
1747 have values that will be used below */ | |
1748 retry: | |
648 | 1749 fun = Findirect_function (original_fun); |
272 | 1750 |
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
1751 if (SUBRP (fun)) |
272 | 1752 { |
1753 Lisp_Object numargs; | |
19544
fc0bb24597ba
(Feval): Handle a subr which takes 8 arguments.
Kenichi Handa <handa@m17n.org>
parents:
19237
diff
changeset
|
1754 Lisp_Object argvals[8]; |
272 | 1755 Lisp_Object args_left; |
1756 register int i, maxargs; | |
1757 | |
1758 args_left = original_args; | |
1759 numargs = Flength (args_left); | |
1760 | |
1761 if (XINT (numargs) < XSUBR (fun)->min_args || | |
1762 (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args < XINT (numargs))) | |
1763 return Fsignal (Qwrong_number_of_arguments, Fcons (fun, Fcons (numargs, Qnil))); | |
1764 | |
1765 if (XSUBR (fun)->max_args == UNEVALLED) | |
1766 { | |
1767 backtrace.evalargs = 0; | |
1768 val = (*XSUBR (fun)->function) (args_left); | |
1769 goto done; | |
1770 } | |
1771 | |
1772 if (XSUBR (fun)->max_args == MANY) | |
1773 { | |
1774 /* Pass a vector of evaluated arguments */ | |
1775 Lisp_Object *vals; | |
1776 register int argnum = 0; | |
1777 | |
1778 vals = (Lisp_Object *) alloca (XINT (numargs) * sizeof (Lisp_Object)); | |
1779 | |
1780 GCPRO3 (args_left, fun, fun); | |
1781 gcpro3.var = vals; | |
1782 gcpro3.nvars = 0; | |
1783 | |
485 | 1784 while (!NILP (args_left)) |
272 | 1785 { |
1786 vals[argnum++] = Feval (Fcar (args_left)); | |
1787 args_left = Fcdr (args_left); | |
1788 gcpro3.nvars = argnum; | |
1789 } | |
1790 | |
1791 backtrace.args = vals; | |
1792 backtrace.nargs = XINT (numargs); | |
1793 | |
1794 val = (*XSUBR (fun)->function) (XINT (numargs), vals); | |
323 | 1795 UNGCPRO; |
272 | 1796 goto done; |
1797 } | |
1798 | |
1799 GCPRO3 (args_left, fun, fun); | |
1800 gcpro3.var = argvals; | |
1801 gcpro3.nvars = 0; | |
1802 | |
1803 maxargs = XSUBR (fun)->max_args; | |
1804 for (i = 0; i < maxargs; args_left = Fcdr (args_left)) | |
1805 { | |
1806 argvals[i] = Feval (Fcar (args_left)); | |
1807 gcpro3.nvars = ++i; | |
1808 } | |
1809 | |
1810 UNGCPRO; | |
1811 | |
1812 backtrace.args = argvals; | |
1813 backtrace.nargs = XINT (numargs); | |
1814 | |
1815 switch (i) | |
1816 { | |
1817 case 0: | |
1818 val = (*XSUBR (fun)->function) (); | |
1819 goto done; | |
1820 case 1: | |
1821 val = (*XSUBR (fun)->function) (argvals[0]); | |
1822 goto done; | |
1823 case 2: | |
1824 val = (*XSUBR (fun)->function) (argvals[0], argvals[1]); | |
1825 goto done; | |
1826 case 3: | |
1827 val = (*XSUBR (fun)->function) (argvals[0], argvals[1], | |
1828 argvals[2]); | |
1829 goto done; | |
1830 case 4: | |
1831 val = (*XSUBR (fun)->function) (argvals[0], argvals[1], | |
1832 argvals[2], argvals[3]); | |
1833 goto done; | |
1834 case 5: | |
1835 val = (*XSUBR (fun)->function) (argvals[0], argvals[1], argvals[2], | |
1836 argvals[3], argvals[4]); | |
1837 goto done; | |
1838 case 6: | |
1839 val = (*XSUBR (fun)->function) (argvals[0], argvals[1], argvals[2], | |
1840 argvals[3], argvals[4], argvals[5]); | |
1841 goto done; | |
863
427299469901
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
753
diff
changeset
|
1842 case 7: |
427299469901
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
753
diff
changeset
|
1843 val = (*XSUBR (fun)->function) (argvals[0], argvals[1], argvals[2], |
427299469901
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
753
diff
changeset
|
1844 argvals[3], argvals[4], argvals[5], |
427299469901
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
753
diff
changeset
|
1845 argvals[6]); |
427299469901
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
753
diff
changeset
|
1846 goto done; |
272 | 1847 |
19544
fc0bb24597ba
(Feval): Handle a subr which takes 8 arguments.
Kenichi Handa <handa@m17n.org>
parents:
19237
diff
changeset
|
1848 case 8: |
fc0bb24597ba
(Feval): Handle a subr which takes 8 arguments.
Kenichi Handa <handa@m17n.org>
parents:
19237
diff
changeset
|
1849 val = (*XSUBR (fun)->function) (argvals[0], argvals[1], argvals[2], |
fc0bb24597ba
(Feval): Handle a subr which takes 8 arguments.
Kenichi Handa <handa@m17n.org>
parents:
19237
diff
changeset
|
1850 argvals[3], argvals[4], argvals[5], |
fc0bb24597ba
(Feval): Handle a subr which takes 8 arguments.
Kenichi Handa <handa@m17n.org>
parents:
19237
diff
changeset
|
1851 argvals[6], argvals[7]); |
fc0bb24597ba
(Feval): Handle a subr which takes 8 arguments.
Kenichi Handa <handa@m17n.org>
parents:
19237
diff
changeset
|
1852 goto done; |
fc0bb24597ba
(Feval): Handle a subr which takes 8 arguments.
Kenichi Handa <handa@m17n.org>
parents:
19237
diff
changeset
|
1853 |
272 | 1854 default: |
604 | 1855 /* Someone has created a subr that takes more arguments than |
1856 is supported by this code. We need to either rewrite the | |
1857 subr to use a different argument protocol, or add more | |
1858 cases to this switch. */ | |
1859 abort (); | |
272 | 1860 } |
1861 } | |
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
1862 if (COMPILEDP (fun)) |
272 | 1863 val = apply_lambda (fun, original_args, 1); |
1864 else | |
1865 { | |
1866 if (!CONSP (fun)) | |
1867 return Fsignal (Qinvalid_function, Fcons (fun, Qnil)); | |
1868 funcar = Fcar (fun); | |
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
1869 if (!SYMBOLP (funcar)) |
272 | 1870 return Fsignal (Qinvalid_function, Fcons (fun, Qnil)); |
1871 if (EQ (funcar, Qautoload)) | |
1872 { | |
1873 do_autoload (fun, original_fun); | |
1874 goto retry; | |
1875 } | |
1876 if (EQ (funcar, Qmacro)) | |
1877 val = Feval (apply1 (Fcdr (fun), original_args)); | |
1878 else if (EQ (funcar, Qlambda)) | |
1879 val = apply_lambda (fun, original_args, 1); | |
1880 else if (EQ (funcar, Qmocklisp)) | |
1881 val = ml_apply (fun, original_args); | |
1882 else | |
1883 return Fsignal (Qinvalid_function, Fcons (fun, Qnil)); | |
1884 } | |
1885 done: | |
1886 if (!EQ (Vmocklisp_arguments, Qt)) | |
1887 { | |
485 | 1888 if (NILP (val)) |
9306
ac852c183fa1
(Feval, Ffuncall, funcall_lambda, Fbacktrace): Don't use XFASTINT as an
Karl Heuer <kwzh@gnu.org>
parents:
9148
diff
changeset
|
1889 XSETFASTINT (val, 0); |
272 | 1890 else if (EQ (val, Qt)) |
9306
ac852c183fa1
(Feval, Ffuncall, funcall_lambda, Fbacktrace): Don't use XFASTINT as an
Karl Heuer <kwzh@gnu.org>
parents:
9148
diff
changeset
|
1891 XSETFASTINT (val, 1); |
272 | 1892 } |
1893 lisp_eval_depth--; | |
1894 if (backtrace.debug_on_exit) | |
1895 val = call_debugger (Fcons (Qexit, Fcons (val, Qnil))); | |
1896 backtrace_list = backtrace.next; | |
1897 return val; | |
1898 } | |
1899 | |
1900 DEFUN ("apply", Fapply, Sapply, 2, MANY, 0, | |
1901 "Call FUNCTION with our remaining args, using our last arg as list of args.\n\ | |
12583
73ac42b9be24
(Ffuncall, Fapply): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
11481
diff
changeset
|
1902 Then return the value FUNCTION returns.\n\ |
272 | 1903 Thus, (apply '+ 1 2 '(3 4)) returns 10.") |
1904 (nargs, args) | |
1905 int nargs; | |
1906 Lisp_Object *args; | |
1907 { | |
1908 register int i, numargs; | |
1909 register Lisp_Object spread_arg; | |
1910 register Lisp_Object *funcall_args; | |
1911 Lisp_Object fun; | |
323 | 1912 struct gcpro gcpro1; |
272 | 1913 |
1914 fun = args [0]; | |
1915 funcall_args = 0; | |
1916 spread_arg = args [nargs - 1]; | |
1917 CHECK_LIST (spread_arg, nargs); | |
1918 | |
1919 numargs = XINT (Flength (spread_arg)); | |
1920 | |
1921 if (numargs == 0) | |
1922 return Ffuncall (nargs - 1, args); | |
1923 else if (numargs == 1) | |
1924 { | |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
1925 args [nargs - 1] = XCAR (spread_arg); |
272 | 1926 return Ffuncall (nargs, args); |
1927 } | |
1928 | |
323 | 1929 numargs += nargs - 2; |
272 | 1930 |
648 | 1931 fun = indirect_function (fun); |
1932 if (EQ (fun, Qunbound)) | |
272 | 1933 { |
648 | 1934 /* Let funcall get the error */ |
1935 fun = args[0]; | |
1936 goto funcall; | |
272 | 1937 } |
1938 | |
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
1939 if (SUBRP (fun)) |
272 | 1940 { |
1941 if (numargs < XSUBR (fun)->min_args | |
1942 || (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args < numargs)) | |
1943 goto funcall; /* Let funcall get the error */ | |
1944 else if (XSUBR (fun)->max_args > numargs) | |
1945 { | |
1946 /* Avoid making funcall cons up a yet another new vector of arguments | |
1947 by explicitly supplying nil's for optional values */ | |
1948 funcall_args = (Lisp_Object *) alloca ((1 + XSUBR (fun)->max_args) | |
1949 * sizeof (Lisp_Object)); | |
1950 for (i = numargs; i < XSUBR (fun)->max_args;) | |
1951 funcall_args[++i] = Qnil; | |
323 | 1952 GCPRO1 (*funcall_args); |
1953 gcpro1.nvars = 1 + XSUBR (fun)->max_args; | |
272 | 1954 } |
1955 } | |
1956 funcall: | |
1957 /* We add 1 to numargs because funcall_args includes the | |
1958 function itself as well as its arguments. */ | |
1959 if (!funcall_args) | |
323 | 1960 { |
1961 funcall_args = (Lisp_Object *) alloca ((1 + numargs) | |
1962 * sizeof (Lisp_Object)); | |
1963 GCPRO1 (*funcall_args); | |
1964 gcpro1.nvars = 1 + numargs; | |
1965 } | |
1966 | |
272 | 1967 bcopy (args, funcall_args, nargs * sizeof (Lisp_Object)); |
1968 /* Spread the last arg we got. Its first element goes in | |
1969 the slot that it used to occupy, hence this value of I. */ | |
1970 i = nargs - 1; | |
485 | 1971 while (!NILP (spread_arg)) |
272 | 1972 { |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
1973 funcall_args [i++] = XCAR (spread_arg); |
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
1974 spread_arg = XCDR (spread_arg); |
272 | 1975 } |
323 | 1976 |
1977 RETURN_UNGCPRO (Ffuncall (gcpro1.nvars, funcall_args)); | |
272 | 1978 } |
1979 | |
12732
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
1980 /* Run hook variables in various ways. */ |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
1981 |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
1982 enum run_hooks_condition {to_completion, until_success, until_failure}; |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
1983 |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
1984 DEFUN ("run-hooks", Frun_hooks, Srun_hooks, 1, MANY, 0, |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
1985 "Run each hook in HOOKS. Major mode functions use this.\n\ |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
1986 Each argument should be a symbol, a hook variable.\n\ |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
1987 These symbols are processed in the order specified.\n\ |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
1988 If a hook symbol has a non-nil value, that value may be a function\n\ |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
1989 or a list of functions to be called to run the hook.\n\ |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
1990 If the value is a function, it is called with no arguments.\n\ |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
1991 If it is a list, the elements are called, in order, with no arguments.\n\ |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
1992 \n\ |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
1993 To make a hook variable buffer-local, use `make-local-hook',\n\ |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
1994 not `make-local-variable'.") |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
1995 (nargs, args) |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
1996 int nargs; |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
1997 Lisp_Object *args; |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
1998 { |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
1999 Lisp_Object hook[1]; |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2000 register int i; |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2001 |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2002 for (i = 0; i < nargs; i++) |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2003 { |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2004 hook[0] = args[i]; |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2005 run_hook_with_args (1, hook, to_completion); |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2006 } |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2007 |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2008 return Qnil; |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2009 } |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2010 |
16485
9b919c5464a4
Reorganize function definitions so etags finds them.
Erik Naggum <erik@naggum.no>
parents:
16443
diff
changeset
|
2011 DEFUN ("run-hook-with-args", Frun_hook_with_args, |
9b919c5464a4
Reorganize function definitions so etags finds them.
Erik Naggum <erik@naggum.no>
parents:
16443
diff
changeset
|
2012 Srun_hook_with_args, 1, MANY, 0, |
12654
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2013 "Run HOOK with the specified arguments ARGS.\n\ |
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2014 HOOK should be a symbol, a hook variable. If HOOK has a non-nil\n\ |
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2015 value, that value may be a function or a list of functions to be\n\ |
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2016 called to run the hook. If the value is a function, it is called with\n\ |
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2017 the given arguments and its return value is returned. If it is a list\n\ |
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2018 of functions, those functions are called, in order,\n\ |
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2019 with the given arguments ARGS.\n\ |
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2020 It is best not to depend on the value return by `run-hook-with-args',\n\ |
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2021 as that may change.\n\ |
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2022 \n\ |
12732
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2023 To make a hook variable buffer-local, use `make-local-hook',\n\ |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2024 not `make-local-variable'.") |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2025 (nargs, args) |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2026 int nargs; |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2027 Lisp_Object *args; |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2028 { |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2029 return run_hook_with_args (nargs, args, to_completion); |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2030 } |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2031 |
16485
9b919c5464a4
Reorganize function definitions so etags finds them.
Erik Naggum <erik@naggum.no>
parents:
16443
diff
changeset
|
2032 DEFUN ("run-hook-with-args-until-success", Frun_hook_with_args_until_success, |
9b919c5464a4
Reorganize function definitions so etags finds them.
Erik Naggum <erik@naggum.no>
parents:
16443
diff
changeset
|
2033 Srun_hook_with_args_until_success, 1, MANY, 0, |
12732
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2034 "Run HOOK with the specified arguments ARGS.\n\ |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2035 HOOK should be a symbol, a hook variable. Its value should\n\ |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2036 be a list of functions. We call those functions, one by one,\n\ |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2037 passing arguments ARGS to each of them, until one of them\n\ |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2038 returns a non-nil value. Then we return that value.\n\ |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2039 If all the functions return nil, we return nil.\n\ |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2040 \n\ |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2041 To make a hook variable buffer-local, use `make-local-hook',\n\ |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2042 not `make-local-variable'.") |
12654
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2043 (nargs, args) |
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2044 int nargs; |
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2045 Lisp_Object *args; |
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2046 { |
12732
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2047 return run_hook_with_args (nargs, args, until_success); |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2048 } |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2049 |
16485
9b919c5464a4
Reorganize function definitions so etags finds them.
Erik Naggum <erik@naggum.no>
parents:
16443
diff
changeset
|
2050 DEFUN ("run-hook-with-args-until-failure", Frun_hook_with_args_until_failure, |
9b919c5464a4
Reorganize function definitions so etags finds them.
Erik Naggum <erik@naggum.no>
parents:
16443
diff
changeset
|
2051 Srun_hook_with_args_until_failure, 1, MANY, 0, |
12732
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2052 "Run HOOK with the specified arguments ARGS.\n\ |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2053 HOOK should be a symbol, a hook variable. Its value should\n\ |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2054 be a list of functions. We call those functions, one by one,\n\ |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2055 passing arguments ARGS to each of them, until one of them\n\ |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2056 returns nil. Then we return nil.\n\ |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2057 If all the functions return non-nil, we return non-nil.\n\ |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2058 \n\ |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2059 To make a hook variable buffer-local, use `make-local-hook',\n\ |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2060 not `make-local-variable'.") |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2061 (nargs, args) |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2062 int nargs; |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2063 Lisp_Object *args; |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2064 { |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2065 return run_hook_with_args (nargs, args, until_failure); |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2066 } |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2067 |
12781
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2068 /* ARGS[0] should be a hook symbol. |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2069 Call each of the functions in the hook value, passing each of them |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2070 as arguments all the rest of ARGS (all NARGS - 1 elements). |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2071 COND specifies a condition to test after each call |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2072 to decide whether to stop. |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2073 The caller (or its caller, etc) must gcpro all of ARGS, |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2074 except that it isn't necessary to gcpro ARGS[0]. */ |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2075 |
12732
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2076 Lisp_Object |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2077 run_hook_with_args (nargs, args, cond) |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2078 int nargs; |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2079 Lisp_Object *args; |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2080 enum run_hooks_condition cond; |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2081 { |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2082 Lisp_Object sym, val, ret; |
25257
0be923a80096
(run_hook_list_with_args): Gcpro `globals'.
Karl Heuer <kwzh@gnu.org>
parents:
25008
diff
changeset
|
2083 Lisp_Object globals; |
0be923a80096
(run_hook_list_with_args): Gcpro `globals'.
Karl Heuer <kwzh@gnu.org>
parents:
25008
diff
changeset
|
2084 struct gcpro gcpro1, gcpro2, gcpro3; |
12654
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2085 |
14218
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
2086 /* If we are dying or still initializing, |
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
2087 don't do anything--it would probably crash if we tried. */ |
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
2088 if (NILP (Vrun_hooks)) |
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
2089 return; |
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
2090 |
12654
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2091 sym = args[0]; |
12663
14d407b83eb3
(run-hook-with-args): Fix previous code.
Karl Heuer <kwzh@gnu.org>
parents:
12654
diff
changeset
|
2092 val = find_symbol_value (sym); |
12732
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2093 ret = (cond == until_failure ? Qt : Qnil); |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2094 |
12654
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2095 if (EQ (val, Qunbound) || NILP (val)) |
12732
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2096 return ret; |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
2097 else if (!CONSP (val) || EQ (XCAR (val), Qlambda)) |
12654
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2098 { |
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2099 args[0] = val; |
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2100 return Ffuncall (nargs, args); |
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2101 } |
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2102 else |
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2103 { |
25257
0be923a80096
(run_hook_list_with_args): Gcpro `globals'.
Karl Heuer <kwzh@gnu.org>
parents:
25008
diff
changeset
|
2104 globals = Qnil; |
0be923a80096
(run_hook_list_with_args): Gcpro `globals'.
Karl Heuer <kwzh@gnu.org>
parents:
25008
diff
changeset
|
2105 GCPRO3 (sym, val, globals); |
12788
eceb3f25e115
(run_hook_with_args): Move the GCPRO2; add UNGCPRO.
Richard M. Stallman <rms@gnu.org>
parents:
12781
diff
changeset
|
2106 |
12732
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2107 for (; |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2108 CONSP (val) && ((cond == to_completion) |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2109 || (cond == until_success ? NILP (ret) |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2110 : !NILP (ret))); |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
2111 val = XCDR (val)) |
12654
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2112 { |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
2113 if (EQ (XCAR (val), Qt)) |
12654
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2114 { |
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2115 /* t indicates this hook has a local binding; |
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2116 it means to run the global binding too. */ |
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2117 |
12732
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2118 for (globals = Fdefault_value (sym); |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2119 CONSP (globals) && ((cond == to_completion) |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2120 || (cond == until_success ? NILP (ret) |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2121 : !NILP (ret))); |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
2122 globals = XCDR (globals)) |
12654
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2123 { |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
2124 args[0] = XCAR (globals); |
13444
17f3f1c1bdf8
(run-hook-with-args, run-hook-list-with-args): Safeguard
Richard M. Stallman <rms@gnu.org>
parents:
13314
diff
changeset
|
2125 /* In a global value, t should not occur. If it does, we |
17f3f1c1bdf8
(run-hook-with-args, run-hook-list-with-args): Safeguard
Richard M. Stallman <rms@gnu.org>
parents:
13314
diff
changeset
|
2126 must ignore it to avoid an endless loop. */ |
17f3f1c1bdf8
(run-hook-with-args, run-hook-list-with-args): Safeguard
Richard M. Stallman <rms@gnu.org>
parents:
13314
diff
changeset
|
2127 if (!EQ (args[0], Qt)) |
17f3f1c1bdf8
(run-hook-with-args, run-hook-list-with-args): Safeguard
Richard M. Stallman <rms@gnu.org>
parents:
13314
diff
changeset
|
2128 ret = Ffuncall (nargs, args); |
12654
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2129 } |
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2130 } |
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2131 else |
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2132 { |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
2133 args[0] = XCAR (val); |
12732
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2134 ret = Ffuncall (nargs, args); |
12654
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2135 } |
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2136 } |
12788
eceb3f25e115
(run_hook_with_args): Move the GCPRO2; add UNGCPRO.
Richard M. Stallman <rms@gnu.org>
parents:
12781
diff
changeset
|
2137 |
eceb3f25e115
(run_hook_with_args): Move the GCPRO2; add UNGCPRO.
Richard M. Stallman <rms@gnu.org>
parents:
12781
diff
changeset
|
2138 UNGCPRO; |
12732
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2139 return ret; |
12654
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2140 } |
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2141 } |
12781
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2142 |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2143 /* Run a hook symbol ARGS[0], but use FUNLIST instead of the actual |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2144 present value of that symbol. |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2145 Call each element of FUNLIST, |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2146 passing each of them the rest of ARGS. |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2147 The caller (or its caller, etc) must gcpro all of ARGS, |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2148 except that it isn't necessary to gcpro ARGS[0]. */ |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2149 |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2150 Lisp_Object |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2151 run_hook_list_with_args (funlist, nargs, args) |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2152 Lisp_Object funlist; |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2153 int nargs; |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2154 Lisp_Object *args; |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2155 { |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2156 Lisp_Object sym; |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2157 Lisp_Object val; |
25257
0be923a80096
(run_hook_list_with_args): Gcpro `globals'.
Karl Heuer <kwzh@gnu.org>
parents:
25008
diff
changeset
|
2158 Lisp_Object globals; |
0be923a80096
(run_hook_list_with_args): Gcpro `globals'.
Karl Heuer <kwzh@gnu.org>
parents:
25008
diff
changeset
|
2159 struct gcpro gcpro1, gcpro2, gcpro3; |
12781
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2160 |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2161 sym = args[0]; |
25257
0be923a80096
(run_hook_list_with_args): Gcpro `globals'.
Karl Heuer <kwzh@gnu.org>
parents:
25008
diff
changeset
|
2162 globals = Qnil; |
0be923a80096
(run_hook_list_with_args): Gcpro `globals'.
Karl Heuer <kwzh@gnu.org>
parents:
25008
diff
changeset
|
2163 GCPRO3 (sym, val, globals); |
12781
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2164 |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
2165 for (val = funlist; CONSP (val); val = XCDR (val)) |
12781
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2166 { |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
2167 if (EQ (XCAR (val), Qt)) |
12781
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2168 { |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2169 /* t indicates this hook has a local binding; |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2170 it means to run the global binding too. */ |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2171 |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2172 for (globals = Fdefault_value (sym); |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2173 CONSP (globals); |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
2174 globals = XCDR (globals)) |
12781
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2175 { |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
2176 args[0] = XCAR (globals); |
13444
17f3f1c1bdf8
(run-hook-with-args, run-hook-list-with-args): Safeguard
Richard M. Stallman <rms@gnu.org>
parents:
13314
diff
changeset
|
2177 /* In a global value, t should not occur. If it does, we |
17f3f1c1bdf8
(run-hook-with-args, run-hook-list-with-args): Safeguard
Richard M. Stallman <rms@gnu.org>
parents:
13314
diff
changeset
|
2178 must ignore it to avoid an endless loop. */ |
17f3f1c1bdf8
(run-hook-with-args, run-hook-list-with-args): Safeguard
Richard M. Stallman <rms@gnu.org>
parents:
13314
diff
changeset
|
2179 if (!EQ (args[0], Qt)) |
17f3f1c1bdf8
(run-hook-with-args, run-hook-list-with-args): Safeguard
Richard M. Stallman <rms@gnu.org>
parents:
13314
diff
changeset
|
2180 Ffuncall (nargs, args); |
12781
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2181 } |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2182 } |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2183 else |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2184 { |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
2185 args[0] = XCAR (val); |
12781
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2186 Ffuncall (nargs, args); |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2187 } |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2188 } |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2189 UNGCPRO; |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2190 return Qnil; |
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2191 } |
13103
a537b52d6668
(run_hook_with_args_2): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12788
diff
changeset
|
2192 |
a537b52d6668
(run_hook_with_args_2): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12788
diff
changeset
|
2193 /* Run the hook HOOK, giving each function the two args ARG1 and ARG2. */ |
a537b52d6668
(run_hook_with_args_2): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12788
diff
changeset
|
2194 |
a537b52d6668
(run_hook_with_args_2): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12788
diff
changeset
|
2195 void |
a537b52d6668
(run_hook_with_args_2): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12788
diff
changeset
|
2196 run_hook_with_args_2 (hook, arg1, arg2) |
a537b52d6668
(run_hook_with_args_2): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12788
diff
changeset
|
2197 Lisp_Object hook, arg1, arg2; |
a537b52d6668
(run_hook_with_args_2): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12788
diff
changeset
|
2198 { |
a537b52d6668
(run_hook_with_args_2): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12788
diff
changeset
|
2199 Lisp_Object temp[3]; |
a537b52d6668
(run_hook_with_args_2): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12788
diff
changeset
|
2200 temp[0] = hook; |
a537b52d6668
(run_hook_with_args_2): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12788
diff
changeset
|
2201 temp[1] = arg1; |
a537b52d6668
(run_hook_with_args_2): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12788
diff
changeset
|
2202 temp[2] = arg2; |
a537b52d6668
(run_hook_with_args_2): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12788
diff
changeset
|
2203 |
a537b52d6668
(run_hook_with_args_2): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12788
diff
changeset
|
2204 Frun_hook_with_args (3, temp); |
a537b52d6668
(run_hook_with_args_2): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12788
diff
changeset
|
2205 } |
12732
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2206 |
272 | 2207 /* Apply fn to arg */ |
2208 Lisp_Object | |
2209 apply1 (fn, arg) | |
2210 Lisp_Object fn, arg; | |
2211 { | |
323 | 2212 struct gcpro gcpro1; |
2213 | |
2214 GCPRO1 (fn); | |
485 | 2215 if (NILP (arg)) |
323 | 2216 RETURN_UNGCPRO (Ffuncall (1, &fn)); |
2217 gcpro1.nvars = 2; | |
272 | 2218 #ifdef NO_ARG_ARRAY |
2219 { | |
2220 Lisp_Object args[2]; | |
2221 args[0] = fn; | |
2222 args[1] = arg; | |
323 | 2223 gcpro1.var = args; |
2224 RETURN_UNGCPRO (Fapply (2, args)); | |
272 | 2225 } |
2226 #else /* not NO_ARG_ARRAY */ | |
323 | 2227 RETURN_UNGCPRO (Fapply (2, &fn)); |
272 | 2228 #endif /* not NO_ARG_ARRAY */ |
2229 } | |
2230 | |
2231 /* Call function fn on no arguments */ | |
2232 Lisp_Object | |
2233 call0 (fn) | |
2234 Lisp_Object fn; | |
2235 { | |
323 | 2236 struct gcpro gcpro1; |
2237 | |
2238 GCPRO1 (fn); | |
2239 RETURN_UNGCPRO (Ffuncall (1, &fn)); | |
272 | 2240 } |
2241 | |
3703
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2242 /* Call function fn with 1 argument arg1 */ |
272 | 2243 /* ARGSUSED */ |
2244 Lisp_Object | |
3703
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2245 call1 (fn, arg1) |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2246 Lisp_Object fn, arg1; |
272 | 2247 { |
323 | 2248 struct gcpro gcpro1; |
272 | 2249 #ifdef NO_ARG_ARRAY |
323 | 2250 Lisp_Object args[2]; |
2251 | |
272 | 2252 args[0] = fn; |
3703
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2253 args[1] = arg1; |
323 | 2254 GCPRO1 (args[0]); |
2255 gcpro1.nvars = 2; | |
2256 RETURN_UNGCPRO (Ffuncall (2, args)); | |
272 | 2257 #else /* not NO_ARG_ARRAY */ |
323 | 2258 GCPRO1 (fn); |
2259 gcpro1.nvars = 2; | |
2260 RETURN_UNGCPRO (Ffuncall (2, &fn)); | |
272 | 2261 #endif /* not NO_ARG_ARRAY */ |
2262 } | |
2263 | |
3703
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2264 /* Call function fn with 2 arguments arg1, arg2 */ |
272 | 2265 /* ARGSUSED */ |
2266 Lisp_Object | |
3703
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2267 call2 (fn, arg1, arg2) |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2268 Lisp_Object fn, arg1, arg2; |
272 | 2269 { |
323 | 2270 struct gcpro gcpro1; |
272 | 2271 #ifdef NO_ARG_ARRAY |
2272 Lisp_Object args[3]; | |
2273 args[0] = fn; | |
3703
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2274 args[1] = arg1; |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2275 args[2] = arg2; |
323 | 2276 GCPRO1 (args[0]); |
2277 gcpro1.nvars = 3; | |
2278 RETURN_UNGCPRO (Ffuncall (3, args)); | |
272 | 2279 #else /* not NO_ARG_ARRAY */ |
323 | 2280 GCPRO1 (fn); |
2281 gcpro1.nvars = 3; | |
2282 RETURN_UNGCPRO (Ffuncall (3, &fn)); | |
272 | 2283 #endif /* not NO_ARG_ARRAY */ |
2284 } | |
2285 | |
3703
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2286 /* Call function fn with 3 arguments arg1, arg2, arg3 */ |
272 | 2287 /* ARGSUSED */ |
2288 Lisp_Object | |
3703
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2289 call3 (fn, arg1, arg2, arg3) |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2290 Lisp_Object fn, arg1, arg2, arg3; |
272 | 2291 { |
323 | 2292 struct gcpro gcpro1; |
272 | 2293 #ifdef NO_ARG_ARRAY |
2294 Lisp_Object args[4]; | |
2295 args[0] = fn; | |
3703
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2296 args[1] = arg1; |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2297 args[2] = arg2; |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2298 args[3] = arg3; |
323 | 2299 GCPRO1 (args[0]); |
2300 gcpro1.nvars = 4; | |
2301 RETURN_UNGCPRO (Ffuncall (4, args)); | |
272 | 2302 #else /* not NO_ARG_ARRAY */ |
323 | 2303 GCPRO1 (fn); |
2304 gcpro1.nvars = 4; | |
2305 RETURN_UNGCPRO (Ffuncall (4, &fn)); | |
272 | 2306 #endif /* not NO_ARG_ARRAY */ |
2307 } | |
2308 | |
3703
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2309 /* Call function fn with 4 arguments arg1, arg2, arg3, arg4 */ |
3598
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2310 /* ARGSUSED */ |
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2311 Lisp_Object |
3703
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2312 call4 (fn, arg1, arg2, arg3, arg4) |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2313 Lisp_Object fn, arg1, arg2, arg3, arg4; |
3598
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2314 { |
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2315 struct gcpro gcpro1; |
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2316 #ifdef NO_ARG_ARRAY |
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2317 Lisp_Object args[5]; |
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2318 args[0] = fn; |
3703
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2319 args[1] = arg1; |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2320 args[2] = arg2; |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2321 args[3] = arg3; |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2322 args[4] = arg4; |
3598
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2323 GCPRO1 (args[0]); |
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2324 gcpro1.nvars = 5; |
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2325 RETURN_UNGCPRO (Ffuncall (5, args)); |
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2326 #else /* not NO_ARG_ARRAY */ |
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2327 GCPRO1 (fn); |
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2328 gcpro1.nvars = 5; |
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2329 RETURN_UNGCPRO (Ffuncall (5, &fn)); |
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2330 #endif /* not NO_ARG_ARRAY */ |
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2331 } |
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2332 |
3703
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2333 /* Call function fn with 5 arguments arg1, arg2, arg3, arg4, arg5 */ |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2334 /* ARGSUSED */ |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2335 Lisp_Object |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2336 call5 (fn, arg1, arg2, arg3, arg4, arg5) |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2337 Lisp_Object fn, arg1, arg2, arg3, arg4, arg5; |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2338 { |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2339 struct gcpro gcpro1; |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2340 #ifdef NO_ARG_ARRAY |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2341 Lisp_Object args[6]; |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2342 args[0] = fn; |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2343 args[1] = arg1; |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2344 args[2] = arg2; |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2345 args[3] = arg3; |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2346 args[4] = arg4; |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2347 args[5] = arg5; |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2348 GCPRO1 (args[0]); |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2349 gcpro1.nvars = 6; |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2350 RETURN_UNGCPRO (Ffuncall (6, args)); |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2351 #else /* not NO_ARG_ARRAY */ |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2352 GCPRO1 (fn); |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2353 gcpro1.nvars = 6; |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2354 RETURN_UNGCPRO (Ffuncall (6, &fn)); |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2355 #endif /* not NO_ARG_ARRAY */ |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2356 } |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2357 |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2358 /* Call function fn with 6 arguments arg1, arg2, arg3, arg4, arg5, arg6 */ |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2359 /* ARGSUSED */ |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2360 Lisp_Object |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2361 call6 (fn, arg1, arg2, arg3, arg4, arg5, arg6) |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2362 Lisp_Object fn, arg1, arg2, arg3, arg4, arg5, arg6; |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2363 { |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2364 struct gcpro gcpro1; |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2365 #ifdef NO_ARG_ARRAY |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2366 Lisp_Object args[7]; |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2367 args[0] = fn; |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2368 args[1] = arg1; |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2369 args[2] = arg2; |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2370 args[3] = arg3; |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2371 args[4] = arg4; |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2372 args[5] = arg5; |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2373 args[6] = arg6; |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2374 GCPRO1 (args[0]); |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2375 gcpro1.nvars = 7; |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2376 RETURN_UNGCPRO (Ffuncall (7, args)); |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2377 #else /* not NO_ARG_ARRAY */ |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2378 GCPRO1 (fn); |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2379 gcpro1.nvars = 7; |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2380 RETURN_UNGCPRO (Ffuncall (7, &fn)); |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2381 #endif /* not NO_ARG_ARRAY */ |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2382 } |
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2383 |
272 | 2384 DEFUN ("funcall", Ffuncall, Sfuncall, 1, MANY, 0, |
2385 "Call first argument as a function, passing remaining arguments to it.\n\ | |
12583
73ac42b9be24
(Ffuncall, Fapply): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
11481
diff
changeset
|
2386 Return the value that function returns.\n\ |
272 | 2387 Thus, (funcall 'cons 'x 'y) returns (x . y).") |
2388 (nargs, args) | |
2389 int nargs; | |
2390 Lisp_Object *args; | |
2391 { | |
2392 Lisp_Object fun; | |
2393 Lisp_Object funcar; | |
2394 int numargs = nargs - 1; | |
2395 Lisp_Object lisp_numargs; | |
2396 Lisp_Object val; | |
2397 struct backtrace backtrace; | |
2398 register Lisp_Object *internal_args; | |
2399 register int i; | |
2400 | |
2401 QUIT; | |
2402 if (consing_since_gc > gc_cons_threshold) | |
323 | 2403 Fgarbage_collect (); |
272 | 2404 |
2405 if (++lisp_eval_depth > max_lisp_eval_depth) | |
2406 { | |
2407 if (max_lisp_eval_depth < 100) | |
2408 max_lisp_eval_depth = 100; | |
2409 if (lisp_eval_depth > max_lisp_eval_depth) | |
2410 error ("Lisp nesting exceeds max-lisp-eval-depth"); | |
2411 } | |
2412 | |
2413 backtrace.next = backtrace_list; | |
2414 backtrace_list = &backtrace; | |
2415 backtrace.function = &args[0]; | |
2416 backtrace.args = &args[1]; | |
2417 backtrace.nargs = nargs - 1; | |
2418 backtrace.evalargs = 0; | |
2419 backtrace.debug_on_exit = 0; | |
2420 | |
2421 if (debug_on_next_call) | |
2422 do_debug_on_call (Qlambda); | |
2423 | |
2424 retry: | |
2425 | |
2426 fun = args[0]; | |
648 | 2427 |
2428 fun = Findirect_function (fun); | |
272 | 2429 |
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
2430 if (SUBRP (fun)) |
272 | 2431 { |
2432 if (numargs < XSUBR (fun)->min_args | |
2433 || (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args < numargs)) | |
2434 { | |
9306
ac852c183fa1
(Feval, Ffuncall, funcall_lambda, Fbacktrace): Don't use XFASTINT as an
Karl Heuer <kwzh@gnu.org>
parents:
9148
diff
changeset
|
2435 XSETFASTINT (lisp_numargs, numargs); |
272 | 2436 return Fsignal (Qwrong_number_of_arguments, Fcons (fun, Fcons (lisp_numargs, Qnil))); |
2437 } | |
2438 | |
2439 if (XSUBR (fun)->max_args == UNEVALLED) | |
2440 return Fsignal (Qinvalid_function, Fcons (fun, Qnil)); | |
2441 | |
2442 if (XSUBR (fun)->max_args == MANY) | |
2443 { | |
2444 val = (*XSUBR (fun)->function) (numargs, args + 1); | |
2445 goto done; | |
2446 } | |
2447 | |
2448 if (XSUBR (fun)->max_args > numargs) | |
2449 { | |
2450 internal_args = (Lisp_Object *) alloca (XSUBR (fun)->max_args * sizeof (Lisp_Object)); | |
2451 bcopy (args + 1, internal_args, numargs * sizeof (Lisp_Object)); | |
2452 for (i = numargs; i < XSUBR (fun)->max_args; i++) | |
2453 internal_args[i] = Qnil; | |
2454 } | |
2455 else | |
2456 internal_args = args + 1; | |
2457 switch (XSUBR (fun)->max_args) | |
2458 { | |
2459 case 0: | |
2460 val = (*XSUBR (fun)->function) (); | |
2461 goto done; | |
2462 case 1: | |
2463 val = (*XSUBR (fun)->function) (internal_args[0]); | |
2464 goto done; | |
2465 case 2: | |
2466 val = (*XSUBR (fun)->function) (internal_args[0], | |
2467 internal_args[1]); | |
2468 goto done; | |
2469 case 3: | |
2470 val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1], | |
2471 internal_args[2]); | |
2472 goto done; | |
2473 case 4: | |
2474 val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1], | |
2475 internal_args[2], | |
2476 internal_args[3]); | |
2477 goto done; | |
2478 case 5: | |
2479 val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1], | |
2480 internal_args[2], internal_args[3], | |
2481 internal_args[4]); | |
2482 goto done; | |
2483 case 6: | |
2484 val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1], | |
2485 internal_args[2], internal_args[3], | |
2486 internal_args[4], internal_args[5]); | |
2487 goto done; | |
863
427299469901
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
753
diff
changeset
|
2488 case 7: |
427299469901
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
753
diff
changeset
|
2489 val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1], |
427299469901
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
753
diff
changeset
|
2490 internal_args[2], internal_args[3], |
427299469901
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
753
diff
changeset
|
2491 internal_args[4], internal_args[5], |
427299469901
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
753
diff
changeset
|
2492 internal_args[6]); |
427299469901
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
753
diff
changeset
|
2493 goto done; |
272 | 2494 |
19544
fc0bb24597ba
(Feval): Handle a subr which takes 8 arguments.
Kenichi Handa <handa@m17n.org>
parents:
19237
diff
changeset
|
2495 case 8: |
fc0bb24597ba
(Feval): Handle a subr which takes 8 arguments.
Kenichi Handa <handa@m17n.org>
parents:
19237
diff
changeset
|
2496 val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1], |
fc0bb24597ba
(Feval): Handle a subr which takes 8 arguments.
Kenichi Handa <handa@m17n.org>
parents:
19237
diff
changeset
|
2497 internal_args[2], internal_args[3], |
fc0bb24597ba
(Feval): Handle a subr which takes 8 arguments.
Kenichi Handa <handa@m17n.org>
parents:
19237
diff
changeset
|
2498 internal_args[4], internal_args[5], |
fc0bb24597ba
(Feval): Handle a subr which takes 8 arguments.
Kenichi Handa <handa@m17n.org>
parents:
19237
diff
changeset
|
2499 internal_args[6], internal_args[7]); |
fc0bb24597ba
(Feval): Handle a subr which takes 8 arguments.
Kenichi Handa <handa@m17n.org>
parents:
19237
diff
changeset
|
2500 goto done; |
fc0bb24597ba
(Feval): Handle a subr which takes 8 arguments.
Kenichi Handa <handa@m17n.org>
parents:
19237
diff
changeset
|
2501 |
272 | 2502 default: |
573 | 2503 |
19544
fc0bb24597ba
(Feval): Handle a subr which takes 8 arguments.
Kenichi Handa <handa@m17n.org>
parents:
19237
diff
changeset
|
2504 /* If a subr takes more than 8 arguments without using MANY |
573 | 2505 or UNEVALLED, we need to extend this function to support it. |
2506 Until this is done, there is no way to call the function. */ | |
2507 abort (); | |
272 | 2508 } |
2509 } | |
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
2510 if (COMPILEDP (fun)) |
272 | 2511 val = funcall_lambda (fun, numargs, args + 1); |
2512 else | |
2513 { | |
2514 if (!CONSP (fun)) | |
2515 return Fsignal (Qinvalid_function, Fcons (fun, Qnil)); | |
2516 funcar = Fcar (fun); | |
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
2517 if (!SYMBOLP (funcar)) |
272 | 2518 return Fsignal (Qinvalid_function, Fcons (fun, Qnil)); |
2519 if (EQ (funcar, Qlambda)) | |
2520 val = funcall_lambda (fun, numargs, args + 1); | |
2521 else if (EQ (funcar, Qmocklisp)) | |
2522 val = ml_apply (fun, Flist (numargs, args + 1)); | |
2523 else if (EQ (funcar, Qautoload)) | |
2524 { | |
2525 do_autoload (fun, args[0]); | |
2526 goto retry; | |
2527 } | |
2528 else | |
2529 return Fsignal (Qinvalid_function, Fcons (fun, Qnil)); | |
2530 } | |
2531 done: | |
2532 lisp_eval_depth--; | |
2533 if (backtrace.debug_on_exit) | |
2534 val = call_debugger (Fcons (Qexit, Fcons (val, Qnil))); | |
2535 backtrace_list = backtrace.next; | |
2536 return val; | |
2537 } | |
2538 | |
2539 Lisp_Object | |
2540 apply_lambda (fun, args, eval_flag) | |
2541 Lisp_Object fun, args; | |
2542 int eval_flag; | |
2543 { | |
2544 Lisp_Object args_left; | |
2545 Lisp_Object numargs; | |
2546 register Lisp_Object *arg_vector; | |
2547 struct gcpro gcpro1, gcpro2, gcpro3; | |
2548 register int i; | |
2549 register Lisp_Object tem; | |
2550 | |
2551 numargs = Flength (args); | |
2552 arg_vector = (Lisp_Object *) alloca (XINT (numargs) * sizeof (Lisp_Object)); | |
2553 args_left = args; | |
2554 | |
2555 GCPRO3 (*arg_vector, args_left, fun); | |
2556 gcpro1.nvars = 0; | |
2557 | |
2558 for (i = 0; i < XINT (numargs);) | |
2559 { | |
2560 tem = Fcar (args_left), args_left = Fcdr (args_left); | |
2561 if (eval_flag) tem = Feval (tem); | |
2562 arg_vector[i++] = tem; | |
2563 gcpro1.nvars = i; | |
2564 } | |
2565 | |
2566 UNGCPRO; | |
2567 | |
2568 if (eval_flag) | |
2569 { | |
2570 backtrace_list->args = arg_vector; | |
2571 backtrace_list->nargs = i; | |
2572 } | |
2573 backtrace_list->evalargs = 0; | |
2574 tem = funcall_lambda (fun, XINT (numargs), arg_vector); | |
2575 | |
2576 /* Do the debug-on-exit now, while arg_vector still exists. */ | |
2577 if (backtrace_list->debug_on_exit) | |
2578 tem = call_debugger (Fcons (Qexit, Fcons (tem, Qnil))); | |
2579 /* Don't do it again when we return to eval. */ | |
2580 backtrace_list->debug_on_exit = 0; | |
2581 return tem; | |
2582 } | |
2583 | |
2584 /* Apply a Lisp function FUN to the NARGS evaluated arguments in ARG_VECTOR | |
2585 and return the result of evaluation. | |
2586 FUN must be either a lambda-expression or a compiled-code object. */ | |
2587 | |
2588 Lisp_Object | |
2589 funcall_lambda (fun, nargs, arg_vector) | |
2590 Lisp_Object fun; | |
2591 int nargs; | |
2592 register Lisp_Object *arg_vector; | |
2593 { | |
2594 Lisp_Object val, tem; | |
2595 register Lisp_Object syms_left; | |
2596 Lisp_Object numargs; | |
2597 register Lisp_Object next; | |
2598 int count = specpdl_ptr - specpdl; | |
2599 register int i; | |
2600 int optional = 0, rest = 0; | |
2601 | |
2602 specbind (Qmocklisp_arguments, Qt); /* t means NOT mocklisp! */ | |
2603 | |
9306
ac852c183fa1
(Feval, Ffuncall, funcall_lambda, Fbacktrace): Don't use XFASTINT as an
Karl Heuer <kwzh@gnu.org>
parents:
9148
diff
changeset
|
2604 XSETFASTINT (numargs, nargs); |
272 | 2605 |
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
2606 if (CONSP (fun)) |
272 | 2607 syms_left = Fcar (Fcdr (fun)); |
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
2608 else if (COMPILEDP (fun)) |
272 | 2609 syms_left = XVECTOR (fun)->contents[COMPILED_ARGLIST]; |
2610 else abort (); | |
2611 | |
2612 i = 0; | |
485 | 2613 for (; !NILP (syms_left); syms_left = Fcdr (syms_left)) |
272 | 2614 { |
2615 QUIT; | |
2616 next = Fcar (syms_left); | |
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
2617 while (!SYMBOLP (next)) |
431 | 2618 next = Fsignal (Qinvalid_function, Fcons (fun, Qnil)); |
272 | 2619 if (EQ (next, Qand_rest)) |
2620 rest = 1; | |
2621 else if (EQ (next, Qand_optional)) | |
2622 optional = 1; | |
2623 else if (rest) | |
2624 { | |
431 | 2625 specbind (next, Flist (nargs - i, &arg_vector[i])); |
272 | 2626 i = nargs; |
2627 } | |
2628 else if (i < nargs) | |
2629 { | |
2630 tem = arg_vector[i++]; | |
2631 specbind (next, tem); | |
2632 } | |
2633 else if (!optional) | |
2634 return Fsignal (Qwrong_number_of_arguments, Fcons (fun, Fcons (numargs, Qnil))); | |
2635 else | |
2636 specbind (next, Qnil); | |
2637 } | |
2638 | |
2639 if (i < nargs) | |
2640 return Fsignal (Qwrong_number_of_arguments, Fcons (fun, Fcons (numargs, Qnil))); | |
2641 | |
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
2642 if (CONSP (fun)) |
272 | 2643 val = Fprogn (Fcdr (Fcdr (fun))); |
2644 else | |
10201
03f3a1f4264a
(Fdefvar): Fix minor error in previous change.
Richard M. Stallman <rms@gnu.org>
parents:
10161
diff
changeset
|
2645 { |
03f3a1f4264a
(Fdefvar): Fix minor error in previous change.
Richard M. Stallman <rms@gnu.org>
parents:
10161
diff
changeset
|
2646 /* If we have not actually read the bytecode string |
03f3a1f4264a
(Fdefvar): Fix minor error in previous change.
Richard M. Stallman <rms@gnu.org>
parents:
10161
diff
changeset
|
2647 and constants vector yet, fetch them from the file. */ |
03f3a1f4264a
(Fdefvar): Fix minor error in previous change.
Richard M. Stallman <rms@gnu.org>
parents:
10161
diff
changeset
|
2648 if (CONSP (XVECTOR (fun)->contents[COMPILED_BYTECODE])) |
11205
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2649 Ffetch_bytecode (fun); |
10201
03f3a1f4264a
(Fdefvar): Fix minor error in previous change.
Richard M. Stallman <rms@gnu.org>
parents:
10161
diff
changeset
|
2650 val = Fbyte_code (XVECTOR (fun)->contents[COMPILED_BYTECODE], |
03f3a1f4264a
(Fdefvar): Fix minor error in previous change.
Richard M. Stallman <rms@gnu.org>
parents:
10161
diff
changeset
|
2651 XVECTOR (fun)->contents[COMPILED_CONSTANTS], |
03f3a1f4264a
(Fdefvar): Fix minor error in previous change.
Richard M. Stallman <rms@gnu.org>
parents:
10161
diff
changeset
|
2652 XVECTOR (fun)->contents[COMPILED_STACK_DEPTH]); |
03f3a1f4264a
(Fdefvar): Fix minor error in previous change.
Richard M. Stallman <rms@gnu.org>
parents:
10161
diff
changeset
|
2653 } |
272 | 2654 return unbind_to (count, val); |
2655 } | |
11205
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2656 |
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2657 DEFUN ("fetch-bytecode", Ffetch_bytecode, Sfetch_bytecode, |
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2658 1, 1, 0, |
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2659 "If byte-compiled OBJECT is lazy-loaded, fetch it now.") |
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2660 (object) |
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2661 Lisp_Object object; |
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2662 { |
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2663 Lisp_Object tem; |
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2664 |
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2665 if (COMPILEDP (object) |
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2666 && CONSP (XVECTOR (object)->contents[COMPILED_BYTECODE])) |
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2667 { |
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2668 tem = read_doc_string (XVECTOR (object)->contents[COMPILED_BYTECODE]); |
11481
af7833ecb551
(Ffetch_bytecode): Check the type of the object being read from the file.
Richard M. Stallman <rms@gnu.org>
parents:
11365
diff
changeset
|
2669 if (!CONSP (tem)) |
af7833ecb551
(Ffetch_bytecode): Check the type of the object being read from the file.
Richard M. Stallman <rms@gnu.org>
parents:
11365
diff
changeset
|
2670 error ("invalid byte code"); |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
2671 XVECTOR (object)->contents[COMPILED_BYTECODE] = XCAR (tem); |
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
2672 XVECTOR (object)->contents[COMPILED_CONSTANTS] = XCDR (tem); |
11205
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2673 } |
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2674 return object; |
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2675 } |
272 | 2676 |
2677 void | |
2678 grow_specpdl () | |
2679 { | |
2680 register int count = specpdl_ptr - specpdl; | |
2681 if (specpdl_size >= max_specpdl_size) | |
2682 { | |
2683 if (max_specpdl_size < 400) | |
2684 max_specpdl_size = 400; | |
2685 if (specpdl_size >= max_specpdl_size) | |
2686 { | |
1452
ed79bb8047e8
(grow_specpdl): Increase max_specpdl_size before Fsignal.
Richard M. Stallman <rms@gnu.org>
parents:
1199
diff
changeset
|
2687 if (!NILP (Vdebug_on_error)) |
ed79bb8047e8
(grow_specpdl): Increase max_specpdl_size before Fsignal.
Richard M. Stallman <rms@gnu.org>
parents:
1199
diff
changeset
|
2688 /* Leave room for some specpdl in the debugger. */ |
ed79bb8047e8
(grow_specpdl): Increase max_specpdl_size before Fsignal.
Richard M. Stallman <rms@gnu.org>
parents:
1199
diff
changeset
|
2689 max_specpdl_size = specpdl_size + 100; |
272 | 2690 Fsignal (Qerror, |
2691 Fcons (build_string ("Variable binding depth exceeds max-specpdl-size"), Qnil)); | |
2692 } | |
2693 } | |
2694 specpdl_size *= 2; | |
2695 if (specpdl_size > max_specpdl_size) | |
2696 specpdl_size = max_specpdl_size; | |
2697 specpdl = (struct specbinding *) xrealloc (specpdl, specpdl_size * sizeof (struct specbinding)); | |
2698 specpdl_ptr = specpdl + count; | |
2699 } | |
2700 | |
2701 void | |
2702 specbind (symbol, value) | |
2703 Lisp_Object symbol, value; | |
2704 { | |
2705 Lisp_Object ovalue; | |
2706 | |
431 | 2707 CHECK_SYMBOL (symbol, 0); |
2708 | |
272 | 2709 if (specpdl_ptr == specpdl + specpdl_size) |
2710 grow_specpdl (); | |
2711 specpdl_ptr->symbol = symbol; | |
2712 specpdl_ptr->func = 0; | |
6826
903d03ddf99c
(specbind): Use find_symbol_value.
Richard M. Stallman <rms@gnu.org>
parents:
6803
diff
changeset
|
2713 specpdl_ptr->old_value = ovalue = find_symbol_value (symbol); |
272 | 2714 specpdl_ptr++; |
11007
433d4013f39b
(specbind): Rename perdisplay to kboard.
Karl Heuer <kwzh@gnu.org>
parents:
10604
diff
changeset
|
2715 if (BUFFER_OBJFWDP (ovalue) || KBOARD_OBJFWDP (ovalue)) |
272 | 2716 store_symval_forwarding (symbol, ovalue, value); |
2717 else | |
16930
e1aba4a05388
(unbind_to, specbind): Use set_internal.
Richard M. Stallman <rms@gnu.org>
parents:
16895
diff
changeset
|
2718 set_internal (symbol, value, 1); |
272 | 2719 } |
2720 | |
2721 void | |
2722 record_unwind_protect (function, arg) | |
20312
d75a1b915e20
(record_unwind_protect): Protoize parameter.
Andreas Schwab <schwab@suse.de>
parents:
19544
diff
changeset
|
2723 Lisp_Object (*function) P_ ((Lisp_Object)); |
272 | 2724 Lisp_Object arg; |
2725 { | |
2726 if (specpdl_ptr == specpdl + specpdl_size) | |
2727 grow_specpdl (); | |
2728 specpdl_ptr->func = function; | |
2729 specpdl_ptr->symbol = Qnil; | |
2730 specpdl_ptr->old_value = arg; | |
2731 specpdl_ptr++; | |
2732 } | |
2733 | |
2734 Lisp_Object | |
2735 unbind_to (count, value) | |
2736 int count; | |
2737 Lisp_Object value; | |
2738 { | |
485 | 2739 int quitf = !NILP (Vquit_flag); |
272 | 2740 struct gcpro gcpro1; |
2741 | |
2742 GCPRO1 (value); | |
2743 | |
2744 Vquit_flag = Qnil; | |
2745 | |
2746 while (specpdl_ptr != specpdl + count) | |
2747 { | |
2748 --specpdl_ptr; | |
2749 if (specpdl_ptr->func != 0) | |
2750 (*specpdl_ptr->func) (specpdl_ptr->old_value); | |
2751 /* Note that a "binding" of nil is really an unwind protect, | |
2752 so in that case the "old value" is a list of forms to evaluate. */ | |
485 | 2753 else if (NILP (specpdl_ptr->symbol)) |
272 | 2754 Fprogn (specpdl_ptr->old_value); |
2755 else | |
16930
e1aba4a05388
(unbind_to, specbind): Use set_internal.
Richard M. Stallman <rms@gnu.org>
parents:
16895
diff
changeset
|
2756 set_internal (specpdl_ptr->symbol, specpdl_ptr->old_value, 1); |
272 | 2757 } |
485 | 2758 if (NILP (Vquit_flag) && quitf) Vquit_flag = Qt; |
272 | 2759 |
2760 UNGCPRO; | |
2761 | |
2762 return value; | |
2763 } | |
2764 | |
2765 #if 0 | |
2766 | |
2767 /* Get the value of symbol's global binding, even if that binding | |
2768 is not now dynamically visible. */ | |
2769 | |
2770 Lisp_Object | |
2771 top_level_value (symbol) | |
2772 Lisp_Object symbol; | |
2773 { | |
2774 register struct specbinding *ptr = specpdl; | |
2775 | |
2776 CHECK_SYMBOL (symbol, 0); | |
2777 for (; ptr != specpdl_ptr; ptr++) | |
2778 { | |
2779 if (EQ (ptr->symbol, symbol)) | |
2780 return ptr->old_value; | |
2781 } | |
2782 return Fsymbol_value (symbol); | |
2783 } | |
2784 | |
2785 Lisp_Object | |
2786 top_level_set (symbol, newval) | |
2787 Lisp_Object symbol, newval; | |
2788 { | |
2789 register struct specbinding *ptr = specpdl; | |
2790 | |
2791 CHECK_SYMBOL (symbol, 0); | |
2792 for (; ptr != specpdl_ptr; ptr++) | |
2793 { | |
2794 if (EQ (ptr->symbol, symbol)) | |
2795 { | |
2796 ptr->old_value = newval; | |
2797 return newval; | |
2798 } | |
2799 } | |
2800 return Fset (symbol, newval); | |
2801 } | |
2802 | |
2803 #endif /* 0 */ | |
2804 | |
2805 DEFUN ("backtrace-debug", Fbacktrace_debug, Sbacktrace_debug, 2, 2, 0, | |
2806 "Set the debug-on-exit flag of eval frame LEVEL levels down to FLAG.\n\ | |
2807 The debugger is entered when that frame exits, if the flag is non-nil.") | |
2808 (level, flag) | |
2809 Lisp_Object level, flag; | |
2810 { | |
2811 register struct backtrace *backlist = backtrace_list; | |
2812 register int i; | |
2813 | |
2814 CHECK_NUMBER (level, 0); | |
2815 | |
2816 for (i = 0; backlist && i < XINT (level); i++) | |
2817 { | |
2818 backlist = backlist->next; | |
2819 } | |
2820 | |
2821 if (backlist) | |
485 | 2822 backlist->debug_on_exit = !NILP (flag); |
272 | 2823 |
2824 return flag; | |
2825 } | |
2826 | |
2827 DEFUN ("backtrace", Fbacktrace, Sbacktrace, 0, 0, "", | |
2828 "Print a trace of Lisp function calls currently active.\n\ | |
2829 Output stream used is value of `standard-output'.") | |
2830 () | |
2831 { | |
2832 register struct backtrace *backlist = backtrace_list; | |
2833 register int i; | |
2834 Lisp_Object tail; | |
2835 Lisp_Object tem; | |
2836 extern Lisp_Object Vprint_level; | |
2837 struct gcpro gcpro1; | |
2838 | |
9306
ac852c183fa1
(Feval, Ffuncall, funcall_lambda, Fbacktrace): Don't use XFASTINT as an
Karl Heuer <kwzh@gnu.org>
parents:
9148
diff
changeset
|
2839 XSETFASTINT (Vprint_level, 3); |
272 | 2840 |
2841 tail = Qnil; | |
2842 GCPRO1 (tail); | |
2843 | |
2844 while (backlist) | |
2845 { | |
2846 write_string (backlist->debug_on_exit ? "* " : " ", 2); | |
2847 if (backlist->nargs == UNEVALLED) | |
2848 { | |
2849 Fprin1 (Fcons (*backlist->function, *backlist->args), Qnil); | |
7533
62e3e25bc8f6
(Fbacktrace): Properly nest parentheses.
Karl Heuer <kwzh@gnu.org>
parents:
7511
diff
changeset
|
2850 write_string ("\n", -1); |
272 | 2851 } |
2852 else | |
2853 { | |
2854 tem = *backlist->function; | |
2855 Fprin1 (tem, Qnil); /* This can QUIT */ | |
2856 write_string ("(", -1); | |
2857 if (backlist->nargs == MANY) | |
2858 { | |
2859 for (tail = *backlist->args, i = 0; | |
485 | 2860 !NILP (tail); |
272 | 2861 tail = Fcdr (tail), i++) |
2862 { | |
2863 if (i) write_string (" ", -1); | |
2864 Fprin1 (Fcar (tail), Qnil); | |
2865 } | |
2866 } | |
2867 else | |
2868 { | |
2869 for (i = 0; i < backlist->nargs; i++) | |
2870 { | |
2871 if (i) write_string (" ", -1); | |
2872 Fprin1 (backlist->args[i], Qnil); | |
2873 } | |
2874 } | |
7533
62e3e25bc8f6
(Fbacktrace): Properly nest parentheses.
Karl Heuer <kwzh@gnu.org>
parents:
7511
diff
changeset
|
2875 write_string (")\n", -1); |
272 | 2876 } |
2877 backlist = backlist->next; | |
2878 } | |
2879 | |
2880 Vprint_level = Qnil; | |
2881 UNGCPRO; | |
2882 return Qnil; | |
2883 } | |
2884 | |
2885 DEFUN ("backtrace-frame", Fbacktrace_frame, Sbacktrace_frame, 1, 1, "", | |
14073
0df4b4f2a2a1
(Fmacroexpand, Fthrow, Fbacktrace_frame): Harmonize arguments with
Erik Naggum <erik@naggum.no>
parents:
13945
diff
changeset
|
2886 "Return the function and arguments NFRAMES up from current execution point.\n\ |
272 | 2887 If that frame has not evaluated the arguments yet (or is a special form),\n\ |
2888 the value is (nil FUNCTION ARG-FORMS...).\n\ | |
2889 If that frame has evaluated its arguments and called its function already,\n\ | |
2890 the value is (t FUNCTION ARG-VALUES...).\n\ | |
2891 A &rest arg is represented as the tail of the list ARG-VALUES.\n\ | |
2892 FUNCTION is whatever was supplied as car of evaluated list,\n\ | |
2893 or a lambda expression for macro calls.\n\ | |
14073
0df4b4f2a2a1
(Fmacroexpand, Fthrow, Fbacktrace_frame): Harmonize arguments with
Erik Naggum <erik@naggum.no>
parents:
13945
diff
changeset
|
2894 If NFRAMES is more than the number of frames, the value is nil.") |
272 | 2895 (nframes) |
2896 Lisp_Object nframes; | |
2897 { | |
2898 register struct backtrace *backlist = backtrace_list; | |
2899 register int i; | |
2900 Lisp_Object tem; | |
2901 | |
2902 CHECK_NATNUM (nframes, 0); | |
2903 | |
2904 /* Find the frame requested. */ | |
7533
62e3e25bc8f6
(Fbacktrace): Properly nest parentheses.
Karl Heuer <kwzh@gnu.org>
parents:
7511
diff
changeset
|
2905 for (i = 0; backlist && i < XFASTINT (nframes); i++) |
272 | 2906 backlist = backlist->next; |
2907 | |
2908 if (!backlist) | |
2909 return Qnil; | |
2910 if (backlist->nargs == UNEVALLED) | |
2911 return Fcons (Qnil, Fcons (*backlist->function, *backlist->args)); | |
2912 else | |
2913 { | |
2914 if (backlist->nargs == MANY) | |
2915 tem = *backlist->args; | |
2916 else | |
2917 tem = Flist (backlist->nargs, backlist->args); | |
2918 | |
2919 return Fcons (Qt, Fcons (*backlist->function, tem)); | |
2920 } | |
2921 } | |
2922 | |
21514 | 2923 void |
272 | 2924 syms_of_eval () |
2925 { | |
2926 DEFVAR_INT ("max-specpdl-size", &max_specpdl_size, | |
18920
9c03cae980ed
(syms_of_eval): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18636
diff
changeset
|
2927 "*Limit on number of Lisp variable bindings & unwind-protects.\n\ |
9c03cae980ed
(syms_of_eval): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18636
diff
changeset
|
2928 If Lisp code tries to make more than this many at once,\n\ |
9c03cae980ed
(syms_of_eval): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18636
diff
changeset
|
2929 an error is signaled."); |
272 | 2930 |
2931 DEFVAR_INT ("max-lisp-eval-depth", &max_lisp_eval_depth, | |
18920
9c03cae980ed
(syms_of_eval): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18636
diff
changeset
|
2932 "*Limit on depth in `eval', `apply' and `funcall' before error.\n\ |
272 | 2933 This limit is to catch infinite recursions for you before they cause\n\ |
2934 actual stack overflow in C, which would be fatal for Emacs.\n\ | |
2935 You can safely make it considerably larger than its default value,\n\ | |
2936 if that proves inconveniently small."); | |
2937 | |
2938 DEFVAR_LISP ("quit-flag", &Vquit_flag, | |
2939 "Non-nil causes `eval' to abort, unless `inhibit-quit' is non-nil.\n\ | |
7511
9ec3fc16ab3a
(syms_of_eval): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
7353
diff
changeset
|
2940 Typing C-g sets `quit-flag' non-nil, regardless of `inhibit-quit'."); |
272 | 2941 Vquit_flag = Qnil; |
2942 | |
2943 DEFVAR_LISP ("inhibit-quit", &Vinhibit_quit, | |
2944 "Non-nil inhibits C-g quitting from happening immediately.\n\ | |
2945 Note that `quit-flag' will still be set by typing C-g,\n\ | |
13945
6a653c300631
(syms_of_eval): Doc fix for inhibit-quit.
Karl Heuer <kwzh@gnu.org>
parents:
13768
diff
changeset
|
2946 so a quit will be signaled as soon as `inhibit-quit' is nil.\n\ |
272 | 2947 To prevent this happening, set `quit-flag' to nil\n\ |
2948 before making `inhibit-quit' nil."); | |
2949 Vinhibit_quit = Qnil; | |
2950 | |
381 | 2951 Qinhibit_quit = intern ("inhibit-quit"); |
2952 staticpro (&Qinhibit_quit); | |
2953 | |
272 | 2954 Qautoload = intern ("autoload"); |
2955 staticpro (&Qautoload); | |
2956 | |
2957 Qdebug_on_error = intern ("debug-on-error"); | |
2958 staticpro (&Qdebug_on_error); | |
2959 | |
2960 Qmacro = intern ("macro"); | |
2961 staticpro (&Qmacro); | |
2962 | |
2963 /* Note that the process handling also uses Qexit, but we don't want | |
2964 to staticpro it twice, so we just do it here. */ | |
2965 Qexit = intern ("exit"); | |
2966 staticpro (&Qexit); | |
2967 | |
2968 Qinteractive = intern ("interactive"); | |
2969 staticpro (&Qinteractive); | |
2970 | |
2971 Qcommandp = intern ("commandp"); | |
2972 staticpro (&Qcommandp); | |
2973 | |
2974 Qdefun = intern ("defun"); | |
2975 staticpro (&Qdefun); | |
2976 | |
2977 Qand_rest = intern ("&rest"); | |
2978 staticpro (&Qand_rest); | |
2979 | |
2980 Qand_optional = intern ("&optional"); | |
2981 staticpro (&Qand_optional); | |
2982 | |
684 | 2983 DEFVAR_LISP ("stack-trace-on-error", &Vstack_trace_on_error, |
272 | 2984 "*Non-nil means automatically display a backtrace buffer\n\ |
684 | 2985 after any error that is handled by the editor command loop.\n\ |
2986 If the value is a list, an error only means to display a backtrace\n\ | |
2987 if one of its condition symbols appears in the list."); | |
2988 Vstack_trace_on_error = Qnil; | |
272 | 2989 |
684 | 2990 DEFVAR_LISP ("debug-on-error", &Vdebug_on_error, |
272 | 2991 "*Non-nil means enter debugger if an error is signaled.\n\ |
2992 Does not apply to errors handled by `condition-case'.\n\ | |
684 | 2993 If the value is a list, an error only means to enter the debugger\n\ |
2994 if one of its condition symbols appears in the list.\n\ | |
272 | 2995 See also variable `debug-on-quit'."); |
684 | 2996 Vdebug_on_error = Qnil; |
272 | 2997 |
13768 | 2998 DEFVAR_LISP ("debug-ignored-errors", &Vdebug_ignored_errors, |
2999 "*List of errors for which the debugger should not be called.\n\ | |
3000 Each element may be a condition-name or a regexp that matches error messages.\n\ | |
3001 If any element applies to a given error, that error skips the debugger\n\ | |
3002 and just returns to top level.\n\ | |
3003 This overrides the variable `debug-on-error'.\n\ | |
3004 It does not apply to errors handled by `condition-case'."); | |
3005 Vdebug_ignored_errors = Qnil; | |
3006 | |
272 | 3007 DEFVAR_BOOL ("debug-on-quit", &debug_on_quit, |
7511
9ec3fc16ab3a
(syms_of_eval): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
7353
diff
changeset
|
3008 "*Non-nil means enter debugger if quit is signaled (C-g, for example).\n\ |
940 | 3009 Does not apply if quit is handled by a `condition-case'."); |
272 | 3010 debug_on_quit = 0; |
3011 | |
3012 DEFVAR_BOOL ("debug-on-next-call", &debug_on_next_call, | |
3013 "Non-nil means enter debugger before next `eval', `apply' or `funcall'."); | |
3014 | |
3015 DEFVAR_LISP ("debugger", &Vdebugger, | |
3016 "Function to call to invoke debugger.\n\ | |
3017 If due to frame exit, args are `exit' and the value being returned;\n\ | |
3018 this function's value will be returned instead of that.\n\ | |
3019 If due to error, args are `error' and a list of the args to `signal'.\n\ | |
3020 If due to `apply' or `funcall' entry, one arg, `lambda'.\n\ | |
3021 If due to `eval' entry, one arg, t."); | |
3022 Vdebugger = Qnil; | |
3023 | |
16355
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
3024 DEFVAR_LISP ("signal-hook-function", &Vsignal_hook_function, |
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
3025 "If non-nil, this is a function for `signal' to call.\n\ |
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
3026 It receives the same arguments that `signal' was given.\n\ |
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
3027 The Edebug package uses this to regain control."); |
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
3028 Vsignal_hook_function = Qnil; |
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
3029 |
272 | 3030 Qmocklisp_arguments = intern ("mocklisp-arguments"); |
3031 staticpro (&Qmocklisp_arguments); | |
3032 DEFVAR_LISP ("mocklisp-arguments", &Vmocklisp_arguments, | |
3033 "While in a mocklisp function, the list of its unevaluated args."); | |
3034 Vmocklisp_arguments = Qt; | |
3035 | |
16443
0128b923d281
(Vdebug_on_signal): Renamed from Vdebug_force.
Richard M. Stallman <rms@gnu.org>
parents:
16355
diff
changeset
|
3036 DEFVAR_LISP ("debug-on-signal", &Vdebug_on_signal, |
16355
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
3037 "*Non-nil means call the debugger regardless of condition handlers.\n\ |
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
3038 Note that `debug-on-error', `debug-on-quit' and friends\n\ |
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
3039 still determine whether to handle the particular condition."); |
16443
0128b923d281
(Vdebug_on_signal): Renamed from Vdebug_force.
Richard M. Stallman <rms@gnu.org>
parents:
16355
diff
changeset
|
3040 Vdebug_on_signal = Qnil; |
16355
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
3041 |
16296
584310941e70
(syms_of_eval): Initialize Vrun_hooks here.
Richard M. Stallman <rms@gnu.org>
parents:
16113
diff
changeset
|
3042 Vrun_hooks = intern ("run-hooks"); |
584310941e70
(syms_of_eval): Initialize Vrun_hooks here.
Richard M. Stallman <rms@gnu.org>
parents:
16113
diff
changeset
|
3043 staticpro (&Vrun_hooks); |
272 | 3044 |
3045 staticpro (&Vautoload_queue); | |
3046 Vautoload_queue = Qnil; | |
3047 | |
3048 defsubr (&Sor); | |
3049 defsubr (&Sand); | |
3050 defsubr (&Sif); | |
3051 defsubr (&Scond); | |
3052 defsubr (&Sprogn); | |
3053 defsubr (&Sprog1); | |
3054 defsubr (&Sprog2); | |
3055 defsubr (&Ssetq); | |
3056 defsubr (&Squote); | |
3057 defsubr (&Sfunction); | |
3058 defsubr (&Sdefun); | |
3059 defsubr (&Sdefmacro); | |
3060 defsubr (&Sdefvar); | |
3061 defsubr (&Sdefconst); | |
3062 defsubr (&Suser_variable_p); | |
3063 defsubr (&Slet); | |
3064 defsubr (&SletX); | |
3065 defsubr (&Swhile); | |
3066 defsubr (&Smacroexpand); | |
3067 defsubr (&Scatch); | |
3068 defsubr (&Sthrow); | |
3069 defsubr (&Sunwind_protect); | |
3070 defsubr (&Scondition_case); | |
3071 defsubr (&Ssignal); | |
3072 defsubr (&Sinteractive_p); | |
3073 defsubr (&Scommandp); | |
3074 defsubr (&Sautoload); | |
3075 defsubr (&Seval); | |
3076 defsubr (&Sapply); | |
12732
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
3077 defsubr (&Sfuncall); |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
3078 defsubr (&Srun_hooks); |
12711
a8feaa42d775
(syms_of_eval): Add missing defsubr.
Karl Heuer <kwzh@gnu.org>
parents:
12663
diff
changeset
|
3079 defsubr (&Srun_hook_with_args); |
12732
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
3080 defsubr (&Srun_hook_with_args_until_success); |
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
3081 defsubr (&Srun_hook_with_args_until_failure); |
11205
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
3082 defsubr (&Sfetch_bytecode); |
272 | 3083 defsubr (&Sbacktrace_debug); |
3084 defsubr (&Sbacktrace); | |
3085 defsubr (&Sbacktrace_frame); | |
3086 } |