1 /* Evaluator for GNU Emacs Lisp interpreter.
2 Copyright (C) 1985-1987, 1993-1995, 1999-2011 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
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
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
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.
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
23 #include "blockinput.h"
26 #include "dispextern.h"
27 #include "frame.h" /* For XFRAME. */
33 /* This definition is duplicated in alloc.c and keyboard.c */
34 /* Putting it in lisp.h makes cc bomb out! */
38 struct backtrace
*next
;
39 Lisp_Object
*function
;
40 Lisp_Object
*args
; /* Points to vector of args. */
41 int nargs
; /* Length of vector.
42 If nargs is UNEVALLED, args points to slot holding
43 list of unevalled args */
45 /* Nonzero means call value of debugger when done with this operation. */
49 struct backtrace
*backtrace_list
;
51 struct catchtag
*catchlist
;
54 /* Count levels of GCPRO to detect failure to UNGCPRO. */
58 Lisp_Object Qautoload
, Qmacro
, Qexit
, Qinteractive
, Qcommandp
, Qdefun
;
59 Lisp_Object Qinhibit_quit
;
60 Lisp_Object Qand_rest
, Qand_optional
;
61 Lisp_Object Qdebug_on_error
;
64 Lisp_Object Qinternal_interpreter_environment
, Qclosure
;
68 /* This holds either the symbol `run-hooks' or nil.
69 It is nil at an early stage of startup, and when Emacs
72 Lisp_Object Vrun_hooks
;
74 /* Non-nil means record all fset's and provide's, to be undone
75 if the file being autoloaded is not fully loaded.
76 They are recorded by being consed onto the front of Vautoload_queue:
77 (FUN . ODEF) for a defun, (0 . OFEATURES) for a provide. */
79 Lisp_Object Vautoload_queue
;
81 /* When lexical binding is being used, this is non-nil, and contains an
82 alist of lexically-bound variable, or (t), indicating an empty
83 environment. The lisp name of this variable is
84 `internal-interpreter-environment'. Every element of this list
85 can be either a cons (VAR . VAL) specifying a lexical binding,
86 or a single symbol VAR indicating that this variable should use
89 Lisp_Object Vinternal_interpreter_environment
;
91 /* Current number of specbindings allocated in specpdl. */
93 EMACS_INT specpdl_size
;
95 /* Pointer to beginning of specpdl. */
97 struct specbinding
*specpdl
;
99 /* Pointer to first unused element in specpdl. */
101 struct specbinding
*specpdl_ptr
;
103 /* Depth in Lisp evaluations and function calls. */
105 EMACS_INT lisp_eval_depth
;
107 /* The value of num_nonmacro_input_events as of the last time we
108 started to enter the debugger. If we decide to enter the debugger
109 again when this is still equal to num_nonmacro_input_events, then we
110 know that the debugger itself has an error, and we should just
111 signal the error instead of entering an infinite loop of debugger
114 int when_entered_debugger
;
116 /* The function from which the last `signal' was called. Set in
119 Lisp_Object Vsignaling_function
;
121 /* Set to non-zero while processing X events. Checked in Feval to
122 make sure the Lisp interpreter isn't called from a signal handler,
123 which is unsafe because the interpreter isn't reentrant. */
127 static Lisp_Object
apply_lambda (Lisp_Object fun
, Lisp_Object args
);
128 static Lisp_Object
funcall_lambda (Lisp_Object
, int, Lisp_Object
*);
129 static void unwind_to_catch (struct catchtag
*, Lisp_Object
) NO_RETURN
;
130 static int interactive_p (int);
133 init_eval_once (void)
136 specpdl
= (struct specbinding
*) xmalloc (specpdl_size
* sizeof (struct specbinding
));
137 specpdl_ptr
= specpdl
;
138 /* Don't forget to update docs (lispref node "Local Variables"). */
139 max_specpdl_size
= 1300; /* 1000 is not enough for CEDET's c-by.el. */
140 max_lisp_eval_depth
= 600;
148 specpdl_ptr
= specpdl
;
153 debug_on_next_call
= 0;
158 /* This is less than the initial value of num_nonmacro_input_events. */
159 when_entered_debugger
= -1;
162 /* unwind-protect function used by call_debugger. */
165 restore_stack_limits (Lisp_Object data
)
167 max_specpdl_size
= XINT (XCAR (data
));
168 max_lisp_eval_depth
= XINT (XCDR (data
));
172 /* Call the Lisp debugger, giving it argument ARG. */
175 call_debugger (Lisp_Object arg
)
177 int debug_while_redisplaying
;
178 int count
= SPECPDL_INDEX ();
180 EMACS_INT old_max
= max_specpdl_size
;
182 /* Temporarily bump up the stack limits,
183 so the debugger won't run out of stack. */
185 max_specpdl_size
+= 1;
186 record_unwind_protect (restore_stack_limits
,
187 Fcons (make_number (old_max
),
188 make_number (max_lisp_eval_depth
)));
189 max_specpdl_size
= old_max
;
191 if (lisp_eval_depth
+ 40 > max_lisp_eval_depth
)
192 max_lisp_eval_depth
= lisp_eval_depth
+ 40;
194 if (SPECPDL_INDEX () + 100 > max_specpdl_size
)
195 max_specpdl_size
= SPECPDL_INDEX () + 100;
197 #ifdef HAVE_WINDOW_SYSTEM
198 if (display_hourglass_p
)
202 debug_on_next_call
= 0;
203 when_entered_debugger
= num_nonmacro_input_events
;
205 /* Resetting redisplaying_p to 0 makes sure that debug output is
206 displayed if the debugger is invoked during redisplay. */
207 debug_while_redisplaying
= redisplaying_p
;
209 specbind (intern ("debugger-may-continue"),
210 debug_while_redisplaying
? Qnil
: Qt
);
211 specbind (Qinhibit_redisplay
, Qnil
);
212 specbind (Qdebug_on_error
, Qnil
);
214 #if 0 /* Binding this prevents execution of Lisp code during
215 redisplay, which necessarily leads to display problems. */
216 specbind (Qinhibit_eval_during_redisplay
, Qt
);
219 val
= apply1 (Vdebugger
, arg
);
221 /* Interrupting redisplay and resuming it later is not safe under
222 all circumstances. So, when the debugger returns, abort the
223 interrupted redisplay by going back to the top-level. */
224 if (debug_while_redisplaying
)
227 return unbind_to (count
, val
);
231 do_debug_on_call (Lisp_Object code
)
233 debug_on_next_call
= 0;
234 backtrace_list
->debug_on_exit
= 1;
235 call_debugger (Fcons (code
, Qnil
));
238 /* NOTE!!! Every function that can call EVAL must protect its args
239 and temporaries from garbage collection while it needs them.
240 The definition of `For' shows what you have to do. */
242 DEFUN ("or", For
, Sor
, 0, UNEVALLED
, 0,
243 doc
: /* Eval args until one of them yields non-nil, then return that value.
244 The remaining args are not evalled at all.
245 If all args return nil, return nil.
246 usage: (or CONDITIONS...) */)
249 register Lisp_Object val
= Qnil
;
256 val
= eval_sub (XCAR (args
));
266 DEFUN ("and", Fand
, Sand
, 0, UNEVALLED
, 0,
267 doc
: /* Eval args until one of them yields nil, then return nil.
268 The remaining args are not evalled at all.
269 If no arg yields nil, return the last arg's value.
270 usage: (and CONDITIONS...) */)
273 register Lisp_Object val
= Qt
;
280 val
= eval_sub (XCAR (args
));
290 DEFUN ("if", Fif
, Sif
, 2, UNEVALLED
, 0,
291 doc
: /* If COND yields non-nil, do THEN, else do ELSE...
292 Returns the value of THEN or the value of the last of the ELSE's.
293 THEN must be one expression, but ELSE... can be zero or more expressions.
294 If COND yields nil, and there are no ELSE's, the value is nil.
295 usage: (if COND THEN ELSE...) */)
298 register Lisp_Object cond
;
302 cond
= eval_sub (Fcar (args
));
306 return eval_sub (Fcar (Fcdr (args
)));
307 return Fprogn (Fcdr (Fcdr (args
)));
310 DEFUN ("cond", Fcond
, Scond
, 0, UNEVALLED
, 0,
311 doc
: /* Try each clause until one succeeds.
312 Each clause looks like (CONDITION BODY...). CONDITION is evaluated
313 and, if the value is non-nil, this clause succeeds:
314 then the expressions in BODY are evaluated and the last one's
315 value is the value of the cond-form.
316 If no clause succeeds, cond returns nil.
317 If a clause has one element, as in (CONDITION),
318 CONDITION's value if non-nil is returned from the cond-form.
319 usage: (cond CLAUSES...) */)
322 register Lisp_Object clause
, val
;
329 clause
= Fcar (args
);
330 val
= eval_sub (Fcar (clause
));
333 if (!EQ (XCDR (clause
), Qnil
))
334 val
= Fprogn (XCDR (clause
));
344 DEFUN ("progn", Fprogn
, Sprogn
, 0, UNEVALLED
, 0,
345 doc
: /* Eval BODY forms sequentially and return value of last one.
346 usage: (progn BODY...) */)
349 register Lisp_Object val
= Qnil
;
356 val
= eval_sub (XCAR (args
));
364 DEFUN ("prog1", Fprog1
, Sprog1
, 1, UNEVALLED
, 0,
365 doc
: /* Eval FIRST and BODY sequentially; return value from FIRST.
366 The value of FIRST is saved during the evaluation of the remaining args,
367 whose values are discarded.
368 usage: (prog1 FIRST BODY...) */)
372 register Lisp_Object args_left
;
373 struct gcpro gcpro1
, gcpro2
;
374 register int argnum
= 0;
386 val
= eval_sub (Fcar (args_left
));
388 eval_sub (Fcar (args_left
));
389 args_left
= Fcdr (args_left
);
391 while (!NILP(args_left
));
397 DEFUN ("prog2", Fprog2
, Sprog2
, 2, UNEVALLED
, 0,
398 doc
: /* Eval FORM1, FORM2 and BODY sequentially; return value from FORM2.
399 The value of FORM2 is saved during the evaluation of the
400 remaining args, whose values are discarded.
401 usage: (prog2 FORM1 FORM2 BODY...) */)
405 register Lisp_Object args_left
;
406 struct gcpro gcpro1
, gcpro2
;
407 register int argnum
= -1;
421 val
= eval_sub (Fcar (args_left
));
423 eval_sub (Fcar (args_left
));
424 args_left
= Fcdr (args_left
);
426 while (!NILP (args_left
));
432 DEFUN ("setq", Fsetq
, Ssetq
, 0, UNEVALLED
, 0,
433 doc
: /* Set each SYM to the value of its VAL.
434 The symbols SYM are variables; they are literal (not evaluated).
435 The values VAL are expressions; they are evaluated.
436 Thus, (setq x (1+ y)) sets `x' to the value of `(1+ y)'.
437 The second VAL is not computed until after the first SYM is set, and so on;
438 each VAL can use the new value of variables set earlier in the `setq'.
439 The return value of the `setq' form is the value of the last VAL.
440 usage: (setq [SYM VAL]...) */)
443 register Lisp_Object args_left
;
444 register Lisp_Object val
, sym
, lex_binding
;
455 val
= eval_sub (Fcar (Fcdr (args_left
)));
456 sym
= Fcar (args_left
);
458 /* Like for eval_sub, we do not check declared_special here since
459 it's been done when let-binding. */
460 if (!NILP (Vinternal_interpreter_environment
) /* Mere optimization! */
462 && !NILP (lex_binding
463 = Fassq (sym
, Vinternal_interpreter_environment
)))
464 XSETCDR (lex_binding
, val
); /* SYM is lexically bound. */
466 Fset (sym
, val
); /* SYM is dynamically bound. */
468 args_left
= Fcdr (Fcdr (args_left
));
470 while (!NILP(args_left
));
476 DEFUN ("quote", Fquote
, Squote
, 1, UNEVALLED
, 0,
477 doc
: /* Return the argument, without evaluating it. `(quote x)' yields `x'.
478 usage: (quote ARG) */)
481 if (!NILP (Fcdr (args
)))
482 xsignal2 (Qwrong_number_of_arguments
, Qquote
, Flength (args
));
486 DEFUN ("function", Ffunction
, Sfunction
, 1, UNEVALLED
, 0,
487 doc
: /* Like `quote', but preferred for objects which are functions.
488 In byte compilation, `function' causes its argument to be compiled.
489 `quote' cannot do that.
490 usage: (function ARG) */)
493 Lisp_Object quoted
= XCAR (args
);
495 if (!NILP (Fcdr (args
)))
496 xsignal2 (Qwrong_number_of_arguments
, Qfunction
, Flength (args
));
498 if (!NILP (Vinternal_interpreter_environment
)
500 && EQ (XCAR (quoted
), Qlambda
))
501 /* This is a lambda expression within a lexical environment;
502 return an interpreted closure instead of a simple lambda. */
503 return Fcons (Qclosure
, Fcons (Vinternal_interpreter_environment
, quoted
));
505 /* Simply quote the argument. */
510 DEFUN ("interactive-p", Finteractive_p
, Sinteractive_p
, 0, 0, 0,
511 doc
: /* Return t if the containing function was run directly by user input.
512 This means that the function was called with `call-interactively'
513 \(which includes being called as the binding of a key)
514 and input is currently coming from the keyboard (not a keyboard macro),
515 and Emacs is not running in batch mode (`noninteractive' is nil).
517 The only known proper use of `interactive-p' is in deciding whether to
518 display a helpful message, or how to display it. If you're thinking
519 of using it for any other purpose, it is quite likely that you're
520 making a mistake. Think: what do you want to do when the command is
521 called from a keyboard macro?
523 To test whether your function was called with `call-interactively',
524 either (i) add an extra optional argument and give it an `interactive'
525 spec that specifies non-nil unconditionally (such as \"p\"); or (ii)
526 use `called-interactively-p'. */)
529 return interactive_p (1) ? Qt
: Qnil
;
533 DEFUN ("called-interactively-p", Fcalled_interactively_p
, Scalled_interactively_p
, 0, 1, 0,
534 doc
: /* Return t if the containing function was called by `call-interactively'.
535 If KIND is `interactive', then only return t if the call was made
536 interactively by the user, i.e. not in `noninteractive' mode nor
537 when `executing-kbd-macro'.
538 If KIND is `any', on the other hand, it will return t for any kind of
539 interactive call, including being called as the binding of a key, or
540 from a keyboard macro, or in `noninteractive' mode.
542 The only known proper use of `interactive' for KIND is in deciding
543 whether to display a helpful message, or how to display it. If you're
544 thinking of using it for any other purpose, it is quite likely that
545 you're making a mistake. Think: what do you want to do when the
546 command is called from a keyboard macro?
548 This function is meant for implementing advice and other
549 function-modifying features. Instead of using this, it is sometimes
550 cleaner to give your function an extra optional argument whose
551 `interactive' spec specifies non-nil unconditionally (\"p\" is a good
552 way to do this), or via (not (or executing-kbd-macro noninteractive)). */)
555 return ((INTERACTIVE
|| !EQ (kind
, intern ("interactive")))
556 && interactive_p (1)) ? Qt
: Qnil
;
560 /* Return 1 if function in which this appears was called using
563 EXCLUDE_SUBRS_P non-zero means always return 0 if the function
564 called is a built-in. */
567 interactive_p (int exclude_subrs_p
)
569 struct backtrace
*btp
;
572 btp
= backtrace_list
;
574 /* If this isn't a byte-compiled function, there may be a frame at
575 the top for Finteractive_p. If so, skip it. */
576 fun
= Findirect_function (*btp
->function
, Qnil
);
577 if (SUBRP (fun
) && (XSUBR (fun
) == &Sinteractive_p
578 || XSUBR (fun
) == &Scalled_interactively_p
))
581 /* If we're running an Emacs 18-style byte-compiled function, there
582 may be a frame for Fbytecode at the top level. In any version of
583 Emacs there can be Fbytecode frames for subexpressions evaluated
584 inside catch and condition-case. Skip past them.
586 If this isn't a byte-compiled function, then we may now be
587 looking at several frames for special forms. Skip past them. */
589 && (EQ (*btp
->function
, Qbytecode
)
590 || btp
->nargs
== UNEVALLED
))
593 /* btp now points at the frame of the innermost function that isn't
594 a special form, ignoring frames for Finteractive_p and/or
595 Fbytecode at the top. If this frame is for a built-in function
596 (such as load or eval-region) return nil. */
597 fun
= Findirect_function (*btp
->function
, Qnil
);
598 if (exclude_subrs_p
&& SUBRP (fun
))
601 /* btp points to the frame of a Lisp function that called interactive-p.
602 Return t if that function was called interactively. */
603 if (btp
&& btp
->next
&& EQ (*btp
->next
->function
, Qcall_interactively
))
609 DEFUN ("defun", Fdefun
, Sdefun
, 2, UNEVALLED
, 0,
610 doc
: /* Define NAME as a function.
611 The definition is (lambda ARGLIST [DOCSTRING] BODY...).
612 See also the function `interactive'.
613 usage: (defun NAME ARGLIST [DOCSTRING] BODY...) */)
616 register Lisp_Object fn_name
;
617 register Lisp_Object defn
;
619 fn_name
= Fcar (args
);
620 CHECK_SYMBOL (fn_name
);
621 defn
= Fcons (Qlambda
, Fcdr (args
));
622 if (!NILP (Vinternal_interpreter_environment
)) /* Mere optimization! */
623 defn
= Ffunction (Fcons (defn
, Qnil
));
624 if (!NILP (Vpurify_flag
))
625 defn
= Fpurecopy (defn
);
626 if (CONSP (XSYMBOL (fn_name
)->function
)
627 && EQ (XCAR (XSYMBOL (fn_name
)->function
), Qautoload
))
628 LOADHIST_ATTACH (Fcons (Qt
, fn_name
));
629 Ffset (fn_name
, defn
);
630 LOADHIST_ATTACH (Fcons (Qdefun
, fn_name
));
634 DEFUN ("defmacro", Fdefmacro
, Sdefmacro
, 2, UNEVALLED
, 0,
635 doc
: /* Define NAME as a macro.
636 The actual definition looks like
637 (macro lambda ARGLIST [DOCSTRING] [DECL] BODY...).
638 When the macro is called, as in (NAME ARGS...),
639 the function (lambda ARGLIST BODY...) is applied to
640 the list ARGS... as it appears in the expression,
641 and the result should be a form to be evaluated instead of the original.
643 DECL is a declaration, optional, which can specify how to indent
644 calls to this macro, how Edebug should handle it, and which argument
645 should be treated as documentation. It looks like this:
647 The elements can look like this:
649 Set NAME's `lisp-indent-function' property to INDENT.
652 Set NAME's `edebug-form-spec' property to DEBUG. (This is
653 equivalent to writing a `def-edebug-spec' for the macro.)
656 Set NAME's `doc-string-elt' property to ELT.
658 usage: (defmacro NAME ARGLIST [DOCSTRING] [DECL] BODY...) */)
661 register Lisp_Object fn_name
;
662 register Lisp_Object defn
;
663 Lisp_Object lambda_list
, doc
, tail
;
665 fn_name
= Fcar (args
);
666 CHECK_SYMBOL (fn_name
);
667 lambda_list
= Fcar (Fcdr (args
));
668 tail
= Fcdr (Fcdr (args
));
671 if (STRINGP (Fcar (tail
)))
677 if (CONSP (Fcar (tail
))
678 && EQ (Fcar (Fcar (tail
)), Qdeclare
))
680 if (!NILP (Vmacro_declaration_function
))
684 call2 (Vmacro_declaration_function
, fn_name
, Fcar (tail
));
692 tail
= Fcons (lambda_list
, tail
);
694 tail
= Fcons (lambda_list
, Fcons (doc
, tail
));
696 defn
= Fcons (Qlambda
, tail
);
697 if (!NILP (Vinternal_interpreter_environment
)) /* Mere optimization! */
698 defn
= Ffunction (Fcons (defn
, Qnil
));
699 defn
= Fcons (Qmacro
, defn
);
701 if (!NILP (Vpurify_flag
))
702 defn
= Fpurecopy (defn
);
703 if (CONSP (XSYMBOL (fn_name
)->function
)
704 && EQ (XCAR (XSYMBOL (fn_name
)->function
), Qautoload
))
705 LOADHIST_ATTACH (Fcons (Qt
, fn_name
));
706 Ffset (fn_name
, defn
);
707 LOADHIST_ATTACH (Fcons (Qdefun
, fn_name
));
712 DEFUN ("defvaralias", Fdefvaralias
, Sdefvaralias
, 2, 3, 0,
713 doc
: /* Make NEW-ALIAS a variable alias for symbol BASE-VARIABLE.
714 Aliased variables always have the same value; setting one sets the other.
715 Third arg DOCSTRING, if non-nil, is documentation for NEW-ALIAS. If it is
716 omitted or nil, NEW-ALIAS gets the documentation string of BASE-VARIABLE,
717 or of the variable at the end of the chain of aliases, if BASE-VARIABLE is
718 itself an alias. If NEW-ALIAS is bound, and BASE-VARIABLE is not,
719 then the value of BASE-VARIABLE is set to that of NEW-ALIAS.
720 The return value is BASE-VARIABLE. */)
721 (Lisp_Object new_alias
, Lisp_Object base_variable
, Lisp_Object docstring
)
723 struct Lisp_Symbol
*sym
;
725 CHECK_SYMBOL (new_alias
);
726 CHECK_SYMBOL (base_variable
);
728 sym
= XSYMBOL (new_alias
);
731 /* Not sure why, but why not? */
732 error ("Cannot make a constant an alias");
734 switch (sym
->redirect
)
736 case SYMBOL_FORWARDED
:
737 error ("Cannot make an internal variable an alias");
738 case SYMBOL_LOCALIZED
:
739 error ("Don't know how to make a localized variable an alias");
742 /* http://lists.gnu.org/archive/html/emacs-devel/2008-04/msg00834.html
743 If n_a is bound, but b_v is not, set the value of b_v to n_a,
744 so that old-code that affects n_a before the aliasing is setup
746 if (NILP (Fboundp (base_variable
)))
747 set_internal (base_variable
, find_symbol_value (new_alias
), Qnil
, 1);
750 struct specbinding
*p
;
752 for (p
= specpdl_ptr
- 1; p
>= specpdl
; p
--)
755 CONSP (p
->symbol
) ? XCAR (p
->symbol
) : p
->symbol
)))
756 error ("Don't know how to make a let-bound variable an alias");
759 sym
->declared_special
= 1;
760 sym
->redirect
= SYMBOL_VARALIAS
;
761 SET_SYMBOL_ALIAS (sym
, XSYMBOL (base_variable
));
762 sym
->constant
= SYMBOL_CONSTANT_P (base_variable
);
763 LOADHIST_ATTACH (new_alias
);
764 /* Even if docstring is nil: remove old docstring. */
765 Fput (new_alias
, Qvariable_documentation
, docstring
);
767 return base_variable
;
771 DEFUN ("defvar", Fdefvar
, Sdefvar
, 1, UNEVALLED
, 0,
772 doc
: /* Define SYMBOL as a variable, and return SYMBOL.
773 You are not required to define a variable in order to use it,
774 but the definition can supply documentation and an initial value
775 in a way that tags can recognize.
777 INITVALUE is evaluated, and used to set SYMBOL, only if SYMBOL's value is void.
778 If SYMBOL is buffer-local, its default value is what is set;
779 buffer-local values are not affected.
780 INITVALUE and DOCSTRING are optional.
781 If DOCSTRING starts with *, this variable is identified as a user option.
782 This means that M-x set-variable recognizes it.
783 See also `user-variable-p'.
784 If INITVALUE is missing, SYMBOL's value is not set.
786 If SYMBOL has a local binding, then this form affects the local
787 binding. This is usually not what you want. Thus, if you need to
788 load a file defining variables, with this form or with `defconst' or
789 `defcustom', you should always load that file _outside_ any bindings
790 for these variables. \(`defconst' and `defcustom' behave similarly in
792 usage: (defvar SYMBOL &optional INITVALUE DOCSTRING) */)
795 register Lisp_Object sym
, tem
, tail
;
799 if (!NILP (Fcdr (Fcdr (tail
))))
800 error ("Too many arguments");
802 tem
= Fdefault_boundp (sym
);
806 /* Do it before evaluating the initial value, for self-references. */
807 XSYMBOL (sym
)->declared_special
= 1;
809 if (SYMBOL_CONSTANT_P (sym
))
811 /* For upward compatibility, allow (defvar :foo (quote :foo)). */
812 Lisp_Object tem
= Fcar (tail
);
814 && EQ (XCAR (tem
), Qquote
)
815 && CONSP (XCDR (tem
))
816 && EQ (XCAR (XCDR (tem
)), sym
)))
817 error ("Constant symbol `%s' specified in defvar",
818 SDATA (SYMBOL_NAME (sym
)));
822 Fset_default (sym
, eval_sub (Fcar (tail
)));
824 { /* Check if there is really a global binding rather than just a let
825 binding that shadows the global unboundness of the var. */
826 volatile struct specbinding
*pdl
= specpdl_ptr
;
827 while (--pdl
>= specpdl
)
829 if (EQ (pdl
->symbol
, sym
) && !pdl
->func
830 && EQ (pdl
->old_value
, Qunbound
))
832 message_with_string ("Warning: defvar ignored because %s is let-bound",
833 SYMBOL_NAME (sym
), 1);
842 if (!NILP (Vpurify_flag
))
843 tem
= Fpurecopy (tem
);
844 Fput (sym
, Qvariable_documentation
, tem
);
846 LOADHIST_ATTACH (sym
);
848 else if (!NILP (Vinternal_interpreter_environment
)
849 && !XSYMBOL (sym
)->declared_special
)
850 /* A simple (defvar foo) with lexical scoping does "nothing" except
851 declare that var to be dynamically scoped *locally* (i.e. within
852 the current file or let-block). */
853 Vinternal_interpreter_environment
=
854 Fcons (sym
, Vinternal_interpreter_environment
);
856 /* Simple (defvar <var>) should not count as a definition at all.
857 It could get in the way of other definitions, and unloading this
858 package could try to make the variable unbound. */
864 DEFUN ("defconst", Fdefconst
, Sdefconst
, 2, UNEVALLED
, 0,
865 doc
: /* Define SYMBOL as a constant variable.
866 The intent is that neither programs nor users should ever change this value.
867 Always sets the value of SYMBOL to the result of evalling INITVALUE.
868 If SYMBOL is buffer-local, its default value is what is set;
869 buffer-local values are not affected.
870 DOCSTRING is optional.
872 If SYMBOL has a local binding, then this form sets the local binding's
873 value. However, you should normally not make local bindings for
874 variables defined with this form.
875 usage: (defconst SYMBOL INITVALUE [DOCSTRING]) */)
878 register Lisp_Object sym
, tem
;
881 if (!NILP (Fcdr (Fcdr (Fcdr (args
)))))
882 error ("Too many arguments");
884 tem
= eval_sub (Fcar (Fcdr (args
)));
885 if (!NILP (Vpurify_flag
))
886 tem
= Fpurecopy (tem
);
887 Fset_default (sym
, tem
);
888 XSYMBOL (sym
)->declared_special
= 1;
889 tem
= Fcar (Fcdr (Fcdr (args
)));
892 if (!NILP (Vpurify_flag
))
893 tem
= Fpurecopy (tem
);
894 Fput (sym
, Qvariable_documentation
, tem
);
896 Fput (sym
, Qrisky_local_variable
, Qt
);
897 LOADHIST_ATTACH (sym
);
901 /* Error handler used in Fuser_variable_p. */
903 user_variable_p_eh (Lisp_Object ignore
)
909 lisp_indirect_variable (Lisp_Object sym
)
911 XSETSYMBOL (sym
, indirect_variable (XSYMBOL (sym
)));
915 DEFUN ("user-variable-p", Fuser_variable_p
, Suser_variable_p
, 1, 1, 0,
916 doc
: /* Return t if VARIABLE is intended to be set and modified by users.
917 \(The alternative is a variable used internally in a Lisp program.)
918 A variable is a user variable if
919 \(1) the first character of its documentation is `*', or
920 \(2) it is customizable (its property list contains a non-nil value
921 of `standard-value' or `custom-autoload'), or
922 \(3) it is an alias for another user variable.
923 Return nil if VARIABLE is an alias and there is a loop in the
924 chain of symbols. */)
925 (Lisp_Object variable
)
927 Lisp_Object documentation
;
929 if (!SYMBOLP (variable
))
932 /* If indirect and there's an alias loop, don't check anything else. */
933 if (XSYMBOL (variable
)->redirect
== SYMBOL_VARALIAS
934 && NILP (internal_condition_case_1 (lisp_indirect_variable
, variable
,
935 Qt
, user_variable_p_eh
)))
940 documentation
= Fget (variable
, Qvariable_documentation
);
941 if (INTEGERP (documentation
) && XINT (documentation
) < 0)
943 if (STRINGP (documentation
)
944 && ((unsigned char) SREF (documentation
, 0) == '*'))
946 /* If it is (STRING . INTEGER), a negative integer means a user variable. */
947 if (CONSP (documentation
)
948 && STRINGP (XCAR (documentation
))
949 && INTEGERP (XCDR (documentation
))
950 && XINT (XCDR (documentation
)) < 0)
952 /* Customizable? See `custom-variable-p'. */
953 if ((!NILP (Fget (variable
, intern ("standard-value"))))
954 || (!NILP (Fget (variable
, intern ("custom-autoload")))))
957 if (!(XSYMBOL (variable
)->redirect
== SYMBOL_VARALIAS
))
960 /* An indirect variable? Let's follow the chain. */
961 XSETSYMBOL (variable
, SYMBOL_ALIAS (XSYMBOL (variable
)));
965 DEFUN ("let*", FletX
, SletX
, 1, UNEVALLED
, 0,
966 doc
: /* Bind variables according to VARLIST then eval BODY.
967 The value of the last form in BODY is returned.
968 Each element of VARLIST is a symbol (which is bound to nil)
969 or a list (SYMBOL VALUEFORM) (which binds SYMBOL to the value of VALUEFORM).
970 Each VALUEFORM can refer to the symbols already bound by this VARLIST.
971 usage: (let* VARLIST BODY...) */)
974 Lisp_Object varlist
, var
, val
, elt
, lexenv
;
975 int count
= SPECPDL_INDEX ();
976 struct gcpro gcpro1
, gcpro2
, gcpro3
;
978 GCPRO3 (args
, elt
, varlist
);
980 lexenv
= Vinternal_interpreter_environment
;
982 varlist
= Fcar (args
);
983 while (CONSP (varlist
))
987 elt
= XCAR (varlist
);
993 else if (! NILP (Fcdr (Fcdr (elt
))))
994 signal_error ("`let' bindings can have only one value-form", elt
);
998 val
= eval_sub (Fcar (Fcdr (elt
)));
1001 if (!NILP (lexenv
) && SYMBOLP (var
)
1002 && !XSYMBOL (var
)->declared_special
1003 && NILP (Fmemq (var
, Vinternal_interpreter_environment
)))
1004 /* Lexically bind VAR by adding it to the interpreter's binding
1008 = Fcons (Fcons (var
, val
), Vinternal_interpreter_environment
);
1009 if (EQ (Vinternal_interpreter_environment
, lexenv
))
1010 /* Save the old lexical environment on the specpdl stack,
1011 but only for the first lexical binding, since we'll never
1012 need to revert to one of the intermediate ones. */
1013 specbind (Qinternal_interpreter_environment
, newenv
);
1015 Vinternal_interpreter_environment
= newenv
;
1018 specbind (var
, val
);
1020 varlist
= XCDR (varlist
);
1025 val
= Fprogn (Fcdr (args
));
1027 return unbind_to (count
, val
);
1030 DEFUN ("let", Flet
, Slet
, 1, UNEVALLED
, 0,
1031 doc
: /* Bind variables according to VARLIST then eval BODY.
1032 The value of the last form in BODY is returned.
1033 Each element of VARLIST is a symbol (which is bound to nil)
1034 or a list (SYMBOL VALUEFORM) (which binds SYMBOL to the value of VALUEFORM).
1035 All the VALUEFORMs are evalled before any symbols are bound.
1036 usage: (let VARLIST BODY...) */)
1039 Lisp_Object
*temps
, tem
, lexenv
;
1040 register Lisp_Object elt
, varlist
;
1041 int count
= SPECPDL_INDEX ();
1042 register int argnum
;
1043 struct gcpro gcpro1
, gcpro2
;
1046 varlist
= Fcar (args
);
1048 /* Make space to hold the values to give the bound variables */
1049 elt
= Flength (varlist
);
1050 SAFE_ALLOCA_LISP (temps
, XFASTINT (elt
));
1052 /* Compute the values and store them in `temps' */
1054 GCPRO2 (args
, *temps
);
1057 for (argnum
= 0; CONSP (varlist
); varlist
= XCDR (varlist
))
1060 elt
= XCAR (varlist
);
1062 temps
[argnum
++] = Qnil
;
1063 else if (! NILP (Fcdr (Fcdr (elt
))))
1064 signal_error ("`let' bindings can have only one value-form", elt
);
1066 temps
[argnum
++] = eval_sub (Fcar (Fcdr (elt
)));
1067 gcpro2
.nvars
= argnum
;
1071 lexenv
= Vinternal_interpreter_environment
;
1073 varlist
= Fcar (args
);
1074 for (argnum
= 0; CONSP (varlist
); varlist
= XCDR (varlist
))
1078 elt
= XCAR (varlist
);
1079 var
= SYMBOLP (elt
) ? elt
: Fcar (elt
);
1080 tem
= temps
[argnum
++];
1082 if (!NILP (lexenv
) && SYMBOLP (var
)
1083 && !XSYMBOL (var
)->declared_special
1084 && NILP (Fmemq (var
, Vinternal_interpreter_environment
)))
1085 /* Lexically bind VAR by adding it to the lexenv alist. */
1086 lexenv
= Fcons (Fcons (var
, tem
), lexenv
);
1088 /* Dynamically bind VAR. */
1089 specbind (var
, tem
);
1092 if (!EQ (lexenv
, Vinternal_interpreter_environment
))
1093 /* Instantiate a new lexical environment. */
1094 specbind (Qinternal_interpreter_environment
, lexenv
);
1096 elt
= Fprogn (Fcdr (args
));
1098 return unbind_to (count
, elt
);
1101 DEFUN ("while", Fwhile
, Swhile
, 1, UNEVALLED
, 0,
1102 doc
: /* If TEST yields non-nil, eval BODY... and repeat.
1103 The order of execution is thus TEST, BODY, TEST, BODY and so on
1104 until TEST returns nil.
1105 usage: (while TEST BODY...) */)
1108 Lisp_Object test
, body
;
1109 struct gcpro gcpro1
, gcpro2
;
1111 GCPRO2 (test
, body
);
1115 while (!NILP (eval_sub (test
)))
1125 DEFUN ("macroexpand", Fmacroexpand
, Smacroexpand
, 1, 2, 0,
1126 doc
: /* Return result of expanding macros at top level of FORM.
1127 If FORM is not a macro call, it is returned unchanged.
1128 Otherwise, the macro is expanded and the expansion is considered
1129 in place of FORM. When a non-macro-call results, it is returned.
1131 The second optional arg ENVIRONMENT specifies an environment of macro
1132 definitions to shadow the loaded ones for use in file byte-compilation. */)
1133 (Lisp_Object form
, Lisp_Object environment
)
1135 /* With cleanups from Hallvard Furuseth. */
1136 register Lisp_Object expander
, sym
, def
, tem
;
1140 /* Come back here each time we expand a macro call,
1141 in case it expands into another macro call. */
1144 /* Set SYM, give DEF and TEM right values in case SYM is not a symbol. */
1145 def
= sym
= XCAR (form
);
1147 /* Trace symbols aliases to other symbols
1148 until we get a symbol that is not an alias. */
1149 while (SYMBOLP (def
))
1153 tem
= Fassq (sym
, environment
);
1156 def
= XSYMBOL (sym
)->function
;
1157 if (!EQ (def
, Qunbound
))
1162 /* Right now TEM is the result from SYM in ENVIRONMENT,
1163 and if TEM is nil then DEF is SYM's function definition. */
1166 /* SYM is not mentioned in ENVIRONMENT.
1167 Look at its function definition. */
1168 if (EQ (def
, Qunbound
) || !CONSP (def
))
1169 /* Not defined or definition not suitable */
1171 if (EQ (XCAR (def
), Qautoload
))
1173 /* Autoloading function: will it be a macro when loaded? */
1174 tem
= Fnth (make_number (4), def
);
1175 if (EQ (tem
, Qt
) || EQ (tem
, Qmacro
))
1176 /* Yes, load it and try again. */
1178 struct gcpro gcpro1
;
1180 do_autoload (def
, sym
);
1187 else if (!EQ (XCAR (def
), Qmacro
))
1189 else expander
= XCDR (def
);
1193 expander
= XCDR (tem
);
1194 if (NILP (expander
))
1197 form
= apply1 (expander
, XCDR (form
));
1202 DEFUN ("catch", Fcatch
, Scatch
, 1, UNEVALLED
, 0,
1203 doc
: /* Eval BODY allowing nonlocal exits using `throw'.
1204 TAG is evalled to get the tag to use; it must not be nil.
1206 Then the BODY is executed.
1207 Within BODY, a call to `throw' with the same TAG exits BODY and this `catch'.
1208 If no throw happens, `catch' returns the value of the last BODY form.
1209 If a throw happens, it specifies the value to return from `catch'.
1210 usage: (catch TAG BODY...) */)
1213 register Lisp_Object tag
;
1214 struct gcpro gcpro1
;
1217 tag
= eval_sub (Fcar (args
));
1219 return internal_catch (tag
, Fprogn
, Fcdr (args
));
1222 /* Set up a catch, then call C function FUNC on argument ARG.
1223 FUNC should return a Lisp_Object.
1224 This is how catches are done from within C code. */
1227 internal_catch (Lisp_Object tag
, Lisp_Object (*func
) (Lisp_Object
), Lisp_Object arg
)
1229 /* This structure is made part of the chain `catchlist'. */
1232 /* Fill in the components of c, and put it on the list. */
1236 c
.backlist
= backtrace_list
;
1237 c
.handlerlist
= handlerlist
;
1238 c
.lisp_eval_depth
= lisp_eval_depth
;
1239 c
.pdlcount
= SPECPDL_INDEX ();
1240 c
.poll_suppress_count
= poll_suppress_count
;
1241 c
.interrupt_input_blocked
= interrupt_input_blocked
;
1242 c
.gcpro
= gcprolist
;
1243 c
.byte_stack
= byte_stack_list
;
1247 if (! _setjmp (c
.jmp
))
1248 c
.val
= (*func
) (arg
);
1250 /* Throw works by a longjmp that comes right here. */
1255 /* Unwind the specbind, catch, and handler stacks back to CATCH, and
1256 jump to that CATCH, returning VALUE as the value of that catch.
1258 This is the guts Fthrow and Fsignal; they differ only in the way
1259 they choose the catch tag to throw to. A catch tag for a
1260 condition-case form has a TAG of Qnil.
1262 Before each catch is discarded, unbind all special bindings and
1263 execute all unwind-protect clauses made above that catch. Unwind
1264 the handler stack as we go, so that the proper handlers are in
1265 effect for each unwind-protect clause we run. At the end, restore
1266 some static info saved in CATCH, and longjmp to the location
1269 This is used for correct unwinding in Fthrow and Fsignal. */
1272 unwind_to_catch (struct catchtag
*catch, Lisp_Object value
)
1274 register int last_time
;
1276 /* Save the value in the tag. */
1279 /* Restore certain special C variables. */
1280 set_poll_suppress_count (catch->poll_suppress_count
);
1281 UNBLOCK_INPUT_TO (catch->interrupt_input_blocked
);
1282 handling_signal
= 0;
1287 last_time
= catchlist
== catch;
1289 /* Unwind the specpdl stack, and then restore the proper set of
1291 unbind_to (catchlist
->pdlcount
, Qnil
);
1292 handlerlist
= catchlist
->handlerlist
;
1293 catchlist
= catchlist
->next
;
1295 while (! last_time
);
1298 /* If x_catch_errors was done, turn it off now.
1299 (First we give unbind_to a chance to do that.) */
1300 #if 0 /* This would disable x_catch_errors after x_connection_closed.
1301 The catch must remain in effect during that delicate
1302 state. --lorentey */
1303 x_fully_uncatch_errors ();
1307 byte_stack_list
= catch->byte_stack
;
1308 gcprolist
= catch->gcpro
;
1311 gcpro_level
= gcprolist
->level
+ 1;
1315 backtrace_list
= catch->backlist
;
1316 lisp_eval_depth
= catch->lisp_eval_depth
;
1318 _longjmp (catch->jmp
, 1);
1321 DEFUN ("throw", Fthrow
, Sthrow
, 2, 2, 0,
1322 doc
: /* Throw to the catch for TAG and return VALUE from it.
1323 Both TAG and VALUE are evalled. */)
1324 (register Lisp_Object tag
, Lisp_Object value
)
1326 register struct catchtag
*c
;
1329 for (c
= catchlist
; c
; c
= c
->next
)
1331 if (EQ (c
->tag
, tag
))
1332 unwind_to_catch (c
, value
);
1334 xsignal2 (Qno_catch
, tag
, value
);
1338 DEFUN ("unwind-protect", Funwind_protect
, Sunwind_protect
, 1, UNEVALLED
, 0,
1339 doc
: /* Do BODYFORM, protecting with UNWINDFORMS.
1340 If BODYFORM completes normally, its value is returned
1341 after executing the UNWINDFORMS.
1342 If BODYFORM exits nonlocally, the UNWINDFORMS are executed anyway.
1343 usage: (unwind-protect BODYFORM UNWINDFORMS...) */)
1347 int count
= SPECPDL_INDEX ();
1349 record_unwind_protect (Fprogn
, Fcdr (args
));
1350 val
= eval_sub (Fcar (args
));
1351 return unbind_to (count
, val
);
1354 /* Chain of condition handlers currently in effect.
1355 The elements of this chain are contained in the stack frames
1356 of Fcondition_case and internal_condition_case.
1357 When an error is signaled (by calling Fsignal, below),
1358 this chain is searched for an element that applies. */
1360 struct handler
*handlerlist
;
1362 DEFUN ("condition-case", Fcondition_case
, Scondition_case
, 2, UNEVALLED
, 0,
1363 doc
: /* Regain control when an error is signaled.
1364 Executes BODYFORM and returns its value if no error happens.
1365 Each element of HANDLERS looks like (CONDITION-NAME BODY...)
1366 where the BODY is made of Lisp expressions.
1368 A handler is applicable to an error
1369 if CONDITION-NAME is one of the error's condition names.
1370 If an error happens, the first applicable handler is run.
1372 The car of a handler may be a list of condition names
1373 instead of a single condition name. Then it handles all of them.
1375 When a handler handles an error, control returns to the `condition-case'
1376 and it executes the handler's BODY...
1377 with VAR bound to (ERROR-SYMBOL . SIGNAL-DATA) from the error.
1378 \(If VAR is nil, the handler can't access that information.)
1379 Then the value of the last BODY form is returned from the `condition-case'
1382 See also the function `signal' for more info.
1383 usage: (condition-case VAR BODYFORM &rest HANDLERS) */)
1386 register Lisp_Object bodyform
, handlers
;
1387 volatile Lisp_Object var
;
1390 bodyform
= Fcar (Fcdr (args
));
1391 handlers
= Fcdr (Fcdr (args
));
1393 return internal_lisp_condition_case (var
, bodyform
, handlers
);
1396 /* Like Fcondition_case, but the args are separate
1397 rather than passed in a list. Used by Fbyte_code. */
1400 internal_lisp_condition_case (volatile Lisp_Object var
, Lisp_Object bodyform
,
1401 Lisp_Object handlers
)
1409 for (val
= handlers
; CONSP (val
); val
= XCDR (val
))
1415 && (SYMBOLP (XCAR (tem
))
1416 || CONSP (XCAR (tem
))))))
1417 error ("Invalid condition handler", tem
);
1422 c
.backlist
= backtrace_list
;
1423 c
.handlerlist
= handlerlist
;
1424 c
.lisp_eval_depth
= lisp_eval_depth
;
1425 c
.pdlcount
= SPECPDL_INDEX ();
1426 c
.poll_suppress_count
= poll_suppress_count
;
1427 c
.interrupt_input_blocked
= interrupt_input_blocked
;
1428 c
.gcpro
= gcprolist
;
1429 c
.byte_stack
= byte_stack_list
;
1430 if (_setjmp (c
.jmp
))
1433 specbind (h
.var
, c
.val
);
1434 val
= Fprogn (Fcdr (h
.chosen_clause
));
1436 /* Note that this just undoes the binding of h.var; whoever
1437 longjumped to us unwound the stack to c.pdlcount before
1439 unbind_to (c
.pdlcount
, Qnil
);
1446 h
.handler
= handlers
;
1447 h
.next
= handlerlist
;
1451 val
= eval_sub (bodyform
);
1453 handlerlist
= h
.next
;
1457 /* Call the function BFUN with no arguments, catching errors within it
1458 according to HANDLERS. If there is an error, call HFUN with
1459 one argument which is the data that describes the error:
1462 HANDLERS can be a list of conditions to catch.
1463 If HANDLERS is Qt, catch all errors.
1464 If HANDLERS is Qerror, catch all errors
1465 but allow the debugger to run if that is enabled. */
1468 internal_condition_case (Lisp_Object (*bfun
) (void), Lisp_Object handlers
,
1469 Lisp_Object (*hfun
) (Lisp_Object
))
1475 /* Since Fsignal will close off all calls to x_catch_errors,
1476 we will get the wrong results if some are not closed now. */
1478 if (x_catching_errors ())
1484 c
.backlist
= backtrace_list
;
1485 c
.handlerlist
= handlerlist
;
1486 c
.lisp_eval_depth
= lisp_eval_depth
;
1487 c
.pdlcount
= SPECPDL_INDEX ();
1488 c
.poll_suppress_count
= poll_suppress_count
;
1489 c
.interrupt_input_blocked
= interrupt_input_blocked
;
1490 c
.gcpro
= gcprolist
;
1491 c
.byte_stack
= byte_stack_list
;
1492 if (_setjmp (c
.jmp
))
1494 return (*hfun
) (c
.val
);
1498 h
.handler
= handlers
;
1500 h
.next
= handlerlist
;
1506 handlerlist
= h
.next
;
1510 /* Like internal_condition_case but call BFUN with ARG as its argument. */
1513 internal_condition_case_1 (Lisp_Object (*bfun
) (Lisp_Object
), Lisp_Object arg
,
1514 Lisp_Object handlers
, Lisp_Object (*hfun
) (Lisp_Object
))
1520 /* Since Fsignal will close off all calls to x_catch_errors,
1521 we will get the wrong results if some are not closed now. */
1523 if (x_catching_errors ())
1529 c
.backlist
= backtrace_list
;
1530 c
.handlerlist
= handlerlist
;
1531 c
.lisp_eval_depth
= lisp_eval_depth
;
1532 c
.pdlcount
= SPECPDL_INDEX ();
1533 c
.poll_suppress_count
= poll_suppress_count
;
1534 c
.interrupt_input_blocked
= interrupt_input_blocked
;
1535 c
.gcpro
= gcprolist
;
1536 c
.byte_stack
= byte_stack_list
;
1537 if (_setjmp (c
.jmp
))
1539 return (*hfun
) (c
.val
);
1543 h
.handler
= handlers
;
1545 h
.next
= handlerlist
;
1549 val
= (*bfun
) (arg
);
1551 handlerlist
= h
.next
;
1555 /* Like internal_condition_case_1 but call BFUN with ARG1 and ARG2 as
1559 internal_condition_case_2 (Lisp_Object (*bfun
) (Lisp_Object
, Lisp_Object
),
1562 Lisp_Object handlers
,
1563 Lisp_Object (*hfun
) (Lisp_Object
))
1569 /* Since Fsignal will close off all calls to x_catch_errors,
1570 we will get the wrong results if some are not closed now. */
1572 if (x_catching_errors ())
1578 c
.backlist
= backtrace_list
;
1579 c
.handlerlist
= handlerlist
;
1580 c
.lisp_eval_depth
= lisp_eval_depth
;
1581 c
.pdlcount
= SPECPDL_INDEX ();
1582 c
.poll_suppress_count
= poll_suppress_count
;
1583 c
.interrupt_input_blocked
= interrupt_input_blocked
;
1584 c
.gcpro
= gcprolist
;
1585 c
.byte_stack
= byte_stack_list
;
1586 if (_setjmp (c
.jmp
))
1588 return (*hfun
) (c
.val
);
1592 h
.handler
= handlers
;
1594 h
.next
= handlerlist
;
1598 val
= (*bfun
) (arg1
, arg2
);
1600 handlerlist
= h
.next
;
1604 /* Like internal_condition_case but call BFUN with NARGS as first,
1605 and ARGS as second argument. */
1608 internal_condition_case_n (Lisp_Object (*bfun
) (int, Lisp_Object
*),
1611 Lisp_Object handlers
,
1612 Lisp_Object (*hfun
) (Lisp_Object
))
1618 /* Since Fsignal will close off all calls to x_catch_errors,
1619 we will get the wrong results if some are not closed now. */
1621 if (x_catching_errors ())
1627 c
.backlist
= backtrace_list
;
1628 c
.handlerlist
= handlerlist
;
1629 c
.lisp_eval_depth
= lisp_eval_depth
;
1630 c
.pdlcount
= SPECPDL_INDEX ();
1631 c
.poll_suppress_count
= poll_suppress_count
;
1632 c
.interrupt_input_blocked
= interrupt_input_blocked
;
1633 c
.gcpro
= gcprolist
;
1634 c
.byte_stack
= byte_stack_list
;
1635 if (_setjmp (c
.jmp
))
1637 return (*hfun
) (c
.val
);
1641 h
.handler
= handlers
;
1643 h
.next
= handlerlist
;
1647 val
= (*bfun
) (nargs
, args
);
1649 handlerlist
= h
.next
;
1654 static Lisp_Object
find_handler_clause (Lisp_Object
, Lisp_Object
,
1655 Lisp_Object
, Lisp_Object
);
1656 static int maybe_call_debugger (Lisp_Object conditions
, Lisp_Object sig
,
1659 DEFUN ("signal", Fsignal
, Ssignal
, 2, 2, 0,
1660 doc
: /* Signal an error. Args are ERROR-SYMBOL and associated DATA.
1661 This function does not return.
1663 An error symbol is a symbol with an `error-conditions' property
1664 that is a list of condition names.
1665 A handler for any of those names will get to handle this signal.
1666 The symbol `error' should normally be one of them.
1668 DATA should be a list. Its elements are printed as part of the error message.
1669 See Info anchor `(elisp)Definition of signal' for some details on how this
1670 error message is constructed.
1671 If the signal is handled, DATA is made available to the handler.
1672 See also the function `condition-case'. */)
1673 (Lisp_Object error_symbol
, Lisp_Object data
)
1675 /* When memory is full, ERROR-SYMBOL is nil,
1676 and DATA is (REAL-ERROR-SYMBOL . REAL-DATA).
1677 That is a special case--don't do this in other situations. */
1678 Lisp_Object conditions
;
1680 Lisp_Object real_error_symbol
1681 = (NILP (error_symbol
) ? Fcar (data
) : error_symbol
);
1682 register Lisp_Object clause
= Qnil
;
1684 struct backtrace
*bp
;
1686 immediate_quit
= handling_signal
= 0;
1688 if (gc_in_progress
|| waiting_for_input
)
1691 #if 0 /* rms: I don't know why this was here,
1692 but it is surely wrong for an error that is handled. */
1693 #ifdef HAVE_WINDOW_SYSTEM
1694 if (display_hourglass_p
)
1695 cancel_hourglass ();
1699 /* This hook is used by edebug. */
1700 if (! NILP (Vsignal_hook_function
)
1701 && ! NILP (error_symbol
))
1703 /* Edebug takes care of restoring these variables when it exits. */
1704 if (lisp_eval_depth
+ 20 > max_lisp_eval_depth
)
1705 max_lisp_eval_depth
= lisp_eval_depth
+ 20;
1707 if (SPECPDL_INDEX () + 40 > max_specpdl_size
)
1708 max_specpdl_size
= SPECPDL_INDEX () + 40;
1710 call2 (Vsignal_hook_function
, error_symbol
, data
);
1713 conditions
= Fget (real_error_symbol
, Qerror_conditions
);
1715 /* Remember from where signal was called. Skip over the frame for
1716 `signal' itself. If a frame for `error' follows, skip that,
1717 too. Don't do this when ERROR_SYMBOL is nil, because that
1718 is a memory-full error. */
1719 Vsignaling_function
= Qnil
;
1720 if (backtrace_list
&& !NILP (error_symbol
))
1722 bp
= backtrace_list
->next
;
1723 if (bp
&& bp
->function
&& EQ (*bp
->function
, Qerror
))
1725 if (bp
&& bp
->function
)
1726 Vsignaling_function
= *bp
->function
;
1729 for (h
= handlerlist
; h
; h
= h
->next
)
1731 clause
= find_handler_clause (h
->handler
, conditions
,
1732 error_symbol
, data
);
1737 if (/* Don't run the debugger for a memory-full error.
1738 (There is no room in memory to do that!) */
1739 !NILP (error_symbol
)
1740 && (!NILP (Vdebug_on_signal
)
1741 /* If no handler is present now, try to run the debugger. */
1743 /* Special handler that means "print a message and run debugger
1745 || EQ (h
->handler
, Qerror
)))
1748 = maybe_call_debugger (conditions
, error_symbol
, data
);
1749 /* We can't return values to code which signaled an error, but we
1750 can continue code which has signaled a quit. */
1751 if (debugger_called
&& EQ (real_error_symbol
, Qquit
))
1757 Lisp_Object unwind_data
1758 = (NILP (error_symbol
) ? data
: Fcons (error_symbol
, data
));
1760 h
->chosen_clause
= clause
;
1761 unwind_to_catch (h
->tag
, unwind_data
);
1766 Fthrow (Qtop_level
, Qt
);
1769 if (! NILP (error_symbol
))
1770 data
= Fcons (error_symbol
, data
);
1772 string
= Ferror_message_string (data
);
1773 fatal ("%s", SDATA (string
), 0);
1776 /* Internal version of Fsignal that never returns.
1777 Used for anything but Qquit (which can return from Fsignal). */
1780 xsignal (Lisp_Object error_symbol
, Lisp_Object data
)
1782 Fsignal (error_symbol
, data
);
1786 /* Like xsignal, but takes 0, 1, 2, or 3 args instead of a list. */
1789 xsignal0 (Lisp_Object error_symbol
)
1791 xsignal (error_symbol
, Qnil
);
1795 xsignal1 (Lisp_Object error_symbol
, Lisp_Object arg
)
1797 xsignal (error_symbol
, list1 (arg
));
1801 xsignal2 (Lisp_Object error_symbol
, Lisp_Object arg1
, Lisp_Object arg2
)
1803 xsignal (error_symbol
, list2 (arg1
, arg2
));
1807 xsignal3 (Lisp_Object error_symbol
, Lisp_Object arg1
, Lisp_Object arg2
, Lisp_Object arg3
)
1809 xsignal (error_symbol
, list3 (arg1
, arg2
, arg3
));
1812 /* Signal `error' with message S, and additional arg ARG.
1813 If ARG is not a genuine list, make it a one-element list. */
1816 signal_error (const char *s
, Lisp_Object arg
)
1818 Lisp_Object tortoise
, hare
;
1820 hare
= tortoise
= arg
;
1821 while (CONSP (hare
))
1828 tortoise
= XCDR (tortoise
);
1830 if (EQ (hare
, tortoise
))
1835 arg
= Fcons (arg
, Qnil
); /* Make it a list. */
1837 xsignal (Qerror
, Fcons (build_string (s
), arg
));
1841 /* Return nonzero if LIST is a non-nil atom or
1842 a list containing one of CONDITIONS. */
1845 wants_debugger (Lisp_Object list
, Lisp_Object conditions
)
1852 while (CONSP (conditions
))
1854 Lisp_Object
this, tail
;
1855 this = XCAR (conditions
);
1856 for (tail
= list
; CONSP (tail
); tail
= XCDR (tail
))
1857 if (EQ (XCAR (tail
), this))
1859 conditions
= XCDR (conditions
);
1864 /* Return 1 if an error with condition-symbols CONDITIONS,
1865 and described by SIGNAL-DATA, should skip the debugger
1866 according to debugger-ignored-errors. */
1869 skip_debugger (Lisp_Object conditions
, Lisp_Object data
)
1872 int first_string
= 1;
1873 Lisp_Object error_message
;
1875 error_message
= Qnil
;
1876 for (tail
= Vdebug_ignored_errors
; CONSP (tail
); tail
= XCDR (tail
))
1878 if (STRINGP (XCAR (tail
)))
1882 error_message
= Ferror_message_string (data
);
1886 if (fast_string_match (XCAR (tail
), error_message
) >= 0)
1891 Lisp_Object contail
;
1893 for (contail
= conditions
; CONSP (contail
); contail
= XCDR (contail
))
1894 if (EQ (XCAR (tail
), XCAR (contail
)))
1902 /* Call the debugger if calling it is currently enabled for CONDITIONS.
1903 SIG and DATA describe the signal, as in find_handler_clause. */
1906 maybe_call_debugger (Lisp_Object conditions
, Lisp_Object sig
, Lisp_Object data
)
1908 Lisp_Object combined_data
;
1910 combined_data
= Fcons (sig
, data
);
1913 /* Don't try to run the debugger with interrupts blocked.
1914 The editing loop would return anyway. */
1916 /* Does user want to enter debugger for this kind of error? */
1919 : wants_debugger (Vdebug_on_error
, conditions
))
1920 && ! skip_debugger (conditions
, combined_data
)
1921 /* rms: what's this for? */
1922 && when_entered_debugger
< num_nonmacro_input_events
)
1924 call_debugger (Fcons (Qerror
, Fcons (combined_data
, Qnil
)));
1931 /* Value of Qlambda means we have called debugger and user has continued.
1932 There are two ways to pass SIG and DATA:
1933 = SIG is the error symbol, and DATA is the rest of the data.
1934 = SIG is nil, and DATA is (SYMBOL . REST-OF-DATA).
1935 This is for memory-full errors only.
1937 We need to increase max_specpdl_size temporarily around
1938 anything we do that can push on the specpdl, so as not to get
1939 a second error here in case we're handling specpdl overflow. */
1942 find_handler_clause (Lisp_Object handlers
, Lisp_Object conditions
,
1943 Lisp_Object sig
, Lisp_Object data
)
1945 register Lisp_Object h
;
1947 /* t is used by handlers for all conditions, set up by C code. */
1948 if (EQ (handlers
, Qt
))
1951 /* error is used similarly, but means print an error message
1952 and run the debugger if that is enabled. */
1953 if (EQ (handlers
, Qerror
))
1956 for (h
= handlers
; CONSP (h
); h
= XCDR (h
))
1958 Lisp_Object handler
= XCAR (h
);
1959 Lisp_Object condit
, tem
;
1961 if (!CONSP (handler
))
1963 condit
= XCAR (handler
);
1964 /* Handle a single condition name in handler HANDLER. */
1965 if (SYMBOLP (condit
))
1967 tem
= Fmemq (Fcar (handler
), conditions
);
1971 /* Handle a list of condition names in handler HANDLER. */
1972 else if (CONSP (condit
))
1975 for (tail
= condit
; CONSP (tail
); tail
= XCDR (tail
))
1977 tem
= Fmemq (XCAR (tail
), conditions
);
1988 /* dump an error message; called like vprintf */
1990 verror (const char *m
, va_list ap
)
1993 EMACS_INT size
= 200;
2004 used
= doprnt (buffer
, size
, m
, m
+ mlen
, ap
);
2009 buffer
= (char *) xrealloc (buffer
, size
);
2012 buffer
= (char *) xmalloc (size
);
2017 string
= build_string (buffer
);
2021 xsignal1 (Qerror
, string
);
2025 /* dump an error message; called like printf */
2029 error (const char *m
, ...)
2037 DEFUN ("commandp", Fcommandp
, Scommandp
, 1, 2, 0,
2038 doc
: /* Non-nil if FUNCTION makes provisions for interactive calling.
2039 This means it contains a description for how to read arguments to give it.
2040 The value is nil for an invalid function or a symbol with no function
2043 Interactively callable functions include strings and vectors (treated
2044 as keyboard macros), lambda-expressions that contain a top-level call
2045 to `interactive', autoload definitions made by `autoload' with non-nil
2046 fourth argument, and some of the built-in functions of Lisp.
2048 Also, a symbol satisfies `commandp' if its function definition does so.
2050 If the optional argument FOR-CALL-INTERACTIVELY is non-nil,
2051 then strings and vectors are not accepted. */)
2052 (Lisp_Object function
, Lisp_Object for_call_interactively
)
2054 register Lisp_Object fun
;
2055 register Lisp_Object funcar
;
2056 Lisp_Object if_prop
= Qnil
;
2060 fun
= indirect_function (fun
); /* Check cycles. */
2061 if (NILP (fun
) || EQ (fun
, Qunbound
))
2064 /* Check an `interactive-form' property if present, analogous to the
2065 function-documentation property. */
2067 while (SYMBOLP (fun
))
2069 Lisp_Object tmp
= Fget (fun
, Qinteractive_form
);
2072 fun
= Fsymbol_function (fun
);
2075 /* Emacs primitives are interactive if their DEFUN specifies an
2076 interactive spec. */
2078 return XSUBR (fun
)->intspec
? Qt
: if_prop
;
2080 /* Bytecode objects are interactive if they are long enough to
2081 have an element whose index is COMPILED_INTERACTIVE, which is
2082 where the interactive spec is stored. */
2083 else if (COMPILEDP (fun
))
2084 return ((ASIZE (fun
) & PSEUDOVECTOR_SIZE_MASK
) > COMPILED_INTERACTIVE
2087 /* Strings and vectors are keyboard macros. */
2088 if (STRINGP (fun
) || VECTORP (fun
))
2089 return (NILP (for_call_interactively
) ? Qt
: Qnil
);
2091 /* Lists may represent commands. */
2094 funcar
= XCAR (fun
);
2095 if (EQ (funcar
, Qlambda
))
2096 return !NILP (Fassq (Qinteractive
, Fcdr (XCDR (fun
)))) ? Qt
: if_prop
;
2097 if (EQ (funcar
, Qautoload
))
2098 return !NILP (Fcar (Fcdr (Fcdr (XCDR (fun
))))) ? Qt
: if_prop
;
2103 DEFUN ("autoload", Fautoload
, Sautoload
, 2, 5, 0,
2104 doc
: /* Define FUNCTION to autoload from FILE.
2105 FUNCTION is a symbol; FILE is a file name string to pass to `load'.
2106 Third arg DOCSTRING is documentation for the function.
2107 Fourth arg INTERACTIVE if non-nil says function can be called interactively.
2108 Fifth arg TYPE indicates the type of the object:
2109 nil or omitted says FUNCTION is a function,
2110 `keymap' says FUNCTION is really a keymap, and
2111 `macro' or t says FUNCTION is really a macro.
2112 Third through fifth args give info about the real definition.
2113 They default to nil.
2114 If FUNCTION is already defined other than as an autoload,
2115 this does nothing and returns nil. */)
2116 (Lisp_Object function
, Lisp_Object file
, Lisp_Object docstring
, Lisp_Object interactive
, Lisp_Object type
)
2118 CHECK_SYMBOL (function
);
2119 CHECK_STRING (file
);
2121 /* If function is defined and not as an autoload, don't override */
2122 if (!EQ (XSYMBOL (function
)->function
, Qunbound
)
2123 && !(CONSP (XSYMBOL (function
)->function
)
2124 && EQ (XCAR (XSYMBOL (function
)->function
), Qautoload
)))
2127 if (NILP (Vpurify_flag
))
2128 /* Only add entries after dumping, because the ones before are
2129 not useful and else we get loads of them from the loaddefs.el. */
2130 LOADHIST_ATTACH (Fcons (Qautoload
, function
));
2132 /* We don't want the docstring in purespace (instead,
2133 Snarf-documentation should (hopefully) overwrite it).
2134 We used to use 0 here, but that leads to accidental sharing in
2135 purecopy's hash-consing, so we use a (hopefully) unique integer
2137 docstring
= make_number (XHASH (function
));
2138 return Ffset (function
,
2139 Fpurecopy (list5 (Qautoload
, file
, docstring
,
2140 interactive
, type
)));
2144 un_autoload (Lisp_Object oldqueue
)
2146 register Lisp_Object queue
, first
, second
;
2148 /* Queue to unwind is current value of Vautoload_queue.
2149 oldqueue is the shadowed value to leave in Vautoload_queue. */
2150 queue
= Vautoload_queue
;
2151 Vautoload_queue
= oldqueue
;
2152 while (CONSP (queue
))
2154 first
= XCAR (queue
);
2155 second
= Fcdr (first
);
2156 first
= Fcar (first
);
2157 if (EQ (first
, make_number (0)))
2160 Ffset (first
, second
);
2161 queue
= XCDR (queue
);
2166 /* Load an autoloaded function.
2167 FUNNAME is the symbol which is the function's name.
2168 FUNDEF is the autoload definition (a list). */
2171 do_autoload (Lisp_Object fundef
, Lisp_Object funname
)
2173 int count
= SPECPDL_INDEX ();
2175 struct gcpro gcpro1
, gcpro2
, gcpro3
;
2177 /* This is to make sure that loadup.el gives a clear picture
2178 of what files are preloaded and when. */
2179 if (! NILP (Vpurify_flag
))
2180 error ("Attempt to autoload %s while preparing to dump",
2181 SDATA (SYMBOL_NAME (funname
)));
2184 CHECK_SYMBOL (funname
);
2185 GCPRO3 (fun
, funname
, fundef
);
2187 /* Preserve the match data. */
2188 record_unwind_save_match_data ();
2190 /* If autoloading gets an error (which includes the error of failing
2191 to define the function being called), we use Vautoload_queue
2192 to undo function definitions and `provide' calls made by
2193 the function. We do this in the specific case of autoloading
2194 because autoloading is not an explicit request "load this file",
2195 but rather a request to "call this function".
2197 The value saved here is to be restored into Vautoload_queue. */
2198 record_unwind_protect (un_autoload
, Vautoload_queue
);
2199 Vautoload_queue
= Qt
;
2200 Fload (Fcar (Fcdr (fundef
)), Qnil
, Qt
, Qnil
, Qt
);
2202 /* Once loading finishes, don't undo it. */
2203 Vautoload_queue
= Qt
;
2204 unbind_to (count
, Qnil
);
2206 fun
= Findirect_function (fun
, Qnil
);
2208 if (!NILP (Fequal (fun
, fundef
)))
2209 error ("Autoloading failed to define function %s",
2210 SDATA (SYMBOL_NAME (funname
)));
2215 DEFUN ("eval", Feval
, Seval
, 1, 2, 0,
2216 doc
: /* Evaluate FORM and return its value.
2217 If LEXICAL is t, evaluate using lexical scoping. */)
2218 (Lisp_Object form
, Lisp_Object lexical
)
2220 int count
= SPECPDL_INDEX ();
2221 specbind (Qinternal_interpreter_environment
,
2222 NILP (lexical
) ? Qnil
: Fcons (Qt
, Qnil
));
2223 return unbind_to (count
, eval_sub (form
));
2226 /* Eval a sub-expression of the current expression (i.e. in the same
2229 eval_sub (Lisp_Object form
)
2231 Lisp_Object fun
, val
, original_fun
, original_args
;
2233 struct backtrace backtrace
;
2234 struct gcpro gcpro1
, gcpro2
, gcpro3
;
2236 if (handling_signal
)
2241 /* Look up its binding in the lexical environment.
2242 We do not pay attention to the declared_special flag here, since we
2243 already did that when let-binding the variable. */
2244 Lisp_Object lex_binding
2245 = !NILP (Vinternal_interpreter_environment
) /* Mere optimization! */
2246 ? Fassq (form
, Vinternal_interpreter_environment
)
2248 if (CONSP (lex_binding
))
2249 return XCDR (lex_binding
);
2251 return Fsymbol_value (form
);
2258 if ((consing_since_gc
> gc_cons_threshold
2259 && consing_since_gc
> gc_relative_threshold
)
2261 (!NILP (Vmemory_full
) && consing_since_gc
> memory_full_cons_threshold
))
2264 Fgarbage_collect ();
2268 if (++lisp_eval_depth
> max_lisp_eval_depth
)
2270 if (max_lisp_eval_depth
< 100)
2271 max_lisp_eval_depth
= 100;
2272 if (lisp_eval_depth
> max_lisp_eval_depth
)
2273 error ("Lisp nesting exceeds `max-lisp-eval-depth'");
2276 original_fun
= Fcar (form
);
2277 original_args
= Fcdr (form
);
2279 backtrace
.next
= backtrace_list
;
2280 backtrace_list
= &backtrace
;
2281 backtrace
.function
= &original_fun
; /* This also protects them from gc */
2282 backtrace
.args
= &original_args
;
2283 backtrace
.nargs
= UNEVALLED
;
2284 backtrace
.evalargs
= 1;
2285 backtrace
.debug_on_exit
= 0;
2287 if (debug_on_next_call
)
2288 do_debug_on_call (Qt
);
2290 /* At this point, only original_fun and original_args
2291 have values that will be used below */
2294 /* Optimize for no indirection. */
2296 if (SYMBOLP (fun
) && !EQ (fun
, Qunbound
)
2297 && (fun
= XSYMBOL (fun
)->function
, SYMBOLP (fun
)))
2298 fun
= indirect_function (fun
);
2302 Lisp_Object numargs
;
2303 Lisp_Object argvals
[8];
2304 Lisp_Object args_left
;
2305 register int i
, maxargs
;
2307 args_left
= original_args
;
2308 numargs
= Flength (args_left
);
2312 if (XINT (numargs
) < XSUBR (fun
)->min_args
||
2313 (XSUBR (fun
)->max_args
>= 0 && XSUBR (fun
)->max_args
< XINT (numargs
)))
2314 xsignal2 (Qwrong_number_of_arguments
, original_fun
, numargs
);
2316 else if (XSUBR (fun
)->max_args
== UNEVALLED
)
2318 backtrace
.evalargs
= 0;
2319 val
= (XSUBR (fun
)->function
.aUNEVALLED
) (args_left
);
2321 else if (XSUBR (fun
)->max_args
== MANY
)
2323 /* Pass a vector of evaluated arguments */
2325 register int argnum
= 0;
2328 SAFE_ALLOCA_LISP (vals
, XINT (numargs
));
2330 GCPRO3 (args_left
, fun
, fun
);
2334 while (!NILP (args_left
))
2336 vals
[argnum
++] = eval_sub (Fcar (args_left
));
2337 args_left
= Fcdr (args_left
);
2338 gcpro3
.nvars
= argnum
;
2341 backtrace
.args
= vals
;
2342 backtrace
.nargs
= XINT (numargs
);
2344 val
= (XSUBR (fun
)->function
.aMANY
) (XINT (numargs
), vals
);
2350 GCPRO3 (args_left
, fun
, fun
);
2351 gcpro3
.var
= argvals
;
2354 maxargs
= XSUBR (fun
)->max_args
;
2355 for (i
= 0; i
< maxargs
; args_left
= Fcdr (args_left
))
2357 argvals
[i
] = eval_sub (Fcar (args_left
));
2363 backtrace
.args
= argvals
;
2364 backtrace
.nargs
= XINT (numargs
);
2369 val
= (XSUBR (fun
)->function
.a0 ());
2372 val
= (XSUBR (fun
)->function
.a1 (argvals
[0]));
2375 val
= (XSUBR (fun
)->function
.a2 (argvals
[0], argvals
[1]));
2378 val
= (XSUBR (fun
)->function
.a3
2379 (argvals
[0], argvals
[1], argvals
[2]));
2382 val
= (XSUBR (fun
)->function
.a4
2383 (argvals
[0], argvals
[1], argvals
[2], argvals
[3]));
2386 val
= (XSUBR (fun
)->function
.a5
2387 (argvals
[0], argvals
[1], argvals
[2], argvals
[3],
2391 val
= (XSUBR (fun
)->function
.a6
2392 (argvals
[0], argvals
[1], argvals
[2], argvals
[3],
2393 argvals
[4], argvals
[5]));
2396 val
= (XSUBR (fun
)->function
.a7
2397 (argvals
[0], argvals
[1], argvals
[2], argvals
[3],
2398 argvals
[4], argvals
[5], argvals
[6]));
2402 val
= (XSUBR (fun
)->function
.a8
2403 (argvals
[0], argvals
[1], argvals
[2], argvals
[3],
2404 argvals
[4], argvals
[5], argvals
[6], argvals
[7]));
2408 /* Someone has created a subr that takes more arguments than
2409 is supported by this code. We need to either rewrite the
2410 subr to use a different argument protocol, or add more
2411 cases to this switch. */
2416 else if (FUNVECP (fun
))
2417 val
= apply_lambda (fun
, original_args
);
2420 if (EQ (fun
, Qunbound
))
2421 xsignal1 (Qvoid_function
, original_fun
);
2423 xsignal1 (Qinvalid_function
, original_fun
);
2424 funcar
= XCAR (fun
);
2425 if (!SYMBOLP (funcar
))
2426 xsignal1 (Qinvalid_function
, original_fun
);
2427 if (EQ (funcar
, Qautoload
))
2429 do_autoload (fun
, original_fun
);
2432 if (EQ (funcar
, Qmacro
))
2433 val
= eval_sub (apply1 (Fcdr (fun
), original_args
));
2434 else if (EQ (funcar
, Qlambda
)
2435 || EQ (funcar
, Qclosure
))
2436 val
= apply_lambda (fun
, original_args
);
2438 xsignal1 (Qinvalid_function
, original_fun
);
2443 if (backtrace
.debug_on_exit
)
2444 val
= call_debugger (Fcons (Qexit
, Fcons (val
, Qnil
)));
2445 backtrace_list
= backtrace
.next
;
2450 DEFUN ("apply", Fapply
, Sapply
, 2, MANY
, 0,
2451 doc
: /* Call FUNCTION with our remaining args, using our last arg as list of args.
2452 Then return the value FUNCTION returns.
2453 Thus, (apply '+ 1 2 '(3 4)) returns 10.
2454 usage: (apply FUNCTION &rest ARGUMENTS) */)
2455 (int nargs
, Lisp_Object
*args
)
2457 register int i
, numargs
;
2458 register Lisp_Object spread_arg
;
2459 register Lisp_Object
*funcall_args
;
2460 Lisp_Object fun
, retval
;
2461 struct gcpro gcpro1
;
2466 spread_arg
= args
[nargs
- 1];
2467 CHECK_LIST (spread_arg
);
2469 numargs
= XINT (Flength (spread_arg
));
2472 return Ffuncall (nargs
- 1, args
);
2473 else if (numargs
== 1)
2475 args
[nargs
- 1] = XCAR (spread_arg
);
2476 return Ffuncall (nargs
, args
);
2479 numargs
+= nargs
- 2;
2481 /* Optimize for no indirection. */
2482 if (SYMBOLP (fun
) && !EQ (fun
, Qunbound
)
2483 && (fun
= XSYMBOL (fun
)->function
, SYMBOLP (fun
)))
2484 fun
= indirect_function (fun
);
2485 if (EQ (fun
, Qunbound
))
2487 /* Let funcall get the error */
2494 if (numargs
< XSUBR (fun
)->min_args
2495 || (XSUBR (fun
)->max_args
>= 0 && XSUBR (fun
)->max_args
< numargs
))
2496 goto funcall
; /* Let funcall get the error */
2497 else if (XSUBR (fun
)->max_args
> numargs
)
2499 /* Avoid making funcall cons up a yet another new vector of arguments
2500 by explicitly supplying nil's for optional values */
2501 SAFE_ALLOCA_LISP (funcall_args
, 1 + XSUBR (fun
)->max_args
);
2502 for (i
= numargs
; i
< XSUBR (fun
)->max_args
;)
2503 funcall_args
[++i
] = Qnil
;
2504 GCPRO1 (*funcall_args
);
2505 gcpro1
.nvars
= 1 + XSUBR (fun
)->max_args
;
2509 /* We add 1 to numargs because funcall_args includes the
2510 function itself as well as its arguments. */
2513 SAFE_ALLOCA_LISP (funcall_args
, 1 + numargs
);
2514 GCPRO1 (*funcall_args
);
2515 gcpro1
.nvars
= 1 + numargs
;
2518 memcpy (funcall_args
, args
, nargs
* sizeof (Lisp_Object
));
2519 /* Spread the last arg we got. Its first element goes in
2520 the slot that it used to occupy, hence this value of I. */
2522 while (!NILP (spread_arg
))
2524 funcall_args
[i
++] = XCAR (spread_arg
);
2525 spread_arg
= XCDR (spread_arg
);
2528 /* By convention, the caller needs to gcpro Ffuncall's args. */
2529 retval
= Ffuncall (gcpro1
.nvars
, funcall_args
);
2536 /* Run hook variables in various ways. */
2538 enum run_hooks_condition
{to_completion
, until_success
, until_failure
};
2539 static Lisp_Object
run_hook_with_args (int, Lisp_Object
*,
2540 enum run_hooks_condition
);
2542 DEFUN ("run-hooks", Frun_hooks
, Srun_hooks
, 0, MANY
, 0,
2543 doc
: /* Run each hook in HOOKS.
2544 Each argument should be a symbol, a hook variable.
2545 These symbols are processed in the order specified.
2546 If a hook symbol has a non-nil value, that value may be a function
2547 or a list of functions to be called to run the hook.
2548 If the value is a function, it is called with no arguments.
2549 If it is a list, the elements are called, in order, with no arguments.
2551 Major modes should not use this function directly to run their mode
2552 hook; they should use `run-mode-hooks' instead.
2554 Do not use `make-local-variable' to make a hook variable buffer-local.
2555 Instead, use `add-hook' and specify t for the LOCAL argument.
2556 usage: (run-hooks &rest HOOKS) */)
2557 (int nargs
, Lisp_Object
*args
)
2559 Lisp_Object hook
[1];
2562 for (i
= 0; i
< nargs
; i
++)
2565 run_hook_with_args (1, hook
, to_completion
);
2571 DEFUN ("run-hook-with-args", Frun_hook_with_args
,
2572 Srun_hook_with_args
, 1, MANY
, 0,
2573 doc
: /* Run HOOK with the specified arguments ARGS.
2574 HOOK should be a symbol, a hook variable. If HOOK has a non-nil
2575 value, that value may be a function or a list of functions to be
2576 called to run the hook. If the value is a function, it is called with
2577 the given arguments and its return value is returned. If it is a list
2578 of functions, those functions are called, in order,
2579 with the given arguments ARGS.
2580 It is best not to depend on the value returned by `run-hook-with-args',
2583 Do not use `make-local-variable' to make a hook variable buffer-local.
2584 Instead, use `add-hook' and specify t for the LOCAL argument.
2585 usage: (run-hook-with-args HOOK &rest ARGS) */)
2586 (int nargs
, Lisp_Object
*args
)
2588 return run_hook_with_args (nargs
, args
, to_completion
);
2591 DEFUN ("run-hook-with-args-until-success", Frun_hook_with_args_until_success
,
2592 Srun_hook_with_args_until_success
, 1, MANY
, 0,
2593 doc
: /* Run HOOK with the specified arguments ARGS.
2594 HOOK should be a symbol, a hook variable. If HOOK has a non-nil
2595 value, that value may be a function or a list of functions to be
2596 called to run the hook. If the value is a function, it is called with
2597 the given arguments and its return value is returned.
2598 If it is a list of functions, those functions are called, in order,
2599 with the given arguments ARGS, until one of them
2600 returns a non-nil value. Then we return that value.
2601 However, if they all return nil, we return nil.
2603 Do not use `make-local-variable' to make a hook variable buffer-local.
2604 Instead, use `add-hook' and specify t for the LOCAL argument.
2605 usage: (run-hook-with-args-until-success HOOK &rest ARGS) */)
2606 (int nargs
, Lisp_Object
*args
)
2608 return run_hook_with_args (nargs
, args
, until_success
);
2611 DEFUN ("run-hook-with-args-until-failure", Frun_hook_with_args_until_failure
,
2612 Srun_hook_with_args_until_failure
, 1, MANY
, 0,
2613 doc
: /* Run HOOK with the specified arguments ARGS.
2614 HOOK should be a symbol, a hook variable. If HOOK has a non-nil
2615 value, that value may be a function or a list of functions to be
2616 called to run the hook. If the value is a function, it is called with
2617 the given arguments and its return value is returned.
2618 If it is a list of functions, those functions are called, in order,
2619 with the given arguments ARGS, until one of them returns nil.
2620 Then we return nil. However, if they all return non-nil, we return non-nil.
2622 Do not use `make-local-variable' to make a hook variable buffer-local.
2623 Instead, use `add-hook' and specify t for the LOCAL argument.
2624 usage: (run-hook-with-args-until-failure HOOK &rest ARGS) */)
2625 (int nargs
, Lisp_Object
*args
)
2627 return run_hook_with_args (nargs
, args
, until_failure
);
2630 /* ARGS[0] should be a hook symbol.
2631 Call each of the functions in the hook value, passing each of them
2632 as arguments all the rest of ARGS (all NARGS - 1 elements).
2633 COND specifies a condition to test after each call
2634 to decide whether to stop.
2635 The caller (or its caller, etc) must gcpro all of ARGS,
2636 except that it isn't necessary to gcpro ARGS[0]. */
2639 run_hook_with_args (int nargs
, Lisp_Object
*args
, enum run_hooks_condition cond
)
2641 Lisp_Object sym
, val
, ret
;
2642 struct gcpro gcpro1
, gcpro2
, gcpro3
;
2644 /* If we are dying or still initializing,
2645 don't do anything--it would probably crash if we tried. */
2646 if (NILP (Vrun_hooks
))
2650 val
= find_symbol_value (sym
);
2651 ret
= (cond
== until_failure
? Qt
: Qnil
);
2653 if (EQ (val
, Qunbound
) || NILP (val
))
2655 else if (!CONSP (val
) || EQ (XCAR (val
), Qlambda
))
2658 return Ffuncall (nargs
, args
);
2662 Lisp_Object globals
= Qnil
;
2663 GCPRO3 (sym
, val
, globals
);
2666 CONSP (val
) && ((cond
== to_completion
)
2667 || (cond
== until_success
? NILP (ret
)
2671 if (EQ (XCAR (val
), Qt
))
2673 /* t indicates this hook has a local binding;
2674 it means to run the global binding too. */
2675 globals
= Fdefault_value (sym
);
2676 if (NILP (globals
)) continue;
2678 if (!CONSP (globals
) || EQ (XCAR (globals
), Qlambda
))
2681 ret
= Ffuncall (nargs
, args
);
2686 CONSP (globals
) && ((cond
== to_completion
)
2687 || (cond
== until_success
? NILP (ret
)
2689 globals
= XCDR (globals
))
2691 args
[0] = XCAR (globals
);
2692 /* In a global value, t should not occur. If it does, we
2693 must ignore it to avoid an endless loop. */
2694 if (!EQ (args
[0], Qt
))
2695 ret
= Ffuncall (nargs
, args
);
2701 args
[0] = XCAR (val
);
2702 ret
= Ffuncall (nargs
, args
);
2711 /* Run the hook HOOK, giving each function the two args ARG1 and ARG2. */
2714 run_hook_with_args_2 (Lisp_Object hook
, Lisp_Object arg1
, Lisp_Object arg2
)
2716 Lisp_Object temp
[3];
2721 Frun_hook_with_args (3, temp
);
2724 /* Apply fn to arg */
2726 apply1 (Lisp_Object fn
, Lisp_Object arg
)
2728 struct gcpro gcpro1
;
2732 RETURN_UNGCPRO (Ffuncall (1, &fn
));
2735 Lisp_Object args
[2];
2739 RETURN_UNGCPRO (Fapply (2, args
));
2743 /* Call function fn on no arguments */
2745 call0 (Lisp_Object fn
)
2747 struct gcpro gcpro1
;
2750 RETURN_UNGCPRO (Ffuncall (1, &fn
));
2753 /* Call function fn with 1 argument arg1 */
2756 call1 (Lisp_Object fn
, Lisp_Object arg1
)
2758 struct gcpro gcpro1
;
2759 Lisp_Object args
[2];
2765 RETURN_UNGCPRO (Ffuncall (2, args
));
2768 /* Call function fn with 2 arguments arg1, arg2 */
2771 call2 (Lisp_Object fn
, Lisp_Object arg1
, Lisp_Object arg2
)
2773 struct gcpro gcpro1
;
2774 Lisp_Object args
[3];
2780 RETURN_UNGCPRO (Ffuncall (3, args
));
2783 /* Call function fn with 3 arguments arg1, arg2, arg3 */
2786 call3 (Lisp_Object fn
, Lisp_Object arg1
, Lisp_Object arg2
, Lisp_Object arg3
)
2788 struct gcpro gcpro1
;
2789 Lisp_Object args
[4];
2796 RETURN_UNGCPRO (Ffuncall (4, args
));
2799 /* Call function fn with 4 arguments arg1, arg2, arg3, arg4 */
2802 call4 (Lisp_Object fn
, Lisp_Object arg1
, Lisp_Object arg2
, Lisp_Object arg3
,
2805 struct gcpro gcpro1
;
2806 Lisp_Object args
[5];
2814 RETURN_UNGCPRO (Ffuncall (5, args
));
2817 /* Call function fn with 5 arguments arg1, arg2, arg3, arg4, arg5 */
2820 call5 (Lisp_Object fn
, Lisp_Object arg1
, Lisp_Object arg2
, Lisp_Object arg3
,
2821 Lisp_Object arg4
, Lisp_Object arg5
)
2823 struct gcpro gcpro1
;
2824 Lisp_Object args
[6];
2833 RETURN_UNGCPRO (Ffuncall (6, args
));
2836 /* Call function fn with 6 arguments arg1, arg2, arg3, arg4, arg5, arg6 */
2839 call6 (Lisp_Object fn
, Lisp_Object arg1
, Lisp_Object arg2
, Lisp_Object arg3
,
2840 Lisp_Object arg4
, Lisp_Object arg5
, Lisp_Object arg6
)
2842 struct gcpro gcpro1
;
2843 Lisp_Object args
[7];
2853 RETURN_UNGCPRO (Ffuncall (7, args
));
2856 /* Call function fn with 7 arguments arg1, arg2, arg3, arg4, arg5, arg6, arg7 */
2859 call7 (Lisp_Object fn
, Lisp_Object arg1
, Lisp_Object arg2
, Lisp_Object arg3
,
2860 Lisp_Object arg4
, Lisp_Object arg5
, Lisp_Object arg6
, Lisp_Object arg7
)
2862 struct gcpro gcpro1
;
2863 Lisp_Object args
[8];
2874 RETURN_UNGCPRO (Ffuncall (8, args
));
2877 /* The caller should GCPRO all the elements of ARGS. */
2879 DEFUN ("functionp", Ffunctionp
, Sfunctionp
, 1, 1, 0,
2880 doc
: /* Return non-nil if OBJECT is a type of object that can be called as a function. */)
2881 (Lisp_Object object
)
2883 if (SYMBOLP (object
) && !NILP (Ffboundp (object
)))
2885 object
= Findirect_function (object
, Qnil
);
2887 if (CONSP (object
) && EQ (XCAR (object
), Qautoload
))
2889 /* Autoloaded symbols are functions, except if they load
2890 macros or keymaps. */
2892 for (i
= 0; i
< 4 && CONSP (object
); i
++)
2893 object
= XCDR (object
);
2895 return (CONSP (object
) && !NILP (XCAR (object
))) ? Qnil
: Qt
;
2900 return (XSUBR (object
)->max_args
!= UNEVALLED
) ? Qt
: Qnil
;
2901 else if (FUNVECP (object
))
2903 else if (CONSP (object
))
2905 Lisp_Object car
= XCAR (object
);
2906 return (EQ (car
, Qlambda
) || EQ (car
, Qclosure
)) ? Qt
: Qnil
;
2912 DEFUN ("funcall", Ffuncall
, Sfuncall
, 1, MANY
, 0,
2913 doc
: /* Call first argument as a function, passing remaining arguments to it.
2914 Return the value that function returns.
2915 Thus, (funcall 'cons 'x 'y) returns (x . y).
2916 usage: (funcall FUNCTION &rest ARGUMENTS) */)
2917 (int nargs
, Lisp_Object
*args
)
2919 Lisp_Object fun
, original_fun
;
2921 int numargs
= nargs
- 1;
2922 Lisp_Object lisp_numargs
;
2924 struct backtrace backtrace
;
2925 register Lisp_Object
*internal_args
;
2929 if ((consing_since_gc
> gc_cons_threshold
2930 && consing_since_gc
> gc_relative_threshold
)
2932 (!NILP (Vmemory_full
) && consing_since_gc
> memory_full_cons_threshold
))
2933 Fgarbage_collect ();
2935 if (++lisp_eval_depth
> max_lisp_eval_depth
)
2937 if (max_lisp_eval_depth
< 100)
2938 max_lisp_eval_depth
= 100;
2939 if (lisp_eval_depth
> max_lisp_eval_depth
)
2940 error ("Lisp nesting exceeds `max-lisp-eval-depth'");
2943 backtrace
.next
= backtrace_list
;
2944 backtrace_list
= &backtrace
;
2945 backtrace
.function
= &args
[0];
2946 backtrace
.args
= &args
[1];
2947 backtrace
.nargs
= nargs
- 1;
2948 backtrace
.evalargs
= 0;
2949 backtrace
.debug_on_exit
= 0;
2951 if (debug_on_next_call
)
2952 do_debug_on_call (Qlambda
);
2956 original_fun
= args
[0];
2960 /* Optimize for no indirection. */
2962 if (SYMBOLP (fun
) && !EQ (fun
, Qunbound
)
2963 && (fun
= XSYMBOL (fun
)->function
, SYMBOLP (fun
)))
2964 fun
= indirect_function (fun
);
2968 if (numargs
< XSUBR (fun
)->min_args
2969 || (XSUBR (fun
)->max_args
>= 0 && XSUBR (fun
)->max_args
< numargs
))
2971 XSETFASTINT (lisp_numargs
, numargs
);
2972 xsignal2 (Qwrong_number_of_arguments
, original_fun
, lisp_numargs
);
2975 else if (XSUBR (fun
)->max_args
== UNEVALLED
)
2976 xsignal1 (Qinvalid_function
, original_fun
);
2978 else if (XSUBR (fun
)->max_args
== MANY
)
2979 val
= (XSUBR (fun
)->function
.aMANY
) (numargs
, args
+ 1);
2982 if (XSUBR (fun
)->max_args
> numargs
)
2984 internal_args
= (Lisp_Object
*) alloca (XSUBR (fun
)->max_args
* sizeof (Lisp_Object
));
2985 memcpy (internal_args
, args
+ 1, numargs
* sizeof (Lisp_Object
));
2986 for (i
= numargs
; i
< XSUBR (fun
)->max_args
; i
++)
2987 internal_args
[i
] = Qnil
;
2990 internal_args
= args
+ 1;
2991 switch (XSUBR (fun
)->max_args
)
2994 val
= (XSUBR (fun
)->function
.a0 ());
2997 val
= (XSUBR (fun
)->function
.a1 (internal_args
[0]));
3000 val
= (XSUBR (fun
)->function
.a2
3001 (internal_args
[0], internal_args
[1]));
3004 val
= (XSUBR (fun
)->function
.a3
3005 (internal_args
[0], internal_args
[1], internal_args
[2]));
3008 val
= (XSUBR (fun
)->function
.a4
3009 (internal_args
[0], internal_args
[1], internal_args
[2],
3013 val
= (XSUBR (fun
)->function
.a5
3014 (internal_args
[0], internal_args
[1], internal_args
[2],
3015 internal_args
[3], internal_args
[4]));
3018 val
= (XSUBR (fun
)->function
.a6
3019 (internal_args
[0], internal_args
[1], internal_args
[2],
3020 internal_args
[3], internal_args
[4], internal_args
[5]));
3023 val
= (XSUBR (fun
)->function
.a7
3024 (internal_args
[0], internal_args
[1], internal_args
[2],
3025 internal_args
[3], internal_args
[4], internal_args
[5],
3030 val
= (XSUBR (fun
)->function
.a8
3031 (internal_args
[0], internal_args
[1], internal_args
[2],
3032 internal_args
[3], internal_args
[4], internal_args
[5],
3033 internal_args
[6], internal_args
[7]));
3038 /* If a subr takes more than 8 arguments without using MANY
3039 or UNEVALLED, we need to extend this function to support it.
3040 Until this is done, there is no way to call the function. */
3045 else if (FUNVECP (fun
))
3046 val
= funcall_lambda (fun
, numargs
, args
+ 1);
3049 if (EQ (fun
, Qunbound
))
3050 xsignal1 (Qvoid_function
, original_fun
);
3052 xsignal1 (Qinvalid_function
, original_fun
);
3053 funcar
= XCAR (fun
);
3054 if (!SYMBOLP (funcar
))
3055 xsignal1 (Qinvalid_function
, original_fun
);
3056 if (EQ (funcar
, Qlambda
)
3057 || EQ (funcar
, Qclosure
))
3058 val
= funcall_lambda (fun
, numargs
, args
+ 1);
3059 else if (EQ (funcar
, Qautoload
))
3061 do_autoload (fun
, original_fun
);
3066 xsignal1 (Qinvalid_function
, original_fun
);
3070 if (backtrace
.debug_on_exit
)
3071 val
= call_debugger (Fcons (Qexit
, Fcons (val
, Qnil
)));
3072 backtrace_list
= backtrace
.next
;
3077 apply_lambda (Lisp_Object fun
, Lisp_Object args
)
3079 Lisp_Object args_left
;
3080 Lisp_Object numargs
;
3081 register Lisp_Object
*arg_vector
;
3082 struct gcpro gcpro1
, gcpro2
, gcpro3
;
3084 register Lisp_Object tem
;
3087 numargs
= Flength (args
);
3088 SAFE_ALLOCA_LISP (arg_vector
, XINT (numargs
));
3091 GCPRO3 (*arg_vector
, args_left
, fun
);
3094 for (i
= 0; i
< XINT (numargs
);)
3096 tem
= Fcar (args_left
), args_left
= Fcdr (args_left
);
3097 tem
= eval_sub (tem
);
3098 arg_vector
[i
++] = tem
;
3104 backtrace_list
->args
= arg_vector
;
3105 backtrace_list
->nargs
= i
;
3106 backtrace_list
->evalargs
= 0;
3107 tem
= funcall_lambda (fun
, XINT (numargs
), arg_vector
);
3109 /* Do the debug-on-exit now, while arg_vector still exists. */
3110 if (backtrace_list
->debug_on_exit
)
3111 tem
= call_debugger (Fcons (Qexit
, Fcons (tem
, Qnil
)));
3112 /* Don't do it again when we return to eval. */
3113 backtrace_list
->debug_on_exit
= 0;
3119 /* Call a non-bytecode funvec object FUN, on the argments in ARGS (of
3123 funcall_funvec (Lisp_Object fun
, int nargs
, Lisp_Object
*args
)
3125 int size
= FUNVEC_SIZE (fun
);
3126 Lisp_Object tag
= (size
> 0 ? AREF (fun
, 0) : Qnil
);
3128 if (EQ (tag
, Qcurry
))
3130 /* A curried function is a way to attach arguments to a another
3131 function. The first element of the vector is the identifier
3132 `curry', the second is the wrapped function, and remaining
3133 elements are the attached arguments. */
3134 int num_curried_args
= size
- 2;
3135 /* Offset of the curried and user args in the final arglist. Curried
3136 args are first in the new arg vector, after the function. User
3138 int curried_args_offs
= 1;
3139 int user_args_offs
= curried_args_offs
+ num_curried_args
;
3140 /* The curried function and arguments. */
3141 Lisp_Object
*curry_params
= XVECTOR (fun
)->contents
+ 1;
3142 /* The arguments in the curry vector. */
3143 Lisp_Object
*curried_args
= curry_params
+ 1;
3144 /* The number of arguments with which we'll call funcall, and the
3145 arguments themselves. */
3146 int num_funcall_args
= 1 + num_curried_args
+ nargs
;
3147 Lisp_Object
*funcall_args
3148 = (Lisp_Object
*) alloca (num_funcall_args
* sizeof (Lisp_Object
));
3150 /* First comes the real function. */
3151 funcall_args
[0] = curry_params
[0];
3153 /* Then the arguments in the appropriate order. */
3154 memcpy (funcall_args
+ curried_args_offs
, curried_args
,
3155 num_curried_args
* sizeof (Lisp_Object
));
3156 memcpy (funcall_args
+ user_args_offs
, args
,
3157 nargs
* sizeof (Lisp_Object
));
3159 return Ffuncall (num_funcall_args
, funcall_args
);
3162 xsignal1 (Qinvalid_function
, fun
);
3166 /* Apply a Lisp function FUN to the NARGS evaluated arguments in ARG_VECTOR
3167 and return the result of evaluation.
3168 FUN must be either a lambda-expression or a compiled-code object. */
3171 funcall_lambda (Lisp_Object fun
, int nargs
,
3172 register Lisp_Object
*arg_vector
)
3174 Lisp_Object val
, syms_left
, next
, lexenv
;
3175 int count
= SPECPDL_INDEX ();
3176 int i
, optional
, rest
;
3179 && FUNVEC_SIZE (fun
) > COMPILED_PUSH_ARGS
3180 && ! NILP (XVECTOR (fun
)->contents
[COMPILED_PUSH_ARGS
]))
3181 /* A byte-code object with a non-nil `push args' slot means we
3182 shouldn't bind any arguments, instead just call the byte-code
3183 interpreter directly; it will push arguments as necessary.
3185 Byte-code objects with either a non-existant, or a nil value for
3186 the `push args' slot (the default), have dynamically-bound
3187 arguments, and use the argument-binding code below instead (as do
3188 all interpreted functions, even lexically bound ones). */
3190 /* If we have not actually read the bytecode string
3191 and constants vector yet, fetch them from the file. */
3192 if (CONSP (AREF (fun
, COMPILED_BYTECODE
)))
3193 Ffetch_bytecode (fun
);
3194 return exec_byte_code (AREF (fun
, COMPILED_BYTECODE
),
3195 AREF (fun
, COMPILED_CONSTANTS
),
3196 AREF (fun
, COMPILED_STACK_DEPTH
),
3197 AREF (fun
, COMPILED_ARGLIST
),
3201 if (FUNVECP (fun
) && !FUNVEC_COMPILED_P (fun
))
3202 /* Byte-compiled functions are handled directly below, but we
3203 call other funvec types via funcall_funvec. */
3204 return funcall_funvec (fun
, nargs
, arg_vector
);
3208 if (EQ (XCAR (fun
), Qclosure
))
3210 fun
= XCDR (fun
); /* Drop `closure'. */
3211 lexenv
= XCAR (fun
);
3212 fun
= XCDR (fun
); /* Drop the lexical environment. */
3216 syms_left
= XCDR (fun
);
3217 if (CONSP (syms_left
))
3218 syms_left
= XCAR (syms_left
);
3220 xsignal1 (Qinvalid_function
, fun
);
3222 else if (COMPILEDP (fun
))
3224 syms_left
= AREF (fun
, COMPILED_ARGLIST
);
3230 i
= optional
= rest
= 0;
3231 for (; CONSP (syms_left
); syms_left
= XCDR (syms_left
))
3235 next
= XCAR (syms_left
);
3236 if (!SYMBOLP (next
))
3237 xsignal1 (Qinvalid_function
, fun
);
3239 if (EQ (next
, Qand_rest
))
3241 else if (EQ (next
, Qand_optional
))
3248 val
= Flist (nargs
- i
, &arg_vector
[i
]);
3252 val
= arg_vector
[i
++];
3254 xsignal2 (Qwrong_number_of_arguments
, fun
, make_number (nargs
));
3258 /* Bind the argument. */
3259 if (!NILP (lexenv
) && SYMBOLP (next
)
3260 /* FIXME: there's no good reason to allow dynamic-scoping
3261 on function arguments, other than consistency with let. */
3262 && !XSYMBOL (next
)->declared_special
3263 && NILP (Fmemq (next
, Vinternal_interpreter_environment
)))
3264 /* Lexically bind NEXT by adding it to the lexenv alist. */
3265 lexenv
= Fcons (Fcons (next
, val
), lexenv
);
3267 /* Dynamically bind NEXT. */
3268 specbind (next
, val
);
3272 if (!NILP (syms_left
))
3273 xsignal1 (Qinvalid_function
, fun
);
3275 xsignal2 (Qwrong_number_of_arguments
, fun
, make_number (nargs
));
3277 if (!EQ (lexenv
, Vinternal_interpreter_environment
))
3278 /* Instantiate a new lexical environment. */
3279 specbind (Qinternal_interpreter_environment
, lexenv
);
3282 val
= Fprogn (XCDR (XCDR (fun
)));
3285 /* If we have not actually read the bytecode string
3286 and constants vector yet, fetch them from the file. */
3287 if (CONSP (AREF (fun
, COMPILED_BYTECODE
)))
3288 Ffetch_bytecode (fun
);
3289 val
= exec_byte_code (AREF (fun
, COMPILED_BYTECODE
),
3290 AREF (fun
, COMPILED_CONSTANTS
),
3291 AREF (fun
, COMPILED_STACK_DEPTH
),
3295 return unbind_to (count
, val
);
3298 DEFUN ("fetch-bytecode", Ffetch_bytecode
, Sfetch_bytecode
,
3300 doc
: /* If byte-compiled OBJECT is lazy-loaded, fetch it now. */)
3301 (Lisp_Object object
)
3305 if (COMPILEDP (object
) && CONSP (AREF (object
, COMPILED_BYTECODE
)))
3307 tem
= read_doc_string (AREF (object
, COMPILED_BYTECODE
));
3310 tem
= AREF (object
, COMPILED_BYTECODE
);
3311 if (CONSP (tem
) && STRINGP (XCAR (tem
)))
3312 error ("Invalid byte code in %s", SDATA (XCAR (tem
)));
3314 error ("Invalid byte code");
3316 ASET (object
, COMPILED_BYTECODE
, XCAR (tem
));
3317 ASET (object
, COMPILED_CONSTANTS
, XCDR (tem
));
3325 register int count
= SPECPDL_INDEX ();
3326 if (specpdl_size
>= max_specpdl_size
)
3328 if (max_specpdl_size
< 400)
3329 max_specpdl_size
= 400;
3330 if (specpdl_size
>= max_specpdl_size
)
3331 signal_error ("Variable binding depth exceeds max-specpdl-size", Qnil
);
3334 if (specpdl_size
> max_specpdl_size
)
3335 specpdl_size
= max_specpdl_size
;
3336 specpdl
= (struct specbinding
*) xrealloc (specpdl
, specpdl_size
* sizeof (struct specbinding
));
3337 specpdl_ptr
= specpdl
+ count
;
3340 /* specpdl_ptr->symbol is a field which describes which variable is
3341 let-bound, so it can be properly undone when we unbind_to.
3342 It can have the following two shapes:
3343 - SYMBOL : if it's a plain symbol, it means that we have let-bound
3344 a symbol that is not buffer-local (at least at the time
3345 the let binding started). Note also that it should not be
3346 aliased (i.e. when let-binding V1 that's aliased to V2, we want
3348 - (SYMBOL WHERE . BUFFER) : this means that it is a let-binding for
3349 variable SYMBOL which can be buffer-local. WHERE tells us
3350 which buffer is affected (or nil if the let-binding affects the
3351 global value of the variable) and BUFFER tells us which buffer was
3352 current (i.e. if WHERE is non-nil, then BUFFER==WHERE, otherwise
3353 BUFFER did not yet have a buffer-local value). */
3356 specbind (Lisp_Object symbol
, Lisp_Object value
)
3358 struct Lisp_Symbol
*sym
;
3360 eassert (!handling_signal
);
3362 CHECK_SYMBOL (symbol
);
3363 sym
= XSYMBOL (symbol
);
3364 if (specpdl_ptr
== specpdl
+ specpdl_size
)
3368 switch (sym
->redirect
)
3370 case SYMBOL_VARALIAS
:
3371 sym
= indirect_variable (sym
); XSETSYMBOL (symbol
, sym
); goto start
;
3372 case SYMBOL_PLAINVAL
:
3373 /* The most common case is that of a non-constant symbol with a
3374 trivial value. Make that as fast as we can. */
3375 specpdl_ptr
->symbol
= symbol
;
3376 specpdl_ptr
->old_value
= SYMBOL_VAL (sym
);
3377 specpdl_ptr
->func
= NULL
;
3380 SET_SYMBOL_VAL (sym
, value
);
3382 set_internal (symbol
, value
, Qnil
, 1);
3384 case SYMBOL_LOCALIZED
:
3385 if (SYMBOL_BLV (sym
)->frame_local
)
3386 error ("Frame-local vars cannot be let-bound");
3387 case SYMBOL_FORWARDED
:
3389 Lisp_Object ovalue
= find_symbol_value (symbol
);
3390 specpdl_ptr
->func
= 0;
3391 specpdl_ptr
->old_value
= ovalue
;
3393 eassert (sym
->redirect
!= SYMBOL_LOCALIZED
3394 || (EQ (SYMBOL_BLV (sym
)->where
,
3395 SYMBOL_BLV (sym
)->frame_local
?
3396 Fselected_frame () : Fcurrent_buffer ())));
3398 if (sym
->redirect
== SYMBOL_LOCALIZED
3399 || BUFFER_OBJFWDP (SYMBOL_FWD (sym
)))
3401 Lisp_Object where
, cur_buf
= Fcurrent_buffer ();
3403 /* For a local variable, record both the symbol and which
3404 buffer's or frame's value we are saving. */
3405 if (!NILP (Flocal_variable_p (symbol
, Qnil
)))
3407 eassert (sym
->redirect
!= SYMBOL_LOCALIZED
3408 || (BLV_FOUND (SYMBOL_BLV (sym
))
3409 && EQ (cur_buf
, SYMBOL_BLV (sym
)->where
)));
3412 else if (sym
->redirect
== SYMBOL_LOCALIZED
3413 && BLV_FOUND (SYMBOL_BLV (sym
)))
3414 where
= SYMBOL_BLV (sym
)->where
;
3418 /* We're not using the `unused' slot in the specbinding
3419 structure because this would mean we have to do more
3420 work for simple variables. */
3421 /* FIXME: The third value `current_buffer' is only used in
3422 let_shadows_buffer_binding_p which is itself only used
3423 in set_internal for local_if_set. */
3424 eassert (NILP (where
) || EQ (where
, cur_buf
));
3425 specpdl_ptr
->symbol
= Fcons (symbol
, Fcons (where
, cur_buf
));
3427 /* If SYMBOL is a per-buffer variable which doesn't have a
3428 buffer-local value here, make the `let' change the global
3429 value by changing the value of SYMBOL in all buffers not
3430 having their own value. This is consistent with what
3431 happens with other buffer-local variables. */
3433 && sym
->redirect
== SYMBOL_FORWARDED
)
3435 eassert (BUFFER_OBJFWDP (SYMBOL_FWD (sym
)));
3437 Fset_default (symbol
, value
);
3442 specpdl_ptr
->symbol
= symbol
;
3445 set_internal (symbol
, value
, Qnil
, 1);
3453 record_unwind_protect (Lisp_Object (*function
) (Lisp_Object
), Lisp_Object arg
)
3455 eassert (!handling_signal
);
3457 if (specpdl_ptr
== specpdl
+ specpdl_size
)
3459 specpdl_ptr
->func
= function
;
3460 specpdl_ptr
->symbol
= Qnil
;
3461 specpdl_ptr
->old_value
= arg
;
3466 unbind_to (int count
, Lisp_Object value
)
3468 Lisp_Object quitf
= Vquit_flag
;
3469 struct gcpro gcpro1
, gcpro2
;
3471 GCPRO2 (value
, quitf
);
3474 while (specpdl_ptr
!= specpdl
+ count
)
3476 /* Copy the binding, and decrement specpdl_ptr, before we do
3477 the work to unbind it. We decrement first
3478 so that an error in unbinding won't try to unbind
3479 the same entry again, and we copy the binding first
3480 in case more bindings are made during some of the code we run. */
3482 struct specbinding this_binding
;
3483 this_binding
= *--specpdl_ptr
;
3485 if (this_binding
.func
!= 0)
3486 (*this_binding
.func
) (this_binding
.old_value
);
3487 /* If the symbol is a list, it is really (SYMBOL WHERE
3488 . CURRENT-BUFFER) where WHERE is either nil, a buffer, or a
3489 frame. If WHERE is a buffer or frame, this indicates we
3490 bound a variable that had a buffer-local or frame-local
3491 binding. WHERE nil means that the variable had the default
3492 value when it was bound. CURRENT-BUFFER is the buffer that
3493 was current when the variable was bound. */
3494 else if (CONSP (this_binding
.symbol
))
3496 Lisp_Object symbol
, where
;
3498 symbol
= XCAR (this_binding
.symbol
);
3499 where
= XCAR (XCDR (this_binding
.symbol
));
3502 Fset_default (symbol
, this_binding
.old_value
);
3503 /* If `where' is non-nil, reset the value in the appropriate
3504 local binding, but only if that binding still exists. */
3505 else if (BUFFERP (where
)
3506 ? !NILP (Flocal_variable_p (symbol
, where
))
3507 : !NILP (Fassq (symbol
, XFRAME (where
)->param_alist
)))
3508 set_internal (symbol
, this_binding
.old_value
, where
, 1);
3510 /* If variable has a trivial value (no forwarding), we can
3511 just set it. No need to check for constant symbols here,
3512 since that was already done by specbind. */
3513 else if (XSYMBOL (this_binding
.symbol
)->redirect
== SYMBOL_PLAINVAL
)
3514 SET_SYMBOL_VAL (XSYMBOL (this_binding
.symbol
),
3515 this_binding
.old_value
);
3517 /* NOTE: we only ever come here if make_local_foo was used for
3518 the first time on this var within this let. */
3519 Fset_default (this_binding
.symbol
, this_binding
.old_value
);
3522 if (NILP (Vquit_flag
) && !NILP (quitf
))
3531 DEFUN ("special-variable-p", Fspecial_variable_p
, Sspecial_variable_p
, 1, 1, 0,
3532 doc
: /* Return non-nil if SYMBOL's global binding has been declared special.
3533 A special variable is one that will be bound dynamically, even in a
3534 context where binding is lexical by default. */)
3535 (Lisp_Object symbol
)
3537 CHECK_SYMBOL (symbol
);
3538 return XSYMBOL (symbol
)->declared_special
? Qt
: Qnil
;
3543 DEFUN ("curry", Fcurry
, Scurry
, 1, MANY
, 0,
3544 doc
: /* Return FUN curried with ARGS.
3545 The result is a function-like object that will append any arguments it
3546 is called with to ARGS, and call FUN with the resulting list of arguments.
3549 (funcall (curry '+ 3 4 5) 2) is the same as (funcall '+ 3 4 5 2)
3551 (mapcar (curry 'concat "The ") '("a" "b" "c"))
3552 => ("The a" "The b" "The c")
3554 usage: (curry FUN &rest ARGS) */)
3555 (int nargs
, Lisp_Object
*args
)
3557 return make_funvec (Qcurry
, 0, nargs
, args
);
3561 DEFUN ("backtrace-debug", Fbacktrace_debug
, Sbacktrace_debug
, 2, 2, 0,
3562 doc
: /* Set the debug-on-exit flag of eval frame LEVEL levels down to FLAG.
3563 The debugger is entered when that frame exits, if the flag is non-nil. */)
3564 (Lisp_Object level
, Lisp_Object flag
)
3566 register struct backtrace
*backlist
= backtrace_list
;
3569 CHECK_NUMBER (level
);
3571 for (i
= 0; backlist
&& i
< XINT (level
); i
++)
3573 backlist
= backlist
->next
;
3577 backlist
->debug_on_exit
= !NILP (flag
);
3582 DEFUN ("backtrace", Fbacktrace
, Sbacktrace
, 0, 0, "",
3583 doc
: /* Print a trace of Lisp function calls currently active.
3584 Output stream used is value of `standard-output'. */)
3587 register struct backtrace
*backlist
= backtrace_list
;
3591 struct gcpro gcpro1
;
3592 Lisp_Object old_print_level
= Vprint_level
;
3594 if (NILP (Vprint_level
))
3595 XSETFASTINT (Vprint_level
, 8);
3602 write_string (backlist
->debug_on_exit
? "* " : " ", 2);
3603 if (backlist
->nargs
== UNEVALLED
)
3605 Fprin1 (Fcons (*backlist
->function
, *backlist
->args
), Qnil
);
3606 write_string ("\n", -1);
3610 tem
= *backlist
->function
;
3611 Fprin1 (tem
, Qnil
); /* This can QUIT */
3612 write_string ("(", -1);
3613 if (backlist
->nargs
== MANY
)
3615 for (tail
= *backlist
->args
, i
= 0;
3617 tail
= Fcdr (tail
), i
++)
3619 if (i
) write_string (" ", -1);
3620 Fprin1 (Fcar (tail
), Qnil
);
3625 for (i
= 0; i
< backlist
->nargs
; i
++)
3627 if (i
) write_string (" ", -1);
3628 Fprin1 (backlist
->args
[i
], Qnil
);
3631 write_string (")\n", -1);
3633 backlist
= backlist
->next
;
3636 Vprint_level
= old_print_level
;
3641 DEFUN ("backtrace-frame", Fbacktrace_frame
, Sbacktrace_frame
, 1, 1, NULL
,
3642 doc
: /* Return the function and arguments NFRAMES up from current execution point.
3643 If that frame has not evaluated the arguments yet (or is a special form),
3644 the value is (nil FUNCTION ARG-FORMS...).
3645 If that frame has evaluated its arguments and called its function already,
3646 the value is (t FUNCTION ARG-VALUES...).
3647 A &rest arg is represented as the tail of the list ARG-VALUES.
3648 FUNCTION is whatever was supplied as car of evaluated list,
3649 or a lambda expression for macro calls.
3650 If NFRAMES is more than the number of frames, the value is nil. */)
3651 (Lisp_Object nframes
)
3653 register struct backtrace
*backlist
= backtrace_list
;
3657 CHECK_NATNUM (nframes
);
3659 /* Find the frame requested. */
3660 for (i
= 0; backlist
&& i
< XFASTINT (nframes
); i
++)
3661 backlist
= backlist
->next
;
3665 if (backlist
->nargs
== UNEVALLED
)
3666 return Fcons (Qnil
, Fcons (*backlist
->function
, *backlist
->args
));
3669 if (backlist
->nargs
== MANY
)
3670 tem
= *backlist
->args
;
3672 tem
= Flist (backlist
->nargs
, backlist
->args
);
3674 return Fcons (Qt
, Fcons (*backlist
->function
, tem
));
3680 mark_backtrace (void)
3682 register struct backtrace
*backlist
;
3685 for (backlist
= backtrace_list
; backlist
; backlist
= backlist
->next
)
3687 mark_object (*backlist
->function
);
3689 if (backlist
->nargs
== UNEVALLED
|| backlist
->nargs
== MANY
)
3692 i
= backlist
->nargs
- 1;
3694 mark_object (backlist
->args
[i
]);
3701 DEFVAR_INT ("max-specpdl-size", max_specpdl_size
,
3702 doc
: /* *Limit on number of Lisp variable bindings and `unwind-protect's.
3703 If Lisp code tries to increase the total number past this amount,
3704 an error is signaled.
3705 You can safely use a value considerably larger than the default value,
3706 if that proves inconveniently small. However, if you increase it too far,
3707 Emacs could run out of memory trying to make the stack bigger. */);
3709 DEFVAR_INT ("max-lisp-eval-depth", max_lisp_eval_depth
,
3710 doc
: /* *Limit on depth in `eval', `apply' and `funcall' before error.
3712 This limit serves to catch infinite recursions for you before they cause
3713 actual stack overflow in C, which would be fatal for Emacs.
3714 You can safely make it considerably larger than its default value,
3715 if that proves inconveniently small. However, if you increase it too far,
3716 Emacs could overflow the real C stack, and crash. */);
3718 DEFVAR_LISP ("quit-flag", Vquit_flag
,
3719 doc
: /* Non-nil causes `eval' to abort, unless `inhibit-quit' is non-nil.
3720 If the value is t, that means do an ordinary quit.
3721 If the value equals `throw-on-input', that means quit by throwing
3722 to the tag specified in `throw-on-input'; it's for handling `while-no-input'.
3723 Typing C-g sets `quit-flag' to t, regardless of `inhibit-quit',
3724 but `inhibit-quit' non-nil prevents anything from taking notice of that. */);
3727 DEFVAR_LISP ("inhibit-quit", Vinhibit_quit
,
3728 doc
: /* Non-nil inhibits C-g quitting from happening immediately.
3729 Note that `quit-flag' will still be set by typing C-g,
3730 so a quit will be signaled as soon as `inhibit-quit' is nil.
3731 To prevent this happening, set `quit-flag' to nil
3732 before making `inhibit-quit' nil. */);
3733 Vinhibit_quit
= Qnil
;
3735 Qinhibit_quit
= intern_c_string ("inhibit-quit");
3736 staticpro (&Qinhibit_quit
);
3738 Qautoload
= intern_c_string ("autoload");
3739 staticpro (&Qautoload
);
3741 Qdebug_on_error
= intern_c_string ("debug-on-error");
3742 staticpro (&Qdebug_on_error
);
3744 Qmacro
= intern_c_string ("macro");
3745 staticpro (&Qmacro
);
3747 Qdeclare
= intern_c_string ("declare");
3748 staticpro (&Qdeclare
);
3750 /* Note that the process handling also uses Qexit, but we don't want
3751 to staticpro it twice, so we just do it here. */
3752 Qexit
= intern_c_string ("exit");
3755 Qinteractive
= intern_c_string ("interactive");
3756 staticpro (&Qinteractive
);
3758 Qcommandp
= intern_c_string ("commandp");
3759 staticpro (&Qcommandp
);
3761 Qdefun
= intern_c_string ("defun");
3762 staticpro (&Qdefun
);
3764 Qand_rest
= intern_c_string ("&rest");
3765 staticpro (&Qand_rest
);
3767 Qand_optional
= intern_c_string ("&optional");
3768 staticpro (&Qand_optional
);
3770 Qclosure
= intern_c_string ("closure");
3771 staticpro (&Qclosure
);
3773 Qcurry
= intern_c_string ("curry");
3774 staticpro (&Qcurry
);
3776 Qdebug
= intern_c_string ("debug");
3777 staticpro (&Qdebug
);
3779 DEFVAR_LISP ("debug-on-error", Vdebug_on_error
,
3780 doc
: /* *Non-nil means enter debugger if an error is signaled.
3781 Does not apply to errors handled by `condition-case' or those
3782 matched by `debug-ignored-errors'.
3783 If the value is a list, an error only means to enter the debugger
3784 if one of its condition symbols appears in the list.
3785 When you evaluate an expression interactively, this variable
3786 is temporarily non-nil if `eval-expression-debug-on-error' is non-nil.
3787 The command `toggle-debug-on-error' toggles this.
3788 See also the variable `debug-on-quit'. */);
3789 Vdebug_on_error
= Qnil
;
3791 DEFVAR_LISP ("debug-ignored-errors", Vdebug_ignored_errors
,
3792 doc
: /* *List of errors for which the debugger should not be called.
3793 Each element may be a condition-name or a regexp that matches error messages.
3794 If any element applies to a given error, that error skips the debugger
3795 and just returns to top level.
3796 This overrides the variable `debug-on-error'.
3797 It does not apply to errors handled by `condition-case'. */);
3798 Vdebug_ignored_errors
= Qnil
;
3800 DEFVAR_BOOL ("debug-on-quit", debug_on_quit
,
3801 doc
: /* *Non-nil means enter debugger if quit is signaled (C-g, for example).
3802 Does not apply if quit is handled by a `condition-case'. */);
3805 DEFVAR_BOOL ("debug-on-next-call", debug_on_next_call
,
3806 doc
: /* Non-nil means enter debugger before next `eval', `apply' or `funcall'. */);
3808 DEFVAR_BOOL ("debugger-may-continue", debugger_may_continue
,
3809 doc
: /* Non-nil means debugger may continue execution.
3810 This is nil when the debugger is called under circumstances where it
3811 might not be safe to continue. */);
3812 debugger_may_continue
= 1;
3814 DEFVAR_LISP ("debugger", Vdebugger
,
3815 doc
: /* Function to call to invoke debugger.
3816 If due to frame exit, args are `exit' and the value being returned;
3817 this function's value will be returned instead of that.
3818 If due to error, args are `error' and a list of the args to `signal'.
3819 If due to `apply' or `funcall' entry, one arg, `lambda'.
3820 If due to `eval' entry, one arg, t. */);
3823 DEFVAR_LISP ("signal-hook-function", Vsignal_hook_function
,
3824 doc
: /* If non-nil, this is a function for `signal' to call.
3825 It receives the same arguments that `signal' was given.
3826 The Edebug package uses this to regain control. */);
3827 Vsignal_hook_function
= Qnil
;
3829 DEFVAR_LISP ("debug-on-signal", Vdebug_on_signal
,
3830 doc
: /* *Non-nil means call the debugger regardless of condition handlers.
3831 Note that `debug-on-error', `debug-on-quit' and friends
3832 still determine whether to handle the particular condition. */);
3833 Vdebug_on_signal
= Qnil
;
3835 DEFVAR_LISP ("macro-declaration-function", Vmacro_declaration_function
,
3836 doc
: /* Function to process declarations in a macro definition.
3837 The function will be called with two args MACRO and DECL.
3838 MACRO is the name of the macro being defined.
3839 DECL is a list `(declare ...)' containing the declarations.
3840 The value the function returns is not used. */);
3841 Vmacro_declaration_function
= Qnil
;
3843 Qinternal_interpreter_environment
3844 = intern_c_string ("internal-interpreter-environment");
3845 staticpro (&Qinternal_interpreter_environment
);
3846 #if 0 /* Don't export this variable to Elisp, so noone can mess with it
3847 (Just imagine if someone makes it buffer-local). */
3848 DEFVAR__LISP ("internal-interpreter-environment",
3849 Vinternal_interpreter_environment
,
3850 doc
: /* If non-nil, the current lexical environment of the lisp interpreter.
3851 When lexical binding is not being used, this variable is nil.
3852 A value of `(t)' indicates an empty environment, otherwise it is an
3853 alist of active lexical bindings. */);
3855 Vinternal_interpreter_environment
= Qnil
;
3857 Vrun_hooks
= intern_c_string ("run-hooks");
3858 staticpro (&Vrun_hooks
);
3860 staticpro (&Vautoload_queue
);
3861 Vautoload_queue
= Qnil
;
3862 staticpro (&Vsignaling_function
);
3863 Vsignaling_function
= Qnil
;
3874 defsubr (&Sfunction
);
3876 defsubr (&Sdefmacro
);
3878 defsubr (&Sdefvaralias
);
3879 defsubr (&Sdefconst
);
3880 defsubr (&Suser_variable_p
);
3884 defsubr (&Smacroexpand
);
3887 defsubr (&Sunwind_protect
);
3888 defsubr (&Scondition_case
);
3890 defsubr (&Sinteractive_p
);
3891 defsubr (&Scalled_interactively_p
);
3892 defsubr (&Scommandp
);
3893 defsubr (&Sautoload
);
3896 defsubr (&Sfuncall
);
3897 defsubr (&Srun_hooks
);
3898 defsubr (&Srun_hook_with_args
);
3899 defsubr (&Srun_hook_with_args_until_success
);
3900 defsubr (&Srun_hook_with_args_until_failure
);
3901 defsubr (&Sfetch_bytecode
);
3903 defsubr (&Sbacktrace_debug
);
3904 defsubr (&Sbacktrace
);
3905 defsubr (&Sbacktrace_frame
);
3907 defsubr (&Sspecial_variable_p
);
3908 defsubr (&Sfunctionp
);