1 /* Evaluator for GNU Emacs Lisp interpreter.
2 Copyright (C) 1985, 86, 87, 93, 94, 95, 99, 2000, 2001, 2002
3 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
25 #include "blockinput.h"
28 #include "dispextern.h"
31 /* This definition is duplicated in alloc.c and keyboard.c */
32 /* Putting it in lisp.h makes cc bomb out! */
36 struct backtrace
*next
;
37 Lisp_Object
*function
;
38 Lisp_Object
*args
; /* Points to vector of args. */
39 int nargs
; /* Length of vector.
40 If nargs is UNEVALLED, args points to slot holding
41 list of unevalled args */
43 /* Nonzero means call value of debugger when done with this operation. */
47 struct backtrace
*backtrace_list
;
49 /* This structure helps implement the `catch' and `throw' control
50 structure. A struct catchtag contains all the information needed
51 to restore the state of the interpreter after a non-local jump.
53 Handlers for error conditions (represented by `struct handler'
54 structures) just point to a catch tag to do the cleanup required
57 catchtag structures are chained together in the C calling stack;
58 the `next' member points to the next outer catchtag.
60 A call like (throw TAG VAL) searches for a catchtag whose `tag'
61 member is TAG, and then unbinds to it. The `val' member is used to
62 hold VAL while the stack is unwound; `val' is returned as the value
65 All the other members are concerned with restoring the interpreter
72 struct catchtag
*next
;
75 struct backtrace
*backlist
;
76 struct handler
*handlerlist
;
79 int poll_suppress_count
;
80 int interrupt_input_blocked
;
81 struct byte_stack
*byte_stack
;
84 struct catchtag
*catchlist
;
87 /* Count levels of GCPRO to detect failure to UNGCPRO. */
91 Lisp_Object Qautoload
, Qmacro
, Qexit
, Qinteractive
, Qcommandp
, Qdefun
, Qdefvar
;
92 Lisp_Object Qinhibit_quit
, Vinhibit_quit
, Vquit_flag
;
93 Lisp_Object Qand_rest
, Qand_optional
;
94 Lisp_Object Qdebug_on_error
;
97 /* This holds either the symbol `run-hooks' or nil.
98 It is nil at an early stage of startup, and when Emacs
101 Lisp_Object Vrun_hooks
;
103 /* Non-nil means record all fset's and provide's, to be undone
104 if the file being autoloaded is not fully loaded.
105 They are recorded by being consed onto the front of Vautoload_queue:
106 (FUN . ODEF) for a defun, (OFEATURES . nil) for a provide. */
108 Lisp_Object Vautoload_queue
;
110 /* Current number of specbindings allocated in specpdl. */
114 /* Pointer to beginning of specpdl. */
116 struct specbinding
*specpdl
;
118 /* Pointer to first unused element in specpdl. */
120 volatile struct specbinding
*specpdl_ptr
;
122 /* Maximum size allowed for specpdl allocation */
124 EMACS_INT max_specpdl_size
;
126 /* Depth in Lisp evaluations and function calls. */
130 /* Maximum allowed depth in Lisp evaluations and function calls. */
132 EMACS_INT max_lisp_eval_depth
;
134 /* Nonzero means enter debugger before next function call */
136 int debug_on_next_call
;
138 /* Non-zero means debugger may continue. This is zero when the
139 debugger is called during redisplay, where it might not be safe to
140 continue the interrupted redisplay. */
142 int debugger_may_continue
;
144 /* List of conditions (non-nil atom means all) which cause a backtrace
145 if an error is handled by the command loop's error handler. */
147 Lisp_Object Vstack_trace_on_error
;
149 /* List of conditions (non-nil atom means all) which enter the debugger
150 if an error is handled by the command loop's error handler. */
152 Lisp_Object Vdebug_on_error
;
154 /* List of conditions and regexps specifying error messages which
155 do not enter the debugger even if Vdebug_on_error says they should. */
157 Lisp_Object Vdebug_ignored_errors
;
159 /* Non-nil means call the debugger even if the error will be handled. */
161 Lisp_Object Vdebug_on_signal
;
163 /* Hook for edebug to use. */
165 Lisp_Object Vsignal_hook_function
;
167 /* Nonzero means enter debugger if a quit signal
168 is handled by the command loop's error handler. */
172 /* The value of num_nonmacro_input_events as of the last time we
173 started to enter the debugger. If we decide to enter the debugger
174 again when this is still equal to num_nonmacro_input_events, then we
175 know that the debugger itself has an error, and we should just
176 signal the error instead of entering an infinite loop of debugger
179 int when_entered_debugger
;
181 Lisp_Object Vdebugger
;
183 /* The function from which the last `signal' was called. Set in
186 Lisp_Object Vsignaling_function
;
188 /* Set to non-zero while processing X events. Checked in Feval to
189 make sure the Lisp interpreter isn't called from a signal handler,
190 which is unsafe because the interpreter isn't reentrant. */
194 /* Function to process declarations in defmacro forms. */
196 Lisp_Object Vmacro_declaration_function
;
199 static Lisp_Object funcall_lambda
P_ ((Lisp_Object
, int, Lisp_Object
*));
205 specpdl
= (struct specbinding
*) xmalloc (specpdl_size
* sizeof (struct specbinding
));
206 specpdl_ptr
= specpdl
;
207 max_specpdl_size
= 600;
208 max_lisp_eval_depth
= 300;
216 specpdl_ptr
= specpdl
;
221 debug_on_next_call
= 0;
226 /* This is less than the initial value of num_nonmacro_input_events. */
227 when_entered_debugger
= -1;
234 int debug_while_redisplaying
;
235 int count
= SPECPDL_INDEX ();
238 if (lisp_eval_depth
+ 20 > max_lisp_eval_depth
)
239 max_lisp_eval_depth
= lisp_eval_depth
+ 20;
241 if (specpdl_size
+ 40 > max_specpdl_size
)
242 max_specpdl_size
= specpdl_size
+ 40;
244 #ifdef HAVE_X_WINDOWS
245 if (display_hourglass_p
)
249 debug_on_next_call
= 0;
250 when_entered_debugger
= num_nonmacro_input_events
;
252 /* Resetting redisplaying_p to 0 makes sure that debug output is
253 displayed if the debugger is invoked during redisplay. */
254 debug_while_redisplaying
= redisplaying_p
;
256 specbind (intern ("debugger-may-continue"),
257 debug_while_redisplaying
? Qnil
: Qt
);
258 specbind (Qinhibit_redisplay
, Qnil
);
260 #if 0 /* Binding this prevents execution of Lisp code during
261 redisplay, which necessarily leads to display problems. */
262 specbind (Qinhibit_eval_during_redisplay
, Qt
);
265 val
= apply1 (Vdebugger
, arg
);
267 /* Interrupting redisplay and resuming it later is not safe under
268 all circumstances. So, when the debugger returns, abort the
269 interrupted redisplay by going back to the top-level. */
270 if (debug_while_redisplaying
)
273 return unbind_to (count
, val
);
277 do_debug_on_call (code
)
280 debug_on_next_call
= 0;
281 backtrace_list
->debug_on_exit
= 1;
282 call_debugger (Fcons (code
, Qnil
));
285 /* NOTE!!! Every function that can call EVAL must protect its args
286 and temporaries from garbage collection while it needs them.
287 The definition of `For' shows what you have to do. */
289 DEFUN ("or", For
, Sor
, 0, UNEVALLED
, 0,
290 doc
: /* Eval args until one of them yields non-nil, then return that value.
291 The remaining args are not evalled at all.
292 If all args return nil, return nil.
293 usage: (or CONDITIONS ...) */)
297 register Lisp_Object val
= Qnil
;
304 val
= Feval (XCAR (args
));
314 DEFUN ("and", Fand
, Sand
, 0, UNEVALLED
, 0,
315 doc
: /* Eval args until one of them yields nil, then return nil.
316 The remaining args are not evalled at all.
317 If no arg yields nil, return the last arg's value.
318 usage: (and CONDITIONS ...) */)
322 register Lisp_Object val
= Qt
;
329 val
= Feval (XCAR (args
));
339 DEFUN ("if", Fif
, Sif
, 2, UNEVALLED
, 0,
340 doc
: /* If COND yields non-nil, do THEN, else do ELSE...
341 Returns the value of THEN or the value of the last of the ELSE's.
342 THEN must be one expression, but ELSE... can be zero or more expressions.
343 If COND yields nil, and there are no ELSE's, the value is nil.
344 usage: (if COND THEN ELSE...) */)
348 register Lisp_Object cond
;
352 cond
= Feval (Fcar (args
));
356 return Feval (Fcar (Fcdr (args
)));
357 return Fprogn (Fcdr (Fcdr (args
)));
360 DEFUN ("cond", Fcond
, Scond
, 0, UNEVALLED
, 0,
361 doc
: /* Try each clause until one succeeds.
362 Each clause looks like (CONDITION BODY...). CONDITION is evaluated
363 and, if the value is non-nil, this clause succeeds:
364 then the expressions in BODY are evaluated and the last one's
365 value is the value of the cond-form.
366 If no clause succeeds, cond returns nil.
367 If a clause has one element, as in (CONDITION),
368 CONDITION's value if non-nil is returned from the cond-form.
369 usage: (cond CLAUSES...) */)
373 register Lisp_Object clause
, val
;
380 clause
= Fcar (args
);
381 val
= Feval (Fcar (clause
));
384 if (!EQ (XCDR (clause
), Qnil
))
385 val
= Fprogn (XCDR (clause
));
395 DEFUN ("progn", Fprogn
, Sprogn
, 0, UNEVALLED
, 0,
396 doc
: /* Eval BODY forms sequentially and return value of last one.
397 usage: (progn BODY ...) */)
401 register Lisp_Object val
= Qnil
;
408 val
= Feval (XCAR (args
));
416 DEFUN ("prog1", Fprog1
, Sprog1
, 1, UNEVALLED
, 0,
417 doc
: /* Eval FIRST and BODY sequentially; value from FIRST.
418 The value of FIRST is saved during the evaluation of the remaining args,
419 whose values are discarded.
420 usage: (prog1 FIRST BODY...) */)
425 register Lisp_Object args_left
;
426 struct gcpro gcpro1
, gcpro2
;
427 register int argnum
= 0;
439 val
= Feval (Fcar (args_left
));
441 Feval (Fcar (args_left
));
442 args_left
= Fcdr (args_left
);
444 while (!NILP(args_left
));
450 DEFUN ("prog2", Fprog2
, Sprog2
, 2, UNEVALLED
, 0,
451 doc
: /* Eval X, Y and BODY sequentially; value from Y.
452 The value of Y is saved during the evaluation of the remaining args,
453 whose values are discarded.
454 usage: (prog2 X Y BODY...) */)
459 register Lisp_Object args_left
;
460 struct gcpro gcpro1
, gcpro2
;
461 register int argnum
= -1;
475 val
= Feval (Fcar (args_left
));
477 Feval (Fcar (args_left
));
478 args_left
= Fcdr (args_left
);
480 while (!NILP (args_left
));
486 DEFUN ("setq", Fsetq
, Ssetq
, 0, UNEVALLED
, 0,
487 doc
: /* Set each SYM to the value of its VAL.
488 The symbols SYM are variables; they are literal (not evaluated).
489 The values VAL are expressions; they are evaluated.
490 Thus, (setq x (1+ y)) sets `x' to the value of `(1+ y)'.
491 The second VAL is not computed until after the first SYM is set, and so on;
492 each VAL can use the new value of variables set earlier in the `setq'.
493 The return value of the `setq' form is the value of the last VAL.
494 usage: (setq SYM VAL SYM VAL ...) */)
498 register Lisp_Object args_left
;
499 register Lisp_Object val
, sym
;
510 val
= Feval (Fcar (Fcdr (args_left
)));
511 sym
= Fcar (args_left
);
513 args_left
= Fcdr (Fcdr (args_left
));
515 while (!NILP(args_left
));
521 DEFUN ("quote", Fquote
, Squote
, 1, UNEVALLED
, 0,
522 doc
: /* Return the argument, without evaluating it. `(quote x)' yields `x'.
523 usage: (quote ARG) */)
530 DEFUN ("function", Ffunction
, Sfunction
, 1, UNEVALLED
, 0,
531 doc
: /* Like `quote', but preferred for objects which are functions.
532 In byte compilation, `function' causes its argument to be compiled.
533 `quote' cannot do that.
534 usage: (function ARG) */)
542 DEFUN ("interactive-p", Finteractive_p
, Sinteractive_p
, 0, 0, 0,
543 doc
: /* Return t if function in which this appears was called interactively.
544 This means that the function was called with call-interactively (which
545 includes being called as the binding of a key)
546 and input is currently coming from the keyboard (not in keyboard macro). */)
549 return interactive_p (1) ? Qt
: Qnil
;
553 /* Return 1 if function in which this appears was called
554 interactively. This means that the function was called with
555 call-interactively (which includes being called as the binding of
556 a key) and input is currently coming from the keyboard (not in
559 EXCLUDE_SUBRS_P non-zero means always return 0 if the function
560 called is a built-in. */
563 interactive_p (exclude_subrs_p
)
566 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
);
577 if (SUBRP (fun
) && XSUBR (fun
) == &Sinteractive_p
)
580 /* If we're running an Emacs 18-style byte-compiled function, there
581 may be a frame for Fbytecode at the top level. In any version of
582 Emacs there can be Fbytecode frames for subexpressions evaluated
583 inside catch and condition-case. Skip past them.
585 If this isn't a byte-compiled function, then we may now be
586 looking at several frames for special forms. Skip past them. */
588 && (EQ (*btp
->function
, Qbytecode
)
589 || btp
->nargs
== UNEVALLED
))
592 /* btp now points at the frame of the innermost function that isn't
593 a special form, ignoring frames for Finteractive_p and/or
594 Fbytecode at the top. If this frame is for a built-in function
595 (such as load or eval-region) return nil. */
596 fun
= Findirect_function (*btp
->function
);
597 if (exclude_subrs_p
&& SUBRP (fun
))
600 /* btp points to the frame of a Lisp function that called interactive-p.
601 Return t if that function was called interactively. */
602 if (btp
&& btp
->next
&& EQ (*btp
->next
->function
, Qcall_interactively
))
608 DEFUN ("defun", Fdefun
, Sdefun
, 2, UNEVALLED
, 0,
609 doc
: /* Define NAME as a function.
610 The definition is (lambda ARGLIST [DOCSTRING] BODY...).
611 See also the function `interactive'.
612 usage: (defun NAME ARGLIST [DOCSTRING] BODY...) */)
616 register Lisp_Object fn_name
;
617 register Lisp_Object defn
;
619 fn_name
= Fcar (args
);
620 defn
= Fcons (Qlambda
, Fcdr (args
));
621 if (!NILP (Vpurify_flag
))
622 defn
= Fpurecopy (defn
);
623 if (CONSP (XSYMBOL (fn_name
)->function
)
624 && EQ (XCAR (XSYMBOL (fn_name
)->function
), Qautoload
))
625 LOADHIST_ATTACH (Fcons (Qt
, fn_name
));
626 Ffset (fn_name
, defn
);
627 LOADHIST_ATTACH (fn_name
);
631 DEFUN ("defmacro", Fdefmacro
, Sdefmacro
, 2, UNEVALLED
, 0,
632 doc
: /* Define NAME as a macro.
633 The actual definition looks like
634 (macro lambda ARGLIST [DOCSTRING] [DECL] BODY...).
635 When the macro is called, as in (NAME ARGS...),
636 the function (lambda ARGLIST BODY...) is applied to
637 the list ARGS... as it appears in the expression,
638 and the result should be a form to be evaluated instead of the original.
640 DECL is a declaration, optional, which can specify how to indent
641 calls to this macro and how Edebug should handle it. It looks like this:
643 The elements can look like this:
645 Set NAME's `lisp-indent-function' property to INDENT.
648 Set NAME's `edebug-form-spec' property to DEBUG. (This is
649 equivalent to writing a `def-edebug-spec' for the macro.)
650 usage: (defmacro NAME ARGLIST [DOCSTRING] [DECL] BODY...) */)
654 register Lisp_Object fn_name
;
655 register Lisp_Object defn
;
656 Lisp_Object lambda_list
, doc
, tail
;
658 fn_name
= Fcar (args
);
659 lambda_list
= Fcar (Fcdr (args
));
660 tail
= Fcdr (Fcdr (args
));
663 if (STRINGP (Fcar (tail
)))
669 while (CONSP (Fcar (tail
))
670 && EQ (Fcar (Fcar (tail
)), Qdeclare
))
672 if (!NILP (Vmacro_declaration_function
))
676 call2 (Vmacro_declaration_function
, fn_name
, Fcar (tail
));
684 tail
= Fcons (lambda_list
, tail
);
686 tail
= Fcons (lambda_list
, Fcons (doc
, tail
));
687 defn
= Fcons (Qmacro
, Fcons (Qlambda
, tail
));
689 if (!NILP (Vpurify_flag
))
690 defn
= Fpurecopy (defn
);
691 if (CONSP (XSYMBOL (fn_name
)->function
)
692 && EQ (XCAR (XSYMBOL (fn_name
)->function
), Qautoload
))
693 LOADHIST_ATTACH (Fcons (Qt
, fn_name
));
694 Ffset (fn_name
, defn
);
695 LOADHIST_ATTACH (fn_name
);
700 DEFUN ("defvaralias", Fdefvaralias
, Sdefvaralias
, 2, 3, 0,
701 doc
: /* Make SYMBOL a variable alias for symbol ALIASED.
702 Setting the value of SYMBOL will subsequently set the value of ALIASED,
703 and getting the value of SYMBOL will return the value ALIASED has.
704 Third arg DOCSTRING, if non-nil, is documentation for SYMBOL.
705 The return value is ALIASED. */)
706 (symbol
, aliased
, docstring
)
707 Lisp_Object symbol
, aliased
, docstring
;
709 struct Lisp_Symbol
*sym
;
711 CHECK_SYMBOL (symbol
);
712 CHECK_SYMBOL (aliased
);
714 if (SYMBOL_CONSTANT_P (symbol
))
715 error ("Cannot make a constant an alias");
717 sym
= XSYMBOL (symbol
);
718 sym
->indirect_variable
= 1;
719 sym
->value
= aliased
;
720 sym
->constant
= SYMBOL_CONSTANT_P (aliased
);
721 LOADHIST_ATTACH (Fcons (Qdefvar
, symbol
));
722 if (!NILP (docstring
))
723 Fput (symbol
, Qvariable_documentation
, docstring
);
729 DEFUN ("defvar", Fdefvar
, Sdefvar
, 1, UNEVALLED
, 0,
730 doc
: /* Define SYMBOL as a variable.
731 You are not required to define a variable in order to use it,
732 but the definition can supply documentation and an initial value
733 in a way that tags can recognize.
735 INITVALUE is evaluated, and used to set SYMBOL, only if SYMBOL's value is void.
736 If SYMBOL is buffer-local, its default value is what is set;
737 buffer-local values are not affected.
738 INITVALUE and DOCSTRING are optional.
739 If DOCSTRING starts with *, this variable is identified as a user option.
740 This means that M-x set-variable recognizes it.
741 See also `user-variable-p'.
742 If INITVALUE is missing, SYMBOL's value is not set.
743 usage: (defvar SYMBOL &optional INITVALUE DOCSTRING) */)
747 register Lisp_Object sym
, tem
, tail
;
751 if (!NILP (Fcdr (Fcdr (tail
))))
752 error ("too many arguments");
754 tem
= Fdefault_boundp (sym
);
758 Fset_default (sym
, Feval (Fcar (tail
)));
763 if (!NILP (Vpurify_flag
))
764 tem
= Fpurecopy (tem
);
765 Fput (sym
, Qvariable_documentation
, tem
);
767 LOADHIST_ATTACH (Fcons (Qdefvar
, sym
));
770 /* Simple (defvar <var>) should not count as a definition at all.
771 It could get in the way of other definitions, and unloading this
772 package could try to make the variable unbound. */
778 DEFUN ("defconst", Fdefconst
, Sdefconst
, 2, UNEVALLED
, 0,
779 doc
: /* Define SYMBOL as a constant variable.
780 The intent is that neither programs nor users should ever change this value.
781 Always sets the value of SYMBOL to the result of evalling INITVALUE.
782 If SYMBOL is buffer-local, its default value is what is set;
783 buffer-local values are not affected.
784 DOCSTRING is optional.
785 usage: (defconst SYMBOL INITVALUE [DOCSTRING]) */)
789 register Lisp_Object sym
, tem
;
792 if (!NILP (Fcdr (Fcdr (Fcdr (args
)))))
793 error ("too many arguments");
795 tem
= Feval (Fcar (Fcdr (args
)));
796 if (!NILP (Vpurify_flag
))
797 tem
= Fpurecopy (tem
);
798 Fset_default (sym
, tem
);
799 tem
= Fcar (Fcdr (Fcdr (args
)));
802 if (!NILP (Vpurify_flag
))
803 tem
= Fpurecopy (tem
);
804 Fput (sym
, Qvariable_documentation
, tem
);
806 LOADHIST_ATTACH (Fcons (Qdefvar
, sym
));
810 DEFUN ("user-variable-p", Fuser_variable_p
, Suser_variable_p
, 1, 1, 0,
811 doc
: /* Returns t if VARIABLE is intended to be set and modified by users.
812 \(The alternative is a variable used internally in a Lisp program.)
813 Determined by whether the first character of the documentation
814 for the variable is `*' or if the variable is customizable (has a non-nil
815 value of `standard-value' or of `custom-autoload' on its property list). */)
817 Lisp_Object variable
;
819 Lisp_Object documentation
;
821 if (!SYMBOLP (variable
))
824 documentation
= Fget (variable
, Qvariable_documentation
);
825 if (INTEGERP (documentation
) && XINT (documentation
) < 0)
827 if (STRINGP (documentation
)
828 && ((unsigned char) SREF (documentation
, 0) == '*'))
830 /* If it is (STRING . INTEGER), a negative integer means a user variable. */
831 if (CONSP (documentation
)
832 && STRINGP (XCAR (documentation
))
833 && INTEGERP (XCDR (documentation
))
834 && XINT (XCDR (documentation
)) < 0)
836 /* Customizable? See `custom-variable-p'. */
837 if ((!NILP (Fget (variable
, intern ("standard-value"))))
838 || (!NILP (Fget (variable
, intern ("custom-autoload")))))
843 DEFUN ("let*", FletX
, SletX
, 1, UNEVALLED
, 0,
844 doc
: /* Bind variables according to VARLIST then eval BODY.
845 The value of the last form in BODY is returned.
846 Each element of VARLIST is a symbol (which is bound to nil)
847 or a list (SYMBOL VALUEFORM) (which binds SYMBOL to the value of VALUEFORM).
848 Each VALUEFORM can refer to the symbols already bound by this VARLIST.
849 usage: (let* VARLIST BODY...) */)
853 Lisp_Object varlist
, val
, elt
;
854 int count
= SPECPDL_INDEX ();
855 struct gcpro gcpro1
, gcpro2
, gcpro3
;
857 GCPRO3 (args
, elt
, varlist
);
859 varlist
= Fcar (args
);
860 while (!NILP (varlist
))
863 elt
= Fcar (varlist
);
865 specbind (elt
, Qnil
);
866 else if (! NILP (Fcdr (Fcdr (elt
))))
868 Fcons (build_string ("`let' bindings can have only one value-form"),
872 val
= Feval (Fcar (Fcdr (elt
)));
873 specbind (Fcar (elt
), val
);
875 varlist
= Fcdr (varlist
);
878 val
= Fprogn (Fcdr (args
));
879 return unbind_to (count
, val
);
882 DEFUN ("let", Flet
, Slet
, 1, UNEVALLED
, 0,
883 doc
: /* Bind variables according to VARLIST then eval BODY.
884 The value of the last form in BODY is returned.
885 Each element of VARLIST is a symbol (which is bound to nil)
886 or a list (SYMBOL VALUEFORM) (which binds SYMBOL to the value of VALUEFORM).
887 All the VALUEFORMs are evalled before any symbols are bound.
888 usage: (let VARLIST BODY...) */)
892 Lisp_Object
*temps
, tem
;
893 register Lisp_Object elt
, varlist
;
894 int count
= SPECPDL_INDEX ();
896 struct gcpro gcpro1
, gcpro2
;
898 varlist
= Fcar (args
);
900 /* Make space to hold the values to give the bound variables */
901 elt
= Flength (varlist
);
902 temps
= (Lisp_Object
*) alloca (XFASTINT (elt
) * sizeof (Lisp_Object
));
904 /* Compute the values and store them in `temps' */
906 GCPRO2 (args
, *temps
);
909 for (argnum
= 0; !NILP (varlist
); varlist
= Fcdr (varlist
))
912 elt
= Fcar (varlist
);
914 temps
[argnum
++] = Qnil
;
915 else if (! NILP (Fcdr (Fcdr (elt
))))
917 Fcons (build_string ("`let' bindings can have only one value-form"),
920 temps
[argnum
++] = Feval (Fcar (Fcdr (elt
)));
921 gcpro2
.nvars
= argnum
;
925 varlist
= Fcar (args
);
926 for (argnum
= 0; !NILP (varlist
); varlist
= Fcdr (varlist
))
928 elt
= Fcar (varlist
);
929 tem
= temps
[argnum
++];
933 specbind (Fcar (elt
), tem
);
936 elt
= Fprogn (Fcdr (args
));
937 return unbind_to (count
, elt
);
940 DEFUN ("while", Fwhile
, Swhile
, 1, UNEVALLED
, 0,
941 doc
: /* If TEST yields non-nil, eval BODY... and repeat.
942 The order of execution is thus TEST, BODY, TEST, BODY and so on
943 until TEST returns nil.
944 usage: (while TEST BODY...) */)
948 Lisp_Object test
, body
;
949 struct gcpro gcpro1
, gcpro2
;
955 while (!NILP (Feval (test
)))
965 DEFUN ("macroexpand", Fmacroexpand
, Smacroexpand
, 1, 2, 0,
966 doc
: /* Return result of expanding macros at top level of FORM.
967 If FORM is not a macro call, it is returned unchanged.
968 Otherwise, the macro is expanded and the expansion is considered
969 in place of FORM. When a non-macro-call results, it is returned.
971 The second optional arg ENVIRONMENT specifies an environment of macro
972 definitions to shadow the loaded ones for use in file byte-compilation. */)
975 Lisp_Object environment
;
977 /* With cleanups from Hallvard Furuseth. */
978 register Lisp_Object expander
, sym
, def
, tem
;
982 /* Come back here each time we expand a macro call,
983 in case it expands into another macro call. */
986 /* Set SYM, give DEF and TEM right values in case SYM is not a symbol. */
987 def
= sym
= XCAR (form
);
989 /* Trace symbols aliases to other symbols
990 until we get a symbol that is not an alias. */
991 while (SYMBOLP (def
))
995 tem
= Fassq (sym
, environment
);
998 def
= XSYMBOL (sym
)->function
;
999 if (!EQ (def
, Qunbound
))
1004 /* Right now TEM is the result from SYM in ENVIRONMENT,
1005 and if TEM is nil then DEF is SYM's function definition. */
1008 /* SYM is not mentioned in ENVIRONMENT.
1009 Look at its function definition. */
1010 if (EQ (def
, Qunbound
) || !CONSP (def
))
1011 /* Not defined or definition not suitable */
1013 if (EQ (XCAR (def
), Qautoload
))
1015 /* Autoloading function: will it be a macro when loaded? */
1016 tem
= Fnth (make_number (4), def
);
1017 if (EQ (tem
, Qt
) || EQ (tem
, Qmacro
))
1018 /* Yes, load it and try again. */
1020 struct gcpro gcpro1
;
1022 do_autoload (def
, sym
);
1029 else if (!EQ (XCAR (def
), Qmacro
))
1031 else expander
= XCDR (def
);
1035 expander
= XCDR (tem
);
1036 if (NILP (expander
))
1039 form
= apply1 (expander
, XCDR (form
));
1044 DEFUN ("catch", Fcatch
, Scatch
, 1, UNEVALLED
, 0,
1045 doc
: /* Eval BODY allowing nonlocal exits using `throw'.
1046 TAG is evalled to get the tag to use; it must not be nil.
1048 Then the BODY is executed.
1049 Within BODY, (throw TAG) with same tag exits BODY and exits this `catch'.
1050 If no throw happens, `catch' returns the value of the last BODY form.
1051 If a throw happens, it specifies the value to return from `catch'.
1052 usage: (catch TAG BODY...) */)
1056 register Lisp_Object tag
;
1057 struct gcpro gcpro1
;
1060 tag
= Feval (Fcar (args
));
1062 return internal_catch (tag
, Fprogn
, Fcdr (args
));
1065 /* Set up a catch, then call C function FUNC on argument ARG.
1066 FUNC should return a Lisp_Object.
1067 This is how catches are done from within C code. */
1070 internal_catch (tag
, func
, arg
)
1072 Lisp_Object (*func
) ();
1075 /* This structure is made part of the chain `catchlist'. */
1078 /* Fill in the components of c, and put it on the list. */
1082 c
.backlist
= backtrace_list
;
1083 c
.handlerlist
= handlerlist
;
1084 c
.lisp_eval_depth
= lisp_eval_depth
;
1085 c
.pdlcount
= SPECPDL_INDEX ();
1086 c
.poll_suppress_count
= poll_suppress_count
;
1087 c
.interrupt_input_blocked
= interrupt_input_blocked
;
1088 c
.gcpro
= gcprolist
;
1089 c
.byte_stack
= byte_stack_list
;
1093 if (! _setjmp (c
.jmp
))
1094 c
.val
= (*func
) (arg
);
1096 /* Throw works by a longjmp that comes right here. */
1101 /* Unwind the specbind, catch, and handler stacks back to CATCH, and
1102 jump to that CATCH, returning VALUE as the value of that catch.
1104 This is the guts Fthrow and Fsignal; they differ only in the way
1105 they choose the catch tag to throw to. A catch tag for a
1106 condition-case form has a TAG of Qnil.
1108 Before each catch is discarded, unbind all special bindings and
1109 execute all unwind-protect clauses made above that catch. Unwind
1110 the handler stack as we go, so that the proper handlers are in
1111 effect for each unwind-protect clause we run. At the end, restore
1112 some static info saved in CATCH, and longjmp to the location
1115 This is used for correct unwinding in Fthrow and Fsignal. */
1118 unwind_to_catch (catch, value
)
1119 struct catchtag
*catch;
1122 register int last_time
;
1124 /* Save the value in the tag. */
1127 /* Restore the polling-suppression count. */
1128 set_poll_suppress_count (catch->poll_suppress_count
);
1129 interrupt_input_blocked
= catch->interrupt_input_blocked
;
1133 last_time
= catchlist
== catch;
1135 /* Unwind the specpdl stack, and then restore the proper set of
1137 unbind_to (catchlist
->pdlcount
, Qnil
);
1138 handlerlist
= catchlist
->handlerlist
;
1139 catchlist
= catchlist
->next
;
1141 while (! last_time
);
1143 byte_stack_list
= catch->byte_stack
;
1144 gcprolist
= catch->gcpro
;
1147 gcpro_level
= gcprolist
->level
+ 1;
1151 backtrace_list
= catch->backlist
;
1152 lisp_eval_depth
= catch->lisp_eval_depth
;
1154 _longjmp (catch->jmp
, 1);
1157 DEFUN ("throw", Fthrow
, Sthrow
, 2, 2, 0,
1158 doc
: /* Throw to the catch for TAG and return VALUE from it.
1159 Both TAG and VALUE are evalled. */)
1161 register Lisp_Object tag
, value
;
1163 register struct catchtag
*c
;
1168 for (c
= catchlist
; c
; c
= c
->next
)
1170 if (EQ (c
->tag
, tag
))
1171 unwind_to_catch (c
, value
);
1173 tag
= Fsignal (Qno_catch
, Fcons (tag
, Fcons (value
, Qnil
)));
1178 DEFUN ("unwind-protect", Funwind_protect
, Sunwind_protect
, 1, UNEVALLED
, 0,
1179 doc
: /* Do BODYFORM, protecting with UNWINDFORMS.
1180 If BODYFORM completes normally, its value is returned
1181 after executing the UNWINDFORMS.
1182 If BODYFORM exits nonlocally, the UNWINDFORMS are executed anyway.
1183 usage: (unwind-protect BODYFORM UNWINDFORMS...) */)
1188 int count
= SPECPDL_INDEX ();
1190 record_unwind_protect (Fprogn
, Fcdr (args
));
1191 val
= Feval (Fcar (args
));
1192 return unbind_to (count
, val
);
1195 /* Chain of condition handlers currently in effect.
1196 The elements of this chain are contained in the stack frames
1197 of Fcondition_case and internal_condition_case.
1198 When an error is signaled (by calling Fsignal, below),
1199 this chain is searched for an element that applies. */
1201 struct handler
*handlerlist
;
1203 DEFUN ("condition-case", Fcondition_case
, Scondition_case
, 2, UNEVALLED
, 0,
1204 doc
: /* Regain control when an error is signaled.
1205 Executes BODYFORM and returns its value if no error happens.
1206 Each element of HANDLERS looks like (CONDITION-NAME BODY...)
1207 where the BODY is made of Lisp expressions.
1209 A handler is applicable to an error
1210 if CONDITION-NAME is one of the error's condition names.
1211 If an error happens, the first applicable handler is run.
1213 The car of a handler may be a list of condition names
1214 instead of a single condition name.
1216 When a handler handles an error,
1217 control returns to the condition-case and the handler BODY... is executed
1218 with VAR bound to (SIGNALED-CONDITIONS . SIGNAL-DATA).
1219 VAR may be nil; then you do not get access to the signal information.
1221 The value of the last BODY form is returned from the condition-case.
1222 See also the function `signal' for more info.
1223 usage: (condition-case VAR BODYFORM HANDLERS...) */)
1230 register Lisp_Object bodyform
, handlers
;
1231 volatile Lisp_Object var
;
1234 bodyform
= Fcar (Fcdr (args
));
1235 handlers
= Fcdr (Fcdr (args
));
1238 for (val
= handlers
; ! NILP (val
); val
= Fcdr (val
))
1244 && (SYMBOLP (XCAR (tem
))
1245 || CONSP (XCAR (tem
))))))
1246 error ("Invalid condition handler", tem
);
1251 c
.backlist
= backtrace_list
;
1252 c
.handlerlist
= handlerlist
;
1253 c
.lisp_eval_depth
= lisp_eval_depth
;
1254 c
.pdlcount
= SPECPDL_INDEX ();
1255 c
.poll_suppress_count
= poll_suppress_count
;
1256 c
.interrupt_input_blocked
= interrupt_input_blocked
;
1257 c
.gcpro
= gcprolist
;
1258 c
.byte_stack
= byte_stack_list
;
1259 if (_setjmp (c
.jmp
))
1262 specbind (h
.var
, c
.val
);
1263 val
= Fprogn (Fcdr (h
.chosen_clause
));
1265 /* Note that this just undoes the binding of h.var; whoever
1266 longjumped to us unwound the stack to c.pdlcount before
1268 unbind_to (c
.pdlcount
, Qnil
);
1275 h
.handler
= handlers
;
1276 h
.next
= handlerlist
;
1280 val
= Feval (bodyform
);
1282 handlerlist
= h
.next
;
1286 /* Call the function BFUN with no arguments, catching errors within it
1287 according to HANDLERS. If there is an error, call HFUN with
1288 one argument which is the data that describes the error:
1291 HANDLERS can be a list of conditions to catch.
1292 If HANDLERS is Qt, catch all errors.
1293 If HANDLERS is Qerror, catch all errors
1294 but allow the debugger to run if that is enabled. */
1297 internal_condition_case (bfun
, handlers
, hfun
)
1298 Lisp_Object (*bfun
) ();
1299 Lisp_Object handlers
;
1300 Lisp_Object (*hfun
) ();
1306 #if 0 /* We now handle interrupt_input_blocked properly.
1307 What we still do not handle is exiting a signal handler. */
1313 c
.backlist
= backtrace_list
;
1314 c
.handlerlist
= handlerlist
;
1315 c
.lisp_eval_depth
= lisp_eval_depth
;
1316 c
.pdlcount
= SPECPDL_INDEX ();
1317 c
.poll_suppress_count
= poll_suppress_count
;
1318 c
.interrupt_input_blocked
= interrupt_input_blocked
;
1319 c
.gcpro
= gcprolist
;
1320 c
.byte_stack
= byte_stack_list
;
1321 if (_setjmp (c
.jmp
))
1323 return (*hfun
) (c
.val
);
1327 h
.handler
= handlers
;
1329 h
.next
= handlerlist
;
1335 handlerlist
= h
.next
;
1339 /* Like internal_condition_case but call BFUN with ARG as its argument. */
1342 internal_condition_case_1 (bfun
, arg
, handlers
, hfun
)
1343 Lisp_Object (*bfun
) ();
1345 Lisp_Object handlers
;
1346 Lisp_Object (*hfun
) ();
1354 c
.backlist
= backtrace_list
;
1355 c
.handlerlist
= handlerlist
;
1356 c
.lisp_eval_depth
= lisp_eval_depth
;
1357 c
.pdlcount
= SPECPDL_INDEX ();
1358 c
.poll_suppress_count
= poll_suppress_count
;
1359 c
.interrupt_input_blocked
= interrupt_input_blocked
;
1360 c
.gcpro
= gcprolist
;
1361 c
.byte_stack
= byte_stack_list
;
1362 if (_setjmp (c
.jmp
))
1364 return (*hfun
) (c
.val
);
1368 h
.handler
= handlers
;
1370 h
.next
= handlerlist
;
1374 val
= (*bfun
) (arg
);
1376 handlerlist
= h
.next
;
1381 /* Like internal_condition_case but call BFUN with NARGS as first,
1382 and ARGS as second argument. */
1385 internal_condition_case_2 (bfun
, nargs
, args
, handlers
, hfun
)
1386 Lisp_Object (*bfun
) ();
1389 Lisp_Object handlers
;
1390 Lisp_Object (*hfun
) ();
1398 c
.backlist
= backtrace_list
;
1399 c
.handlerlist
= handlerlist
;
1400 c
.lisp_eval_depth
= lisp_eval_depth
;
1401 c
.pdlcount
= SPECPDL_INDEX ();
1402 c
.poll_suppress_count
= poll_suppress_count
;
1403 c
.interrupt_input_blocked
= interrupt_input_blocked
;
1404 c
.gcpro
= gcprolist
;
1405 c
.byte_stack
= byte_stack_list
;
1406 if (_setjmp (c
.jmp
))
1408 return (*hfun
) (c
.val
);
1412 h
.handler
= handlers
;
1414 h
.next
= handlerlist
;
1418 val
= (*bfun
) (nargs
, args
);
1420 handlerlist
= h
.next
;
1425 static Lisp_Object find_handler_clause
P_ ((Lisp_Object
, Lisp_Object
,
1426 Lisp_Object
, Lisp_Object
,
1429 DEFUN ("signal", Fsignal
, Ssignal
, 2, 2, 0,
1430 doc
: /* Signal an error. Args are ERROR-SYMBOL and associated DATA.
1431 This function does not return.
1433 An error symbol is a symbol with an `error-conditions' property
1434 that is a list of condition names.
1435 A handler for any of those names will get to handle this signal.
1436 The symbol `error' should normally be one of them.
1438 DATA should be a list. Its elements are printed as part of the error message.
1439 See Info anchor `(elisp)Definition of signal' for some details on how this
1440 error message is constructed.
1441 If the signal is handled, DATA is made available to the handler.
1442 See also the function `condition-case'. */)
1443 (error_symbol
, data
)
1444 Lisp_Object error_symbol
, data
;
1446 /* When memory is full, ERROR-SYMBOL is nil,
1447 and DATA is (REAL-ERROR-SYMBOL . REAL-DATA).
1448 That is a special case--don't do this in other situations. */
1449 register struct handler
*allhandlers
= handlerlist
;
1450 Lisp_Object conditions
;
1451 extern int gc_in_progress
;
1452 extern int waiting_for_input
;
1453 Lisp_Object debugger_value
;
1455 Lisp_Object real_error_symbol
;
1456 struct backtrace
*bp
;
1458 immediate_quit
= handling_signal
= 0;
1460 if (gc_in_progress
|| waiting_for_input
)
1463 if (NILP (error_symbol
))
1464 real_error_symbol
= Fcar (data
);
1466 real_error_symbol
= error_symbol
;
1468 #if 0 /* rms: I don't know why this was here,
1469 but it is surely wrong for an error that is handled. */
1470 #ifdef HAVE_X_WINDOWS
1471 if (display_hourglass_p
)
1472 cancel_hourglass ();
1476 /* This hook is used by edebug. */
1477 if (! NILP (Vsignal_hook_function
)
1478 && ! NILP (error_symbol
))
1479 call2 (Vsignal_hook_function
, error_symbol
, data
);
1481 conditions
= Fget (real_error_symbol
, Qerror_conditions
);
1483 /* Remember from where signal was called. Skip over the frame for
1484 `signal' itself. If a frame for `error' follows, skip that,
1485 too. Don't do this when ERROR_SYMBOL is nil, because that
1486 is a memory-full error. */
1487 Vsignaling_function
= Qnil
;
1488 if (backtrace_list
&& !NILP (error_symbol
))
1490 bp
= backtrace_list
->next
;
1491 if (bp
&& bp
->function
&& EQ (*bp
->function
, Qerror
))
1493 if (bp
&& bp
->function
)
1494 Vsignaling_function
= *bp
->function
;
1497 for (; handlerlist
; handlerlist
= handlerlist
->next
)
1499 register Lisp_Object clause
;
1501 if (lisp_eval_depth
+ 20 > max_lisp_eval_depth
)
1502 max_lisp_eval_depth
= lisp_eval_depth
+ 20;
1504 if (specpdl_size
+ 40 > max_specpdl_size
)
1505 max_specpdl_size
= specpdl_size
+ 40;
1507 clause
= find_handler_clause (handlerlist
->handler
, conditions
,
1508 error_symbol
, data
, &debugger_value
);
1510 if (EQ (clause
, Qlambda
))
1512 /* We can't return values to code which signaled an error, but we
1513 can continue code which has signaled a quit. */
1514 if (EQ (real_error_symbol
, Qquit
))
1517 error ("Cannot return from the debugger in an error");
1522 Lisp_Object unwind_data
;
1523 struct handler
*h
= handlerlist
;
1525 handlerlist
= allhandlers
;
1527 if (NILP (error_symbol
))
1530 unwind_data
= Fcons (error_symbol
, data
);
1531 h
->chosen_clause
= clause
;
1532 unwind_to_catch (h
->tag
, unwind_data
);
1536 handlerlist
= allhandlers
;
1537 /* If no handler is present now, try to run the debugger,
1538 and if that fails, throw to top level. */
1539 find_handler_clause (Qerror
, conditions
, error_symbol
, data
, &debugger_value
);
1541 Fthrow (Qtop_level
, Qt
);
1543 if (! NILP (error_symbol
))
1544 data
= Fcons (error_symbol
, data
);
1546 string
= Ferror_message_string (data
);
1547 fatal ("%s", SDATA (string
), 0);
1550 /* Return nonzero iff LIST is a non-nil atom or
1551 a list containing one of CONDITIONS. */
1554 wants_debugger (list
, conditions
)
1555 Lisp_Object list
, conditions
;
1562 while (CONSP (conditions
))
1564 Lisp_Object
this, tail
;
1565 this = XCAR (conditions
);
1566 for (tail
= list
; CONSP (tail
); tail
= XCDR (tail
))
1567 if (EQ (XCAR (tail
), this))
1569 conditions
= XCDR (conditions
);
1574 /* Return 1 if an error with condition-symbols CONDITIONS,
1575 and described by SIGNAL-DATA, should skip the debugger
1576 according to debugger-ignored-errors. */
1579 skip_debugger (conditions
, data
)
1580 Lisp_Object conditions
, data
;
1583 int first_string
= 1;
1584 Lisp_Object error_message
;
1586 error_message
= Qnil
;
1587 for (tail
= Vdebug_ignored_errors
; CONSP (tail
); tail
= XCDR (tail
))
1589 if (STRINGP (XCAR (tail
)))
1593 error_message
= Ferror_message_string (data
);
1597 if (fast_string_match (XCAR (tail
), error_message
) >= 0)
1602 Lisp_Object contail
;
1604 for (contail
= conditions
; CONSP (contail
); contail
= XCDR (contail
))
1605 if (EQ (XCAR (tail
), XCAR (contail
)))
1613 /* Value of Qlambda means we have called debugger and user has continued.
1614 There are two ways to pass SIG and DATA:
1615 = SIG is the error symbol, and DATA is the rest of the data.
1616 = SIG is nil, and DATA is (SYMBOL . REST-OF-DATA).
1617 This is for memory-full errors only.
1619 Store value returned from debugger into *DEBUGGER_VALUE_PTR. */
1622 find_handler_clause (handlers
, conditions
, sig
, data
, debugger_value_ptr
)
1623 Lisp_Object handlers
, conditions
, sig
, data
;
1624 Lisp_Object
*debugger_value_ptr
;
1626 register Lisp_Object h
;
1627 register Lisp_Object tem
;
1629 if (EQ (handlers
, Qt
)) /* t is used by handlers for all conditions, set up by C code. */
1631 /* error is used similarly, but means print an error message
1632 and run the debugger if that is enabled. */
1633 if (EQ (handlers
, Qerror
)
1634 || !NILP (Vdebug_on_signal
)) /* This says call debugger even if
1635 there is a handler. */
1637 int count
= SPECPDL_INDEX ();
1638 int debugger_called
= 0;
1639 Lisp_Object sig_symbol
, combined_data
;
1640 /* This is set to 1 if we are handling a memory-full error,
1641 because these must not run the debugger.
1642 (There is no room in memory to do that!) */
1643 int no_debugger
= 0;
1647 combined_data
= data
;
1648 sig_symbol
= Fcar (data
);
1653 combined_data
= Fcons (sig
, data
);
1657 if (wants_debugger (Vstack_trace_on_error
, conditions
))
1660 internal_with_output_to_temp_buffer ("*Backtrace*",
1661 (Lisp_Object (*) (Lisp_Object
)) Fbacktrace
,
1664 internal_with_output_to_temp_buffer ("*Backtrace*",
1669 && (EQ (sig_symbol
, Qquit
)
1671 : wants_debugger (Vdebug_on_error
, conditions
))
1672 && ! skip_debugger (conditions
, combined_data
)
1673 && when_entered_debugger
< num_nonmacro_input_events
)
1675 specbind (Qdebug_on_error
, Qnil
);
1677 = call_debugger (Fcons (Qerror
,
1678 Fcons (combined_data
, Qnil
)));
1679 debugger_called
= 1;
1681 /* If there is no handler, return saying whether we ran the debugger. */
1682 if (EQ (handlers
, Qerror
))
1684 if (debugger_called
)
1685 return unbind_to (count
, Qlambda
);
1689 for (h
= handlers
; CONSP (h
); h
= Fcdr (h
))
1691 Lisp_Object handler
, condit
;
1694 if (!CONSP (handler
))
1696 condit
= Fcar (handler
);
1697 /* Handle a single condition name in handler HANDLER. */
1698 if (SYMBOLP (condit
))
1700 tem
= Fmemq (Fcar (handler
), conditions
);
1704 /* Handle a list of condition names in handler HANDLER. */
1705 else if (CONSP (condit
))
1707 while (CONSP (condit
))
1709 tem
= Fmemq (Fcar (condit
), conditions
);
1712 condit
= XCDR (condit
);
1719 /* dump an error message; called like printf */
1723 error (m
, a1
, a2
, a3
)
1743 int used
= doprnt (buffer
, size
, m
, m
+ mlen
, 3, args
);
1748 buffer
= (char *) xrealloc (buffer
, size
);
1751 buffer
= (char *) xmalloc (size
);
1756 string
= build_string (buffer
);
1760 Fsignal (Qerror
, Fcons (string
, Qnil
));
1764 DEFUN ("commandp", Fcommandp
, Scommandp
, 1, 2, 0,
1765 doc
: /* Non-nil if FUNCTION makes provisions for interactive calling.
1766 This means it contains a description for how to read arguments to give it.
1767 The value is nil for an invalid function or a symbol with no function
1770 Interactively callable functions include strings and vectors (treated
1771 as keyboard macros), lambda-expressions that contain a top-level call
1772 to `interactive', autoload definitions made by `autoload' with non-nil
1773 fourth argument, and some of the built-in functions of Lisp.
1775 Also, a symbol satisfies `commandp' if its function definition does so.
1777 If the optional argument FOR-CALL-INTERACTIVELY is non-nil,
1778 then strings and vectors are not accepted. */)
1779 (function
, for_call_interactively
)
1780 Lisp_Object function
, for_call_interactively
;
1782 register Lisp_Object fun
;
1783 register Lisp_Object funcar
;
1787 fun
= indirect_function (fun
);
1788 if (EQ (fun
, Qunbound
))
1791 /* Emacs primitives are interactive if their DEFUN specifies an
1792 interactive spec. */
1795 if (XSUBR (fun
)->prompt
)
1801 /* Bytecode objects are interactive if they are long enough to
1802 have an element whose index is COMPILED_INTERACTIVE, which is
1803 where the interactive spec is stored. */
1804 else if (COMPILEDP (fun
))
1805 return ((ASIZE (fun
) & PSEUDOVECTOR_SIZE_MASK
) > COMPILED_INTERACTIVE
1808 /* Strings and vectors are keyboard macros. */
1809 if (NILP (for_call_interactively
) && (STRINGP (fun
) || VECTORP (fun
)))
1812 /* Lists may represent commands. */
1815 funcar
= Fcar (fun
);
1816 if (!SYMBOLP (funcar
))
1817 return Fsignal (Qinvalid_function
, Fcons (fun
, Qnil
));
1818 if (EQ (funcar
, Qlambda
))
1819 return Fassq (Qinteractive
, Fcdr (Fcdr (fun
)));
1820 if (EQ (funcar
, Qautoload
))
1821 return Fcar (Fcdr (Fcdr (Fcdr (fun
))));
1827 DEFUN ("autoload", Fautoload
, Sautoload
, 2, 5, 0,
1828 doc
: /* Define FUNCTION to autoload from FILE.
1829 FUNCTION is a symbol; FILE is a file name string to pass to `load'.
1830 Third arg DOCSTRING is documentation for the function.
1831 Fourth arg INTERACTIVE if non-nil says function can be called interactively.
1832 Fifth arg TYPE indicates the type of the object:
1833 nil or omitted says FUNCTION is a function,
1834 `keymap' says FUNCTION is really a keymap, and
1835 `macro' or t says FUNCTION is really a macro.
1836 Third through fifth args give info about the real definition.
1837 They default to nil.
1838 If FUNCTION is already defined other than as an autoload,
1839 this does nothing and returns nil. */)
1840 (function
, file
, docstring
, interactive
, type
)
1841 Lisp_Object function
, file
, docstring
, interactive
, type
;
1844 Lisp_Object args
[4];
1847 CHECK_SYMBOL (function
);
1848 CHECK_STRING (file
);
1850 /* If function is defined and not as an autoload, don't override */
1851 if (!EQ (XSYMBOL (function
)->function
, Qunbound
)
1852 && !(CONSP (XSYMBOL (function
)->function
)
1853 && EQ (XCAR (XSYMBOL (function
)->function
), Qautoload
)))
1856 if (NILP (Vpurify_flag
))
1857 /* Only add entries after dumping, because the ones before are
1858 not useful and else we get loads of them from the loaddefs.el. */
1859 LOADHIST_ATTACH (Fcons (Qautoload
, function
));
1863 args
[1] = docstring
;
1864 args
[2] = interactive
;
1867 return Ffset (function
, Fcons (Qautoload
, Flist (4, &args
[0])));
1868 #else /* NO_ARG_ARRAY */
1869 return Ffset (function
, Fcons (Qautoload
, Flist (4, &file
)));
1870 #endif /* not NO_ARG_ARRAY */
1874 un_autoload (oldqueue
)
1875 Lisp_Object oldqueue
;
1877 register Lisp_Object queue
, first
, second
;
1879 /* Queue to unwind is current value of Vautoload_queue.
1880 oldqueue is the shadowed value to leave in Vautoload_queue. */
1881 queue
= Vautoload_queue
;
1882 Vautoload_queue
= oldqueue
;
1883 while (CONSP (queue
))
1885 first
= XCAR (queue
);
1886 second
= Fcdr (first
);
1887 first
= Fcar (first
);
1888 if (EQ (second
, Qnil
))
1891 Ffset (first
, second
);
1892 queue
= XCDR (queue
);
1897 /* Load an autoloaded function.
1898 FUNNAME is the symbol which is the function's name.
1899 FUNDEF is the autoload definition (a list). */
1902 do_autoload (fundef
, funname
)
1903 Lisp_Object fundef
, funname
;
1905 int count
= SPECPDL_INDEX ();
1906 Lisp_Object fun
, queue
, first
, second
;
1907 struct gcpro gcpro1
, gcpro2
, gcpro3
;
1909 /* This is to make sure that loadup.el gives a clear picture
1910 of what files are preloaded and when. */
1911 if (! NILP (Vpurify_flag
))
1912 error ("Attempt to autoload %s while preparing to dump",
1913 SDATA (SYMBOL_NAME (funname
)));
1916 CHECK_SYMBOL (funname
);
1917 GCPRO3 (fun
, funname
, fundef
);
1919 /* Preserve the match data. */
1920 record_unwind_protect (Fset_match_data
, Fmatch_data (Qnil
, Qnil
));
1922 /* Value saved here is to be restored into Vautoload_queue. */
1923 record_unwind_protect (un_autoload
, Vautoload_queue
);
1924 Vautoload_queue
= Qt
;
1925 Fload (Fcar (Fcdr (fundef
)), Qnil
, noninteractive
? Qt
: Qnil
, Qnil
, Qt
);
1927 /* Save the old autoloads, in case we ever do an unload. */
1928 queue
= Vautoload_queue
;
1929 while (CONSP (queue
))
1931 first
= XCAR (queue
);
1932 second
= Fcdr (first
);
1933 first
= Fcar (first
);
1935 /* Note: This test is subtle. The cdr of an autoload-queue entry
1936 may be an atom if the autoload entry was generated by a defalias
1939 Fput (first
, Qautoload
, (XCDR (second
)));
1941 queue
= XCDR (queue
);
1944 /* Once loading finishes, don't undo it. */
1945 Vautoload_queue
= Qt
;
1946 unbind_to (count
, Qnil
);
1948 fun
= Findirect_function (fun
);
1950 if (!NILP (Fequal (fun
, fundef
)))
1951 error ("Autoloading failed to define function %s",
1952 SDATA (SYMBOL_NAME (funname
)));
1957 DEFUN ("eval", Feval
, Seval
, 1, 1, 0,
1958 doc
: /* Evaluate FORM and return its value. */)
1962 Lisp_Object fun
, val
, original_fun
, original_args
;
1964 struct backtrace backtrace
;
1965 struct gcpro gcpro1
, gcpro2
, gcpro3
;
1967 if (handling_signal
)
1971 return Fsymbol_value (form
);
1976 if (consing_since_gc
> gc_cons_threshold
)
1979 Fgarbage_collect ();
1983 if (++lisp_eval_depth
> max_lisp_eval_depth
)
1985 if (max_lisp_eval_depth
< 100)
1986 max_lisp_eval_depth
= 100;
1987 if (lisp_eval_depth
> max_lisp_eval_depth
)
1988 error ("Lisp nesting exceeds max-lisp-eval-depth");
1991 original_fun
= Fcar (form
);
1992 original_args
= Fcdr (form
);
1994 backtrace
.next
= backtrace_list
;
1995 backtrace_list
= &backtrace
;
1996 backtrace
.function
= &original_fun
; /* This also protects them from gc */
1997 backtrace
.args
= &original_args
;
1998 backtrace
.nargs
= UNEVALLED
;
1999 backtrace
.evalargs
= 1;
2000 backtrace
.debug_on_exit
= 0;
2002 if (debug_on_next_call
)
2003 do_debug_on_call (Qt
);
2005 /* At this point, only original_fun and original_args
2006 have values that will be used below */
2008 fun
= Findirect_function (original_fun
);
2012 Lisp_Object numargs
;
2013 Lisp_Object argvals
[8];
2014 Lisp_Object args_left
;
2015 register int i
, maxargs
;
2017 args_left
= original_args
;
2018 numargs
= Flength (args_left
);
2020 if (XINT (numargs
) < XSUBR (fun
)->min_args
||
2021 (XSUBR (fun
)->max_args
>= 0 && XSUBR (fun
)->max_args
< XINT (numargs
)))
2022 return Fsignal (Qwrong_number_of_arguments
, Fcons (fun
, Fcons (numargs
, Qnil
)));
2024 if (XSUBR (fun
)->max_args
== UNEVALLED
)
2026 backtrace
.evalargs
= 0;
2027 val
= (*XSUBR (fun
)->function
) (args_left
);
2031 if (XSUBR (fun
)->max_args
== MANY
)
2033 /* Pass a vector of evaluated arguments */
2035 register int argnum
= 0;
2037 vals
= (Lisp_Object
*) alloca (XINT (numargs
) * sizeof (Lisp_Object
));
2039 GCPRO3 (args_left
, fun
, fun
);
2043 while (!NILP (args_left
))
2045 vals
[argnum
++] = Feval (Fcar (args_left
));
2046 args_left
= Fcdr (args_left
);
2047 gcpro3
.nvars
= argnum
;
2050 backtrace
.args
= vals
;
2051 backtrace
.nargs
= XINT (numargs
);
2053 val
= (*XSUBR (fun
)->function
) (XINT (numargs
), vals
);
2058 GCPRO3 (args_left
, fun
, fun
);
2059 gcpro3
.var
= argvals
;
2062 maxargs
= XSUBR (fun
)->max_args
;
2063 for (i
= 0; i
< maxargs
; args_left
= Fcdr (args_left
))
2065 argvals
[i
] = Feval (Fcar (args_left
));
2071 backtrace
.args
= argvals
;
2072 backtrace
.nargs
= XINT (numargs
);
2077 val
= (*XSUBR (fun
)->function
) ();
2080 val
= (*XSUBR (fun
)->function
) (argvals
[0]);
2083 val
= (*XSUBR (fun
)->function
) (argvals
[0], argvals
[1]);
2086 val
= (*XSUBR (fun
)->function
) (argvals
[0], argvals
[1],
2090 val
= (*XSUBR (fun
)->function
) (argvals
[0], argvals
[1],
2091 argvals
[2], argvals
[3]);
2094 val
= (*XSUBR (fun
)->function
) (argvals
[0], argvals
[1], argvals
[2],
2095 argvals
[3], argvals
[4]);
2098 val
= (*XSUBR (fun
)->function
) (argvals
[0], argvals
[1], argvals
[2],
2099 argvals
[3], argvals
[4], argvals
[5]);
2102 val
= (*XSUBR (fun
)->function
) (argvals
[0], argvals
[1], argvals
[2],
2103 argvals
[3], argvals
[4], argvals
[5],
2108 val
= (*XSUBR (fun
)->function
) (argvals
[0], argvals
[1], argvals
[2],
2109 argvals
[3], argvals
[4], argvals
[5],
2110 argvals
[6], argvals
[7]);
2114 /* Someone has created a subr that takes more arguments than
2115 is supported by this code. We need to either rewrite the
2116 subr to use a different argument protocol, or add more
2117 cases to this switch. */
2121 if (COMPILEDP (fun
))
2122 val
= apply_lambda (fun
, original_args
, 1);
2126 return Fsignal (Qinvalid_function
, Fcons (fun
, Qnil
));
2127 funcar
= Fcar (fun
);
2128 if (!SYMBOLP (funcar
))
2129 return Fsignal (Qinvalid_function
, Fcons (fun
, Qnil
));
2130 if (EQ (funcar
, Qautoload
))
2132 do_autoload (fun
, original_fun
);
2135 if (EQ (funcar
, Qmacro
))
2136 val
= Feval (apply1 (Fcdr (fun
), original_args
));
2137 else if (EQ (funcar
, Qlambda
))
2138 val
= apply_lambda (fun
, original_args
, 1);
2140 return Fsignal (Qinvalid_function
, Fcons (fun
, Qnil
));
2144 if (backtrace
.debug_on_exit
)
2145 val
= call_debugger (Fcons (Qexit
, Fcons (val
, Qnil
)));
2146 backtrace_list
= backtrace
.next
;
2149 mac_check_for_quit_char();
2154 DEFUN ("apply", Fapply
, Sapply
, 2, MANY
, 0,
2155 doc
: /* Call FUNCTION with our remaining args, using our last arg as list of args.
2156 Then return the value FUNCTION returns.
2157 Thus, (apply '+ 1 2 '(3 4)) returns 10.
2158 usage: (apply FUNCTION &rest ARGUMENTS) */)
2163 register int i
, numargs
;
2164 register Lisp_Object spread_arg
;
2165 register Lisp_Object
*funcall_args
;
2167 struct gcpro gcpro1
;
2171 spread_arg
= args
[nargs
- 1];
2172 CHECK_LIST (spread_arg
);
2174 numargs
= XINT (Flength (spread_arg
));
2177 return Ffuncall (nargs
- 1, args
);
2178 else if (numargs
== 1)
2180 args
[nargs
- 1] = XCAR (spread_arg
);
2181 return Ffuncall (nargs
, args
);
2184 numargs
+= nargs
- 2;
2186 fun
= indirect_function (fun
);
2187 if (EQ (fun
, Qunbound
))
2189 /* Let funcall get the error */
2196 if (numargs
< XSUBR (fun
)->min_args
2197 || (XSUBR (fun
)->max_args
>= 0 && XSUBR (fun
)->max_args
< numargs
))
2198 goto funcall
; /* Let funcall get the error */
2199 else if (XSUBR (fun
)->max_args
> numargs
)
2201 /* Avoid making funcall cons up a yet another new vector of arguments
2202 by explicitly supplying nil's for optional values */
2203 funcall_args
= (Lisp_Object
*) alloca ((1 + XSUBR (fun
)->max_args
)
2204 * sizeof (Lisp_Object
));
2205 for (i
= numargs
; i
< XSUBR (fun
)->max_args
;)
2206 funcall_args
[++i
] = Qnil
;
2207 GCPRO1 (*funcall_args
);
2208 gcpro1
.nvars
= 1 + XSUBR (fun
)->max_args
;
2212 /* We add 1 to numargs because funcall_args includes the
2213 function itself as well as its arguments. */
2216 funcall_args
= (Lisp_Object
*) alloca ((1 + numargs
)
2217 * sizeof (Lisp_Object
));
2218 GCPRO1 (*funcall_args
);
2219 gcpro1
.nvars
= 1 + numargs
;
2222 bcopy (args
, funcall_args
, nargs
* sizeof (Lisp_Object
));
2223 /* Spread the last arg we got. Its first element goes in
2224 the slot that it used to occupy, hence this value of I. */
2226 while (!NILP (spread_arg
))
2228 funcall_args
[i
++] = XCAR (spread_arg
);
2229 spread_arg
= XCDR (spread_arg
);
2232 /* By convention, the caller needs to gcpro Ffuncall's args. */
2233 RETURN_UNGCPRO (Ffuncall (gcpro1
.nvars
, funcall_args
));
2236 /* Run hook variables in various ways. */
2238 enum run_hooks_condition
{to_completion
, until_success
, until_failure
};
2239 static Lisp_Object run_hook_with_args
P_ ((int, Lisp_Object
*,
2240 enum run_hooks_condition
));
2242 DEFUN ("run-hooks", Frun_hooks
, Srun_hooks
, 0, MANY
, 0,
2243 doc
: /* Run each hook in HOOKS. Major mode functions use this.
2244 Each argument should be a symbol, a hook variable.
2245 These symbols are processed in the order specified.
2246 If a hook symbol has a non-nil value, that value may be a function
2247 or a list of functions to be called to run the hook.
2248 If the value is a function, it is called with no arguments.
2249 If it is a list, the elements are called, in order, with no arguments.
2251 Do not use `make-local-variable' to make a hook variable buffer-local.
2252 Instead, use `add-hook' and specify t for the LOCAL argument.
2253 usage: (run-hooks &rest HOOKS) */)
2258 Lisp_Object hook
[1];
2261 for (i
= 0; i
< nargs
; i
++)
2264 run_hook_with_args (1, hook
, to_completion
);
2270 DEFUN ("run-hook-with-args", Frun_hook_with_args
,
2271 Srun_hook_with_args
, 1, MANY
, 0,
2272 doc
: /* Run HOOK with the specified arguments ARGS.
2273 HOOK should be a symbol, a hook variable. If HOOK has a non-nil
2274 value, that value may be a function or a list of functions to be
2275 called to run the hook. If the value is a function, it is called with
2276 the given arguments and its return value is returned. If it is a list
2277 of functions, those functions are called, in order,
2278 with the given arguments ARGS.
2279 It is best not to depend on the value return by `run-hook-with-args',
2282 Do not use `make-local-variable' to make a hook variable buffer-local.
2283 Instead, use `add-hook' and specify t for the LOCAL argument.
2284 usage: (run-hook-with-args HOOK &rest ARGS) */)
2289 return run_hook_with_args (nargs
, args
, to_completion
);
2292 DEFUN ("run-hook-with-args-until-success", Frun_hook_with_args_until_success
,
2293 Srun_hook_with_args_until_success
, 1, MANY
, 0,
2294 doc
: /* Run HOOK with the specified arguments ARGS.
2295 HOOK should be a symbol, a hook variable. Its value should
2296 be a list of functions. We call those functions, one by one,
2297 passing arguments ARGS to each of them, until one of them
2298 returns a non-nil value. Then we return that value.
2299 If all the functions return nil, we return nil.
2301 Do not use `make-local-variable' to make a hook variable buffer-local.
2302 Instead, use `add-hook' and specify t for the LOCAL argument.
2303 usage: (run-hook-with-args-until-success HOOK &rest ARGS) */)
2308 return run_hook_with_args (nargs
, args
, until_success
);
2311 DEFUN ("run-hook-with-args-until-failure", Frun_hook_with_args_until_failure
,
2312 Srun_hook_with_args_until_failure
, 1, MANY
, 0,
2313 doc
: /* Run HOOK with the specified arguments ARGS.
2314 HOOK should be a symbol, a hook variable. Its value should
2315 be a list of functions. We call those functions, one by one,
2316 passing arguments ARGS to each of them, until one of them
2317 returns nil. Then we return nil.
2318 If all the functions return non-nil, we return non-nil.
2320 Do not use `make-local-variable' to make a hook variable buffer-local.
2321 Instead, use `add-hook' and specify t for the LOCAL argument.
2322 usage: (run-hook-with-args-until-failure HOOK &rest ARGS) */)
2327 return run_hook_with_args (nargs
, args
, until_failure
);
2330 /* ARGS[0] should be a hook symbol.
2331 Call each of the functions in the hook value, passing each of them
2332 as arguments all the rest of ARGS (all NARGS - 1 elements).
2333 COND specifies a condition to test after each call
2334 to decide whether to stop.
2335 The caller (or its caller, etc) must gcpro all of ARGS,
2336 except that it isn't necessary to gcpro ARGS[0]. */
2339 run_hook_with_args (nargs
, args
, cond
)
2342 enum run_hooks_condition cond
;
2344 Lisp_Object sym
, val
, ret
;
2345 Lisp_Object globals
;
2346 struct gcpro gcpro1
, gcpro2
, gcpro3
;
2348 /* If we are dying or still initializing,
2349 don't do anything--it would probably crash if we tried. */
2350 if (NILP (Vrun_hooks
))
2354 val
= find_symbol_value (sym
);
2355 ret
= (cond
== until_failure
? Qt
: Qnil
);
2357 if (EQ (val
, Qunbound
) || NILP (val
))
2359 else if (!CONSP (val
) || EQ (XCAR (val
), Qlambda
))
2362 return Ffuncall (nargs
, args
);
2367 GCPRO3 (sym
, val
, globals
);
2370 CONSP (val
) && ((cond
== to_completion
)
2371 || (cond
== until_success
? NILP (ret
)
2375 if (EQ (XCAR (val
), Qt
))
2377 /* t indicates this hook has a local binding;
2378 it means to run the global binding too. */
2380 for (globals
= Fdefault_value (sym
);
2381 CONSP (globals
) && ((cond
== to_completion
)
2382 || (cond
== until_success
? NILP (ret
)
2384 globals
= XCDR (globals
))
2386 args
[0] = XCAR (globals
);
2387 /* In a global value, t should not occur. If it does, we
2388 must ignore it to avoid an endless loop. */
2389 if (!EQ (args
[0], Qt
))
2390 ret
= Ffuncall (nargs
, args
);
2395 args
[0] = XCAR (val
);
2396 ret
= Ffuncall (nargs
, args
);
2405 /* Run a hook symbol ARGS[0], but use FUNLIST instead of the actual
2406 present value of that symbol.
2407 Call each element of FUNLIST,
2408 passing each of them the rest of ARGS.
2409 The caller (or its caller, etc) must gcpro all of ARGS,
2410 except that it isn't necessary to gcpro ARGS[0]. */
2413 run_hook_list_with_args (funlist
, nargs
, args
)
2414 Lisp_Object funlist
;
2420 Lisp_Object globals
;
2421 struct gcpro gcpro1
, gcpro2
, gcpro3
;
2425 GCPRO3 (sym
, val
, globals
);
2427 for (val
= funlist
; CONSP (val
); val
= XCDR (val
))
2429 if (EQ (XCAR (val
), Qt
))
2431 /* t indicates this hook has a local binding;
2432 it means to run the global binding too. */
2434 for (globals
= Fdefault_value (sym
);
2436 globals
= XCDR (globals
))
2438 args
[0] = XCAR (globals
);
2439 /* In a global value, t should not occur. If it does, we
2440 must ignore it to avoid an endless loop. */
2441 if (!EQ (args
[0], Qt
))
2442 Ffuncall (nargs
, args
);
2447 args
[0] = XCAR (val
);
2448 Ffuncall (nargs
, args
);
2455 /* Run the hook HOOK, giving each function the two args ARG1 and ARG2. */
2458 run_hook_with_args_2 (hook
, arg1
, arg2
)
2459 Lisp_Object hook
, arg1
, arg2
;
2461 Lisp_Object temp
[3];
2466 Frun_hook_with_args (3, temp
);
2469 /* Apply fn to arg */
2472 Lisp_Object fn
, arg
;
2474 struct gcpro gcpro1
;
2478 RETURN_UNGCPRO (Ffuncall (1, &fn
));
2482 Lisp_Object args
[2];
2486 RETURN_UNGCPRO (Fapply (2, args
));
2488 #else /* not NO_ARG_ARRAY */
2489 RETURN_UNGCPRO (Fapply (2, &fn
));
2490 #endif /* not NO_ARG_ARRAY */
2493 /* Call function fn on no arguments */
2498 struct gcpro gcpro1
;
2501 RETURN_UNGCPRO (Ffuncall (1, &fn
));
2504 /* Call function fn with 1 argument arg1 */
2508 Lisp_Object fn
, arg1
;
2510 struct gcpro gcpro1
;
2512 Lisp_Object args
[2];
2518 RETURN_UNGCPRO (Ffuncall (2, args
));
2519 #else /* not NO_ARG_ARRAY */
2522 RETURN_UNGCPRO (Ffuncall (2, &fn
));
2523 #endif /* not NO_ARG_ARRAY */
2526 /* Call function fn with 2 arguments arg1, arg2 */
2529 call2 (fn
, arg1
, arg2
)
2530 Lisp_Object fn
, arg1
, arg2
;
2532 struct gcpro gcpro1
;
2534 Lisp_Object args
[3];
2540 RETURN_UNGCPRO (Ffuncall (3, args
));
2541 #else /* not NO_ARG_ARRAY */
2544 RETURN_UNGCPRO (Ffuncall (3, &fn
));
2545 #endif /* not NO_ARG_ARRAY */
2548 /* Call function fn with 3 arguments arg1, arg2, arg3 */
2551 call3 (fn
, arg1
, arg2
, arg3
)
2552 Lisp_Object fn
, arg1
, arg2
, arg3
;
2554 struct gcpro gcpro1
;
2556 Lisp_Object args
[4];
2563 RETURN_UNGCPRO (Ffuncall (4, args
));
2564 #else /* not NO_ARG_ARRAY */
2567 RETURN_UNGCPRO (Ffuncall (4, &fn
));
2568 #endif /* not NO_ARG_ARRAY */
2571 /* Call function fn with 4 arguments arg1, arg2, arg3, arg4 */
2574 call4 (fn
, arg1
, arg2
, arg3
, arg4
)
2575 Lisp_Object fn
, arg1
, arg2
, arg3
, arg4
;
2577 struct gcpro gcpro1
;
2579 Lisp_Object args
[5];
2587 RETURN_UNGCPRO (Ffuncall (5, args
));
2588 #else /* not NO_ARG_ARRAY */
2591 RETURN_UNGCPRO (Ffuncall (5, &fn
));
2592 #endif /* not NO_ARG_ARRAY */
2595 /* Call function fn with 5 arguments arg1, arg2, arg3, arg4, arg5 */
2598 call5 (fn
, arg1
, arg2
, arg3
, arg4
, arg5
)
2599 Lisp_Object fn
, arg1
, arg2
, arg3
, arg4
, arg5
;
2601 struct gcpro gcpro1
;
2603 Lisp_Object args
[6];
2612 RETURN_UNGCPRO (Ffuncall (6, args
));
2613 #else /* not NO_ARG_ARRAY */
2616 RETURN_UNGCPRO (Ffuncall (6, &fn
));
2617 #endif /* not NO_ARG_ARRAY */
2620 /* Call function fn with 6 arguments arg1, arg2, arg3, arg4, arg5, arg6 */
2623 call6 (fn
, arg1
, arg2
, arg3
, arg4
, arg5
, arg6
)
2624 Lisp_Object fn
, arg1
, arg2
, arg3
, arg4
, arg5
, arg6
;
2626 struct gcpro gcpro1
;
2628 Lisp_Object args
[7];
2638 RETURN_UNGCPRO (Ffuncall (7, args
));
2639 #else /* not NO_ARG_ARRAY */
2642 RETURN_UNGCPRO (Ffuncall (7, &fn
));
2643 #endif /* not NO_ARG_ARRAY */
2646 /* The caller should GCPRO all the elements of ARGS. */
2648 DEFUN ("funcall", Ffuncall
, Sfuncall
, 1, MANY
, 0,
2649 doc
: /* Call first argument as a function, passing remaining arguments to it.
2650 Return the value that function returns.
2651 Thus, (funcall 'cons 'x 'y) returns (x . y).
2652 usage: (funcall FUNCTION &rest ARGUMENTS) */)
2659 int numargs
= nargs
- 1;
2660 Lisp_Object lisp_numargs
;
2662 struct backtrace backtrace
;
2663 register Lisp_Object
*internal_args
;
2667 if (consing_since_gc
> gc_cons_threshold
)
2668 Fgarbage_collect ();
2670 if (++lisp_eval_depth
> max_lisp_eval_depth
)
2672 if (max_lisp_eval_depth
< 100)
2673 max_lisp_eval_depth
= 100;
2674 if (lisp_eval_depth
> max_lisp_eval_depth
)
2675 error ("Lisp nesting exceeds max-lisp-eval-depth");
2678 backtrace
.next
= backtrace_list
;
2679 backtrace_list
= &backtrace
;
2680 backtrace
.function
= &args
[0];
2681 backtrace
.args
= &args
[1];
2682 backtrace
.nargs
= nargs
- 1;
2683 backtrace
.evalargs
= 0;
2684 backtrace
.debug_on_exit
= 0;
2686 if (debug_on_next_call
)
2687 do_debug_on_call (Qlambda
);
2693 fun
= Findirect_function (fun
);
2697 if (numargs
< XSUBR (fun
)->min_args
2698 || (XSUBR (fun
)->max_args
>= 0 && XSUBR (fun
)->max_args
< numargs
))
2700 XSETFASTINT (lisp_numargs
, numargs
);
2701 return Fsignal (Qwrong_number_of_arguments
, Fcons (fun
, Fcons (lisp_numargs
, Qnil
)));
2704 if (XSUBR (fun
)->max_args
== UNEVALLED
)
2705 return Fsignal (Qinvalid_function
, Fcons (fun
, Qnil
));
2707 if (XSUBR (fun
)->max_args
== MANY
)
2709 val
= (*XSUBR (fun
)->function
) (numargs
, args
+ 1);
2713 if (XSUBR (fun
)->max_args
> numargs
)
2715 internal_args
= (Lisp_Object
*) alloca (XSUBR (fun
)->max_args
* sizeof (Lisp_Object
));
2716 bcopy (args
+ 1, internal_args
, numargs
* sizeof (Lisp_Object
));
2717 for (i
= numargs
; i
< XSUBR (fun
)->max_args
; i
++)
2718 internal_args
[i
] = Qnil
;
2721 internal_args
= args
+ 1;
2722 switch (XSUBR (fun
)->max_args
)
2725 val
= (*XSUBR (fun
)->function
) ();
2728 val
= (*XSUBR (fun
)->function
) (internal_args
[0]);
2731 val
= (*XSUBR (fun
)->function
) (internal_args
[0],
2735 val
= (*XSUBR (fun
)->function
) (internal_args
[0], internal_args
[1],
2739 val
= (*XSUBR (fun
)->function
) (internal_args
[0], internal_args
[1],
2744 val
= (*XSUBR (fun
)->function
) (internal_args
[0], internal_args
[1],
2745 internal_args
[2], internal_args
[3],
2749 val
= (*XSUBR (fun
)->function
) (internal_args
[0], internal_args
[1],
2750 internal_args
[2], internal_args
[3],
2751 internal_args
[4], internal_args
[5]);
2754 val
= (*XSUBR (fun
)->function
) (internal_args
[0], internal_args
[1],
2755 internal_args
[2], internal_args
[3],
2756 internal_args
[4], internal_args
[5],
2761 val
= (*XSUBR (fun
)->function
) (internal_args
[0], internal_args
[1],
2762 internal_args
[2], internal_args
[3],
2763 internal_args
[4], internal_args
[5],
2764 internal_args
[6], internal_args
[7]);
2769 /* If a subr takes more than 8 arguments without using MANY
2770 or UNEVALLED, we need to extend this function to support it.
2771 Until this is done, there is no way to call the function. */
2775 if (COMPILEDP (fun
))
2776 val
= funcall_lambda (fun
, numargs
, args
+ 1);
2780 return Fsignal (Qinvalid_function
, Fcons (fun
, Qnil
));
2781 funcar
= Fcar (fun
);
2782 if (!SYMBOLP (funcar
))
2783 return Fsignal (Qinvalid_function
, Fcons (fun
, Qnil
));
2784 if (EQ (funcar
, Qlambda
))
2785 val
= funcall_lambda (fun
, numargs
, args
+ 1);
2786 else if (EQ (funcar
, Qautoload
))
2788 do_autoload (fun
, args
[0]);
2792 return Fsignal (Qinvalid_function
, Fcons (fun
, Qnil
));
2796 if (backtrace
.debug_on_exit
)
2797 val
= call_debugger (Fcons (Qexit
, Fcons (val
, Qnil
)));
2798 backtrace_list
= backtrace
.next
;
2803 apply_lambda (fun
, args
, eval_flag
)
2804 Lisp_Object fun
, args
;
2807 Lisp_Object args_left
;
2808 Lisp_Object numargs
;
2809 register Lisp_Object
*arg_vector
;
2810 struct gcpro gcpro1
, gcpro2
, gcpro3
;
2812 register Lisp_Object tem
;
2814 numargs
= Flength (args
);
2815 arg_vector
= (Lisp_Object
*) alloca (XINT (numargs
) * sizeof (Lisp_Object
));
2818 GCPRO3 (*arg_vector
, args_left
, fun
);
2821 for (i
= 0; i
< XINT (numargs
);)
2823 tem
= Fcar (args_left
), args_left
= Fcdr (args_left
);
2824 if (eval_flag
) tem
= Feval (tem
);
2825 arg_vector
[i
++] = tem
;
2833 backtrace_list
->args
= arg_vector
;
2834 backtrace_list
->nargs
= i
;
2836 backtrace_list
->evalargs
= 0;
2837 tem
= funcall_lambda (fun
, XINT (numargs
), arg_vector
);
2839 /* Do the debug-on-exit now, while arg_vector still exists. */
2840 if (backtrace_list
->debug_on_exit
)
2841 tem
= call_debugger (Fcons (Qexit
, Fcons (tem
, Qnil
)));
2842 /* Don't do it again when we return to eval. */
2843 backtrace_list
->debug_on_exit
= 0;
2847 /* Apply a Lisp function FUN to the NARGS evaluated arguments in ARG_VECTOR
2848 and return the result of evaluation.
2849 FUN must be either a lambda-expression or a compiled-code object. */
2852 funcall_lambda (fun
, nargs
, arg_vector
)
2855 register Lisp_Object
*arg_vector
;
2857 Lisp_Object val
, syms_left
, next
;
2858 int count
= SPECPDL_INDEX ();
2859 int i
, optional
, rest
;
2863 syms_left
= XCDR (fun
);
2864 if (CONSP (syms_left
))
2865 syms_left
= XCAR (syms_left
);
2867 return Fsignal (Qinvalid_function
, Fcons (fun
, Qnil
));
2869 else if (COMPILEDP (fun
))
2870 syms_left
= AREF (fun
, COMPILED_ARGLIST
);
2874 i
= optional
= rest
= 0;
2875 for (; CONSP (syms_left
); syms_left
= XCDR (syms_left
))
2879 next
= XCAR (syms_left
);
2880 while (!SYMBOLP (next
))
2881 next
= Fsignal (Qinvalid_function
, Fcons (fun
, Qnil
));
2883 if (EQ (next
, Qand_rest
))
2885 else if (EQ (next
, Qand_optional
))
2889 specbind (next
, Flist (nargs
- i
, &arg_vector
[i
]));
2893 specbind (next
, arg_vector
[i
++]);
2895 return Fsignal (Qwrong_number_of_arguments
,
2896 Fcons (fun
, Fcons (make_number (nargs
), Qnil
)));
2898 specbind (next
, Qnil
);
2901 if (!NILP (syms_left
))
2902 return Fsignal (Qinvalid_function
, Fcons (fun
, Qnil
));
2904 return Fsignal (Qwrong_number_of_arguments
,
2905 Fcons (fun
, Fcons (make_number (nargs
), Qnil
)));
2908 val
= Fprogn (XCDR (XCDR (fun
)));
2911 /* If we have not actually read the bytecode string
2912 and constants vector yet, fetch them from the file. */
2913 if (CONSP (AREF (fun
, COMPILED_BYTECODE
)))
2914 Ffetch_bytecode (fun
);
2915 val
= Fbyte_code (AREF (fun
, COMPILED_BYTECODE
),
2916 AREF (fun
, COMPILED_CONSTANTS
),
2917 AREF (fun
, COMPILED_STACK_DEPTH
));
2920 return unbind_to (count
, val
);
2923 DEFUN ("fetch-bytecode", Ffetch_bytecode
, Sfetch_bytecode
,
2925 doc
: /* If byte-compiled OBJECT is lazy-loaded, fetch it now. */)
2931 if (COMPILEDP (object
) && CONSP (AREF (object
, COMPILED_BYTECODE
)))
2933 tem
= read_doc_string (AREF (object
, COMPILED_BYTECODE
));
2936 tem
= AREF (object
, COMPILED_BYTECODE
);
2937 if (CONSP (tem
) && STRINGP (XCAR (tem
)))
2938 error ("Invalid byte code in %s", SDATA (XCAR (tem
)));
2940 error ("Invalid byte code");
2942 AREF (object
, COMPILED_BYTECODE
) = XCAR (tem
);
2943 AREF (object
, COMPILED_CONSTANTS
) = XCDR (tem
);
2951 register int count
= SPECPDL_INDEX ();
2952 if (specpdl_size
>= max_specpdl_size
)
2954 if (max_specpdl_size
< 400)
2955 max_specpdl_size
= 400;
2956 if (specpdl_size
>= max_specpdl_size
)
2958 if (!NILP (Vdebug_on_error
))
2959 /* Leave room for some specpdl in the debugger. */
2960 max_specpdl_size
= specpdl_size
+ 100;
2962 Fcons (build_string ("Variable binding depth exceeds max-specpdl-size"), Qnil
));
2966 if (specpdl_size
> max_specpdl_size
)
2967 specpdl_size
= max_specpdl_size
;
2968 specpdl
= (struct specbinding
*) xrealloc (specpdl
, specpdl_size
* sizeof (struct specbinding
));
2969 specpdl_ptr
= specpdl
+ count
;
2973 specbind (symbol
, value
)
2974 Lisp_Object symbol
, value
;
2977 Lisp_Object valcontents
;
2979 CHECK_SYMBOL (symbol
);
2980 if (specpdl_ptr
== specpdl
+ specpdl_size
)
2983 /* The most common case is that of a non-constant symbol with a
2984 trivial value. Make that as fast as we can. */
2985 valcontents
= SYMBOL_VALUE (symbol
);
2986 if (!MISCP (valcontents
) && !SYMBOL_CONSTANT_P (symbol
))
2988 specpdl_ptr
->symbol
= symbol
;
2989 specpdl_ptr
->old_value
= valcontents
;
2990 specpdl_ptr
->func
= NULL
;
2992 SET_SYMBOL_VALUE (symbol
, value
);
2996 Lisp_Object valcontents
;
2998 ovalue
= find_symbol_value (symbol
);
2999 specpdl_ptr
->func
= 0;
3000 specpdl_ptr
->old_value
= ovalue
;
3002 valcontents
= XSYMBOL (symbol
)->value
;
3004 if (BUFFER_LOCAL_VALUEP (valcontents
)
3005 || SOME_BUFFER_LOCAL_VALUEP (valcontents
)
3006 || BUFFER_OBJFWDP (valcontents
))
3008 Lisp_Object where
, current_buffer
;
3010 current_buffer
= Fcurrent_buffer ();
3012 /* For a local variable, record both the symbol and which
3013 buffer's or frame's value we are saving. */
3014 if (!NILP (Flocal_variable_p (symbol
, Qnil
)))
3015 where
= current_buffer
;
3016 else if (!BUFFER_OBJFWDP (valcontents
)
3017 && XBUFFER_LOCAL_VALUE (valcontents
)->found_for_frame
)
3018 where
= XBUFFER_LOCAL_VALUE (valcontents
)->frame
;
3022 /* We're not using the `unused' slot in the specbinding
3023 structure because this would mean we have to do more
3024 work for simple variables. */
3025 specpdl_ptr
->symbol
= Fcons (symbol
, Fcons (where
, current_buffer
));
3027 /* If SYMBOL is a per-buffer variable which doesn't have a
3028 buffer-local value here, make the `let' change the global
3029 value by changing the value of SYMBOL in all buffers not
3030 having their own value. This is consistent with what
3031 happens with other buffer-local variables. */
3033 && BUFFER_OBJFWDP (valcontents
))
3036 Fset_default (symbol
, value
);
3041 specpdl_ptr
->symbol
= symbol
;
3044 if (BUFFER_OBJFWDP (ovalue
) || KBOARD_OBJFWDP (ovalue
))
3045 store_symval_forwarding (symbol
, ovalue
, value
, NULL
);
3047 set_internal (symbol
, value
, 0, 1);
3052 record_unwind_protect (function
, arg
)
3053 Lisp_Object (*function
) P_ ((Lisp_Object
));
3056 if (specpdl_ptr
== specpdl
+ specpdl_size
)
3058 specpdl_ptr
->func
= function
;
3059 specpdl_ptr
->symbol
= Qnil
;
3060 specpdl_ptr
->old_value
= arg
;
3065 unbind_to (count
, value
)
3069 int quitf
= !NILP (Vquit_flag
);
3070 struct gcpro gcpro1
;
3075 while (specpdl_ptr
!= specpdl
+ count
)
3077 /* Copy the binding, and decrement specpdl_ptr, before we do
3078 the work to unbind it. We decrement first
3079 so that an error in unbinding won't try to unbind
3080 the same entry again, and we copy the binding first
3081 in case more bindings are made during some of the code we run. */
3083 struct specbinding this_binding
;
3084 this_binding
= *--specpdl_ptr
;
3086 if (this_binding
.func
!= 0)
3087 (*this_binding
.func
) (this_binding
.old_value
);
3088 /* If the symbol is a list, it is really (SYMBOL WHERE
3089 . CURRENT-BUFFER) where WHERE is either nil, a buffer, or a
3090 frame. If WHERE is a buffer or frame, this indicates we
3091 bound a variable that had a buffer-local or frame-local
3092 binding. WHERE nil means that the variable had the default
3093 value when it was bound. CURRENT-BUFFER is the buffer that
3094 was current when the variable was bound. */
3095 else if (CONSP (this_binding
.symbol
))
3097 Lisp_Object symbol
, where
;
3099 symbol
= XCAR (this_binding
.symbol
);
3100 where
= XCAR (XCDR (this_binding
.symbol
));
3103 Fset_default (symbol
, this_binding
.old_value
);
3104 else if (BUFFERP (where
))
3105 set_internal (symbol
, this_binding
.old_value
, XBUFFER (where
), 1);
3107 set_internal (symbol
, this_binding
.old_value
, NULL
, 1);
3111 /* If variable has a trivial value (no forwarding), we can
3112 just set it. No need to check for constant symbols here,
3113 since that was already done by specbind. */
3114 if (!MISCP (SYMBOL_VALUE (this_binding
.symbol
)))
3115 SET_SYMBOL_VALUE (this_binding
.symbol
, this_binding
.old_value
);
3117 set_internal (this_binding
.symbol
, this_binding
.old_value
, 0, 1);
3121 if (NILP (Vquit_flag
) && quitf
)
3128 DEFUN ("backtrace-debug", Fbacktrace_debug
, Sbacktrace_debug
, 2, 2, 0,
3129 doc
: /* Set the debug-on-exit flag of eval frame LEVEL levels down to FLAG.
3130 The debugger is entered when that frame exits, if the flag is non-nil. */)
3132 Lisp_Object level
, flag
;
3134 register struct backtrace
*backlist
= backtrace_list
;
3137 CHECK_NUMBER (level
);
3139 for (i
= 0; backlist
&& i
< XINT (level
); i
++)
3141 backlist
= backlist
->next
;
3145 backlist
->debug_on_exit
= !NILP (flag
);
3150 DEFUN ("backtrace", Fbacktrace
, Sbacktrace
, 0, 0, "",
3151 doc
: /* Print a trace of Lisp function calls currently active.
3152 Output stream used is value of `standard-output'. */)
3155 register struct backtrace
*backlist
= backtrace_list
;
3159 extern Lisp_Object Vprint_level
;
3160 struct gcpro gcpro1
;
3162 XSETFASTINT (Vprint_level
, 3);
3169 write_string (backlist
->debug_on_exit
? "* " : " ", 2);
3170 if (backlist
->nargs
== UNEVALLED
)
3172 Fprin1 (Fcons (*backlist
->function
, *backlist
->args
), Qnil
);
3173 write_string ("\n", -1);
3177 tem
= *backlist
->function
;
3178 Fprin1 (tem
, Qnil
); /* This can QUIT */
3179 write_string ("(", -1);
3180 if (backlist
->nargs
== MANY
)
3182 for (tail
= *backlist
->args
, i
= 0;
3184 tail
= Fcdr (tail
), i
++)
3186 if (i
) write_string (" ", -1);
3187 Fprin1 (Fcar (tail
), Qnil
);
3192 for (i
= 0; i
< backlist
->nargs
; i
++)
3194 if (i
) write_string (" ", -1);
3195 Fprin1 (backlist
->args
[i
], Qnil
);
3198 write_string (")\n", -1);
3200 backlist
= backlist
->next
;
3203 Vprint_level
= Qnil
;
3208 DEFUN ("backtrace-frame", Fbacktrace_frame
, Sbacktrace_frame
, 1, 1, NULL
,
3209 doc
: /* Return the function and arguments NFRAMES up from current execution point.
3210 If that frame has not evaluated the arguments yet (or is a special form),
3211 the value is (nil FUNCTION ARG-FORMS...).
3212 If that frame has evaluated its arguments and called its function already,
3213 the value is (t FUNCTION ARG-VALUES...).
3214 A &rest arg is represented as the tail of the list ARG-VALUES.
3215 FUNCTION is whatever was supplied as car of evaluated list,
3216 or a lambda expression for macro calls.
3217 If NFRAMES is more than the number of frames, the value is nil. */)
3219 Lisp_Object nframes
;
3221 register struct backtrace
*backlist
= backtrace_list
;
3225 CHECK_NATNUM (nframes
);
3227 /* Find the frame requested. */
3228 for (i
= 0; backlist
&& i
< XFASTINT (nframes
); i
++)
3229 backlist
= backlist
->next
;
3233 if (backlist
->nargs
== UNEVALLED
)
3234 return Fcons (Qnil
, Fcons (*backlist
->function
, *backlist
->args
));
3237 if (backlist
->nargs
== MANY
)
3238 tem
= *backlist
->args
;
3240 tem
= Flist (backlist
->nargs
, backlist
->args
);
3242 return Fcons (Qt
, Fcons (*backlist
->function
, tem
));
3250 DEFVAR_INT ("max-specpdl-size", &max_specpdl_size
,
3251 doc
: /* *Limit on number of Lisp variable bindings & unwind-protects.
3252 If Lisp code tries to make more than this many at once,
3253 an error is signaled.
3254 You can safely use a value considerably larger than the default value,
3255 if that proves inconveniently small. However, if you increase it too far,
3256 Emacs could run out of memory trying to make the stack bigger. */);
3258 DEFVAR_INT ("max-lisp-eval-depth", &max_lisp_eval_depth
,
3259 doc
: /* *Limit on depth in `eval', `apply' and `funcall' before error.
3261 This limit serves to catch infinite recursions for you before they cause
3262 actual stack overflow in C, which would be fatal for Emacs.
3263 You can safely make it considerably larger than its default value,
3264 if that proves inconveniently small. However, if you increase it too far,
3265 Emacs could overflow the real C stack, and crash. */);
3267 DEFVAR_LISP ("quit-flag", &Vquit_flag
,
3268 doc
: /* Non-nil causes `eval' to abort, unless `inhibit-quit' is non-nil.
3269 Typing C-g sets `quit-flag' non-nil, regardless of `inhibit-quit'. */);
3272 DEFVAR_LISP ("inhibit-quit", &Vinhibit_quit
,
3273 doc
: /* Non-nil inhibits C-g quitting from happening immediately.
3274 Note that `quit-flag' will still be set by typing C-g,
3275 so a quit will be signaled as soon as `inhibit-quit' is nil.
3276 To prevent this happening, set `quit-flag' to nil
3277 before making `inhibit-quit' nil. */);
3278 Vinhibit_quit
= Qnil
;
3280 Qinhibit_quit
= intern ("inhibit-quit");
3281 staticpro (&Qinhibit_quit
);
3283 Qautoload
= intern ("autoload");
3284 staticpro (&Qautoload
);
3286 Qdebug_on_error
= intern ("debug-on-error");
3287 staticpro (&Qdebug_on_error
);
3289 Qmacro
= intern ("macro");
3290 staticpro (&Qmacro
);
3292 Qdeclare
= intern ("declare");
3293 staticpro (&Qdeclare
);
3295 /* Note that the process handling also uses Qexit, but we don't want
3296 to staticpro it twice, so we just do it here. */
3297 Qexit
= intern ("exit");
3300 Qinteractive
= intern ("interactive");
3301 staticpro (&Qinteractive
);
3303 Qcommandp
= intern ("commandp");
3304 staticpro (&Qcommandp
);
3306 Qdefun
= intern ("defun");
3307 staticpro (&Qdefun
);
3309 Qdefvar
= intern ("defvar");
3310 staticpro (&Qdefvar
);
3312 Qand_rest
= intern ("&rest");
3313 staticpro (&Qand_rest
);
3315 Qand_optional
= intern ("&optional");
3316 staticpro (&Qand_optional
);
3318 DEFVAR_LISP ("stack-trace-on-error", &Vstack_trace_on_error
,
3319 doc
: /* *Non-nil means errors display a backtrace buffer.
3320 More precisely, this happens for any error that is handled
3321 by the editor command loop.
3322 If the value is a list, an error only means to display a backtrace
3323 if one of its condition symbols appears in the list. */);
3324 Vstack_trace_on_error
= Qnil
;
3326 DEFVAR_LISP ("debug-on-error", &Vdebug_on_error
,
3327 doc
: /* *Non-nil means enter debugger if an error is signaled.
3328 Does not apply to errors handled by `condition-case' or those
3329 matched by `debug-ignored-errors'.
3330 If the value is a list, an error only means to enter the debugger
3331 if one of its condition symbols appears in the list.
3332 When you evaluate an expression interactively, this variable
3333 is temporarily non-nil if `eval-expression-debug-on-error' is non-nil.
3334 See also variable `debug-on-quit'. */);
3335 Vdebug_on_error
= Qnil
;
3337 DEFVAR_LISP ("debug-ignored-errors", &Vdebug_ignored_errors
,
3338 doc
: /* *List of errors for which the debugger should not be called.
3339 Each element may be a condition-name or a regexp that matches error messages.
3340 If any element applies to a given error, that error skips the debugger
3341 and just returns to top level.
3342 This overrides the variable `debug-on-error'.
3343 It does not apply to errors handled by `condition-case'. */);
3344 Vdebug_ignored_errors
= Qnil
;
3346 DEFVAR_BOOL ("debug-on-quit", &debug_on_quit
,
3347 doc
: /* *Non-nil means enter debugger if quit is signaled (C-g, for example).
3348 Does not apply if quit is handled by a `condition-case'.
3349 When you evaluate an expression interactively, this variable
3350 is temporarily non-nil if `eval-expression-debug-on-quit' is non-nil. */);
3353 DEFVAR_BOOL ("debug-on-next-call", &debug_on_next_call
,
3354 doc
: /* Non-nil means enter debugger before next `eval', `apply' or `funcall'. */);
3356 DEFVAR_BOOL ("debugger-may-continue", &debugger_may_continue
,
3357 doc
: /* Non-nil means debugger may continue execution.
3358 This is nil when the debugger is called under circumstances where it
3359 might not be safe to continue. */);
3360 debugger_may_continue
= 1;
3362 DEFVAR_LISP ("debugger", &Vdebugger
,
3363 doc
: /* Function to call to invoke debugger.
3364 If due to frame exit, args are `exit' and the value being returned;
3365 this function's value will be returned instead of that.
3366 If due to error, args are `error' and a list of the args to `signal'.
3367 If due to `apply' or `funcall' entry, one arg, `lambda'.
3368 If due to `eval' entry, one arg, t. */);
3371 DEFVAR_LISP ("signal-hook-function", &Vsignal_hook_function
,
3372 doc
: /* If non-nil, this is a function for `signal' to call.
3373 It receives the same arguments that `signal' was given.
3374 The Edebug package uses this to regain control. */);
3375 Vsignal_hook_function
= Qnil
;
3377 DEFVAR_LISP ("debug-on-signal", &Vdebug_on_signal
,
3378 doc
: /* *Non-nil means call the debugger regardless of condition handlers.
3379 Note that `debug-on-error', `debug-on-quit' and friends
3380 still determine whether to handle the particular condition. */);
3381 Vdebug_on_signal
= Qnil
;
3383 DEFVAR_LISP ("macro-declaration-function", &Vmacro_declaration_function
,
3384 doc
: /* Function to process declarations in a macro definition.
3385 The function will be called with two args MACRO and DECL.
3386 MACRO is the name of the macro being defined.
3387 DECL is a list `(declare ...)' containing the declarations.
3388 The value the function returns is not used. */);
3389 Vmacro_declaration_function
= Qnil
;
3391 Vrun_hooks
= intern ("run-hooks");
3392 staticpro (&Vrun_hooks
);
3394 staticpro (&Vautoload_queue
);
3395 Vautoload_queue
= Qnil
;
3396 staticpro (&Vsignaling_function
);
3397 Vsignaling_function
= Qnil
;
3408 defsubr (&Sfunction
);
3410 defsubr (&Sdefmacro
);
3412 defsubr (&Sdefvaralias
);
3413 defsubr (&Sdefconst
);
3414 defsubr (&Suser_variable_p
);
3418 defsubr (&Smacroexpand
);
3421 defsubr (&Sunwind_protect
);
3422 defsubr (&Scondition_case
);
3424 defsubr (&Sinteractive_p
);
3425 defsubr (&Scommandp
);
3426 defsubr (&Sautoload
);
3429 defsubr (&Sfuncall
);
3430 defsubr (&Srun_hooks
);
3431 defsubr (&Srun_hook_with_args
);
3432 defsubr (&Srun_hook_with_args_until_success
);
3433 defsubr (&Srun_hook_with_args_until_failure
);
3434 defsubr (&Sfetch_bytecode
);
3435 defsubr (&Sbacktrace_debug
);
3436 defsubr (&Sbacktrace
);
3437 defsubr (&Sbacktrace_frame
);
3440 /* arch-tag: 014a07aa-33ab-4a8f-a3d2-ee8a4a9ff7fb
3441 (do not change this comment) */