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