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