1 /* Evaluator for GNU Emacs Lisp interpreter.
2 Copyright (C) 1985, 86, 87, 93, 94, 95, 99, 2000, 2001
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 struct byte_stack
*byte_stack
;
83 struct catchtag
*catchlist
;
86 /* Count levels of GCPRO to detect failure to UNGCPRO. */
90 Lisp_Object Qautoload
, Qmacro
, Qexit
, Qinteractive
, Qcommandp
, Qdefun
;
91 Lisp_Object Qinhibit_quit
, Vinhibit_quit
, Vquit_flag
;
92 Lisp_Object Qmocklisp_arguments
, Vmocklisp_arguments
, Qmocklisp
;
93 Lisp_Object Qand_rest
, Qand_optional
;
94 Lisp_Object Qdebug_on_error
;
96 /* This holds either the symbol `run-hooks' or nil.
97 It is nil at an early stage of startup, and when Emacs
100 Lisp_Object Vrun_hooks
;
102 /* Non-nil means record all fset's and provide's, to be undone
103 if the file being autoloaded is not fully loaded.
104 They are recorded by being consed onto the front of Vautoload_queue:
105 (FUN . ODEF) for a defun, (OFEATURES . nil) for a provide. */
107 Lisp_Object Vautoload_queue
;
109 /* Current number of specbindings allocated in specpdl. */
113 /* Pointer to beginning of specpdl. */
115 struct specbinding
*specpdl
;
117 /* Pointer to first unused element in specpdl. */
119 struct specbinding
*specpdl_ptr
;
121 /* Maximum size allowed for specpdl allocation */
123 int max_specpdl_size
;
125 /* Depth in Lisp evaluations and function calls. */
129 /* Maximum allowed depth in Lisp evaluations and function calls. */
131 int max_lisp_eval_depth
;
133 /* Nonzero means enter debugger before next function call */
135 int debug_on_next_call
;
137 /* Non-zero means debuffer may continue. This is zero when the
138 debugger is called during redisplay, where it might not be safe to
139 continue the interrupted redisplay. */
141 int debugger_may_continue
;
143 /* List of conditions (non-nil atom means all) which cause a backtrace
144 if an error is handled by the command loop's error handler. */
146 Lisp_Object Vstack_trace_on_error
;
148 /* List of conditions (non-nil atom means all) which enter the debugger
149 if an error is handled by the command loop's error handler. */
151 Lisp_Object Vdebug_on_error
;
153 /* List of conditions and regexps specifying error messages which
154 do not enter the debugger even if Vdebug_on_errors says they should. */
156 Lisp_Object Vdebug_ignored_errors
;
158 /* Non-nil means call the debugger even if the error will be handled. */
160 Lisp_Object Vdebug_on_signal
;
162 /* Hook for edebug to use. */
164 Lisp_Object Vsignal_hook_function
;
166 /* Nonzero means enter debugger if a quit signal
167 is handled by the command loop's error handler. */
171 /* The value of num_nonmacro_input_events as of the last time we
172 started to enter the debugger. If we decide to enter the debugger
173 again when this is still equal to num_nonmacro_input_events, then we
174 know that the debugger itself has an error, and we should just
175 signal the error instead of entering an infinite loop of debugger
178 int when_entered_debugger
;
180 Lisp_Object Vdebugger
;
182 /* The function from which the last `signal' was called. Set in
185 Lisp_Object Vsignaling_function
;
187 /* Set to non-zero while processing X events. Checked in Feval to
188 make sure the Lisp interpreter isn't called from a signal handler,
189 which is unsafe because the interpreter isn't reentrant. */
193 void specbind (), record_unwind_protect ();
195 Lisp_Object
run_hook_with_args ();
197 Lisp_Object
funcall_lambda ();
198 extern Lisp_Object
ml_apply (); /* Apply a mocklisp function to unevaluated argument list */
204 specpdl
= (struct specbinding
*) xmalloc (specpdl_size
* sizeof (struct specbinding
));
205 specpdl_ptr
= specpdl
;
206 max_specpdl_size
= 600;
207 max_lisp_eval_depth
= 300;
215 specpdl_ptr
= specpdl
;
220 debug_on_next_call
= 0;
225 /* This is less than the initial value of num_nonmacro_input_events. */
226 when_entered_debugger
= -1;
233 int debug_while_redisplaying
;
234 int count
= specpdl_ptr
- specpdl
;
237 if (lisp_eval_depth
+ 20 > max_lisp_eval_depth
)
238 max_lisp_eval_depth
= lisp_eval_depth
+ 20;
240 if (specpdl_size
+ 40 > max_specpdl_size
)
241 max_specpdl_size
= specpdl_size
+ 40;
243 #ifdef HAVE_X_WINDOWS
244 if (display_hourglass_p
)
248 debug_on_next_call
= 0;
249 when_entered_debugger
= num_nonmacro_input_events
;
251 /* Resetting redisplaying_p to 0 makes sure that debug output is
252 displayed if the debugger is invoked during redisplay. */
253 debug_while_redisplaying
= redisplaying_p
;
255 specbind (intern ("debugger-may-continue"),
256 debug_while_redisplaying
? Qnil
: Qt
);
257 specbind (Qinhibit_redisplay
, Qnil
);
259 #if 0 /* Binding this prevents execution of Lisp code during
260 redisplay, which necessarily leads to display problems. */
261 specbind (Qinhibit_eval_during_redisplay
, Qt
);
264 val
= apply1 (Vdebugger
, arg
);
266 /* Interrupting redisplay and resuming it later is not safe under
267 all circumstances. So, when the debugger returns, abort the
268 interupted redisplay by going back to the top-level. */
269 if (debug_while_redisplaying
)
272 return unbind_to (count
, val
);
276 do_debug_on_call (code
)
279 debug_on_next_call
= 0;
280 backtrace_list
->debug_on_exit
= 1;
281 call_debugger (Fcons (code
, Qnil
));
284 /* NOTE!!! Every function that can call EVAL must protect its args
285 and temporaries from garbage collection while it needs them.
286 The definition of `For' shows what you have to do. */
288 DEFUN ("or", For
, Sor
, 0, UNEVALLED
, 0,
289 "Eval args until one of them yields non-nil, then return that value.\n\
290 The remaining args are not evalled at all.\n\
291 If all args return nil, return nil.")
295 register Lisp_Object val
;
296 Lisp_Object args_left
;
307 val
= Feval (Fcar (args_left
));
310 args_left
= Fcdr (args_left
);
312 while (!NILP(args_left
));
318 DEFUN ("and", Fand
, Sand
, 0, UNEVALLED
, 0,
319 "Eval args until one of them yields nil, then return nil.\n\
320 The remaining args are not evalled at all.\n\
321 If no arg yields nil, return the last arg's value.")
325 register Lisp_Object val
;
326 Lisp_Object args_left
;
337 val
= Feval (Fcar (args_left
));
340 args_left
= Fcdr (args_left
);
342 while (!NILP(args_left
));
348 DEFUN ("if", Fif
, Sif
, 2, UNEVALLED
, 0,
349 "If COND yields non-nil, do THEN, else do ELSE...\n\
350 Returns the value of THEN or the value of the last of the ELSE's.\n\
351 THEN must be one expression, but ELSE... can be zero or more expressions.\n\
352 If COND yields nil, and there are no ELSE's, the value is nil.")
356 register Lisp_Object cond
;
360 cond
= Feval (Fcar (args
));
364 return Feval (Fcar (Fcdr (args
)));
365 return Fprogn (Fcdr (Fcdr (args
)));
368 DEFUN ("cond", Fcond
, Scond
, 0, UNEVALLED
, 0,
369 "Try each clause until one succeeds.\n\
370 Each clause looks like (CONDITION BODY...). CONDITION is evaluated\n\
371 and, if the value is non-nil, this clause succeeds:\n\
372 then the expressions in BODY are evaluated and the last one's\n\
373 value is the value of the cond-form.\n\
374 If no clause succeeds, cond returns nil.\n\
375 If a clause has one element, as in (CONDITION),\n\
376 CONDITION's value if non-nil is returned from the cond-form.")
380 register Lisp_Object clause
, val
;
387 clause
= Fcar (args
);
388 val
= Feval (Fcar (clause
));
391 if (!EQ (XCDR (clause
), Qnil
))
392 val
= Fprogn (XCDR (clause
));
402 DEFUN ("progn", Fprogn
, Sprogn
, 0, UNEVALLED
, 0,
403 "Eval BODY forms sequentially and return value of last one.")
407 register Lisp_Object val
, tem
;
408 Lisp_Object args_left
;
411 /* In Mocklisp code, symbols at the front of the progn arglist
412 are to be bound to zero. */
413 if (!EQ (Vmocklisp_arguments
, Qt
))
415 val
= make_number (0);
416 while (!NILP (args
) && (tem
= Fcar (args
), SYMBOLP (tem
)))
419 specbind (tem
, val
), args
= Fcdr (args
);
431 val
= Feval (Fcar (args_left
));
432 args_left
= Fcdr (args_left
);
434 while (!NILP(args_left
));
440 DEFUN ("prog1", Fprog1
, Sprog1
, 1, UNEVALLED
, 0,
441 "Eval FIRST and BODY sequentially; value from FIRST.\n\
442 The value of FIRST is saved during the evaluation of the remaining args,\n\
443 whose values are discarded.")
448 register Lisp_Object args_left
;
449 struct gcpro gcpro1
, gcpro2
;
450 register int argnum
= 0;
462 val
= Feval (Fcar (args_left
));
464 Feval (Fcar (args_left
));
465 args_left
= Fcdr (args_left
);
467 while (!NILP(args_left
));
473 DEFUN ("prog2", Fprog2
, Sprog2
, 2, UNEVALLED
, 0,
474 "Eval X, Y and BODY sequentially; value from Y.\n\
475 The value of Y is saved during the evaluation of the remaining args,\n\
476 whose values are discarded.")
481 register Lisp_Object args_left
;
482 struct gcpro gcpro1
, gcpro2
;
483 register int argnum
= -1;
497 val
= Feval (Fcar (args_left
));
499 Feval (Fcar (args_left
));
500 args_left
= Fcdr (args_left
);
502 while (!NILP (args_left
));
508 DEFUN ("setq", Fsetq
, Ssetq
, 0, UNEVALLED
, 0,
509 "Set each SYM to the value of its VAL.\n\
510 The symbols SYM are variables; they are literal (not evaluated).\n\
511 The values VAL are expressions; they are evaluated.\n\
512 Thus, (setq x (1+ y)) sets `x' to the value of `(1+ y)'.\n\
513 The second VAL is not computed until after the first SYM is set, and so on;\n\
514 each VAL can use the new value of variables set earlier in the `setq'.\n\
515 The return value of the `setq' form is the value of the last VAL.")
519 register Lisp_Object args_left
;
520 register Lisp_Object val
, sym
;
531 val
= Feval (Fcar (Fcdr (args_left
)));
532 sym
= Fcar (args_left
);
534 args_left
= Fcdr (Fcdr (args_left
));
536 while (!NILP(args_left
));
542 DEFUN ("quote", Fquote
, Squote
, 1, UNEVALLED
, 0,
543 "Return the argument, without evaluating it. `(quote x)' yields `x'.")
550 DEFUN ("function", Ffunction
, Sfunction
, 1, UNEVALLED
, 0,
551 "Like `quote', but preferred for objects which are functions.\n\
552 In byte compilation, `function' causes its argument to be compiled.\n\
553 `quote' cannot do that.")
561 DEFUN ("interactive-p", Finteractive_p
, Sinteractive_p
, 0, 0, 0,
562 "Return t if function in which this appears was called interactively.\n\
563 This means that the function was called with call-interactively (which\n\
564 includes being called as the binding of a key)\n\
565 and input is currently coming from the keyboard (not in keyboard macro).")
568 return interactive_p (1) ? Qt
: Qnil
;
572 /* Return 1 if function in which this appears was called
573 interactively. This means that the function was called with
574 call-interactively (which includes being called as the binding of
575 a key) and input is currently coming from the keyboard (not in
578 EXCLUDE_SUBRS_P non-zero means always return 0 if the function
579 called is a built-in. */
582 interactive_p (exclude_subrs_p
)
585 struct backtrace
*btp
;
591 btp
= backtrace_list
;
593 /* If this isn't a byte-compiled function, there may be a frame at
594 the top for Finteractive_p. If so, skip it. */
595 fun
= Findirect_function (*btp
->function
);
596 if (SUBRP (fun
) && XSUBR (fun
) == &Sinteractive_p
)
599 /* If we're running an Emacs 18-style byte-compiled function, there
600 may be a frame for Fbytecode. Now, given the strictest
601 definition, this function isn't really being called
602 interactively, but because that's the way Emacs 18 always builds
603 byte-compiled functions, we'll accept it for now. */
604 if (EQ (*btp
->function
, Qbytecode
))
607 /* If this isn't a byte-compiled function, then we may now be
608 looking at several frames for special forms. Skip past them. */
610 btp
->nargs
== UNEVALLED
)
613 /* btp now points at the frame of the innermost function that isn't
614 a special form, ignoring frames for Finteractive_p and/or
615 Fbytecode at the top. If this frame is for a built-in function
616 (such as load or eval-region) return nil. */
617 fun
= Findirect_function (*btp
->function
);
618 if (exclude_subrs_p
&& SUBRP (fun
))
621 /* btp points to the frame of a Lisp function that called interactive-p.
622 Return t if that function was called interactively. */
623 if (btp
&& btp
->next
&& EQ (*btp
->next
->function
, Qcall_interactively
))
629 DEFUN ("defun", Fdefun
, Sdefun
, 2, UNEVALLED
, 0,
630 "Define NAME as a function.\n\
631 The definition is (lambda ARGLIST [DOCSTRING] BODY...).\n\
632 See also the function `interactive'.")
636 register Lisp_Object fn_name
;
637 register Lisp_Object defn
;
639 fn_name
= Fcar (args
);
640 defn
= Fcons (Qlambda
, Fcdr (args
));
641 if (!NILP (Vpurify_flag
))
642 defn
= Fpurecopy (defn
);
643 Ffset (fn_name
, defn
);
644 LOADHIST_ATTACH (fn_name
);
648 DEFUN ("defmacro", Fdefmacro
, Sdefmacro
, 2, UNEVALLED
, 0,
649 "Define NAME as a macro.\n\
650 The definition is (macro lambda ARGLIST [DOCSTRING] BODY...).\n\
651 When the macro is called, as in (NAME ARGS...),\n\
652 the function (lambda ARGLIST BODY...) is applied to\n\
653 the list ARGS... as it appears in the expression,\n\
654 and the result should be a form to be evaluated instead of the original.")
658 register Lisp_Object fn_name
;
659 register Lisp_Object defn
;
661 fn_name
= Fcar (args
);
662 defn
= Fcons (Qmacro
, Fcons (Qlambda
, Fcdr (args
)));
663 if (!NILP (Vpurify_flag
))
664 defn
= Fpurecopy (defn
);
665 Ffset (fn_name
, defn
);
666 LOADHIST_ATTACH (fn_name
);
670 DEFUN ("defvar", Fdefvar
, Sdefvar
, 1, UNEVALLED
, 0,
671 "Define SYMBOL as a variable.\n\
672 You are not required to define a variable in order to use it,\n\
673 but the definition can supply documentation and an initial value\n\
674 in a way that tags can recognize.\n\n\
675 INITVALUE is evaluated, and used to set SYMBOL, only if SYMBOL's value is void.\n\
676 If SYMBOL is buffer-local, its default value is what is set;\n\
677 buffer-local values are not affected.\n\
678 INITVALUE and DOCSTRING are optional.\n\
679 If DOCSTRING starts with *, this variable is identified as a user option.\n\
680 This means that M-x set-variable recognizes it.\n\
681 See also `user-variable-p'.\n\
682 If INITVALUE is missing, SYMBOL's value is not set.")
686 register Lisp_Object sym
, tem
, tail
;
690 if (!NILP (Fcdr (Fcdr (tail
))))
691 error ("too many arguments");
693 tem
= Fdefault_boundp (sym
);
697 Fset_default (sym
, Feval (Fcar (tail
)));
699 if (!NILP (Fcar (tail
)))
702 if (!NILP (Vpurify_flag
))
703 tem
= Fpurecopy (tem
);
704 Fput (sym
, Qvariable_documentation
, tem
);
706 LOADHIST_ATTACH (sym
);
709 /* A (defvar <var>) should not take precedence in the load-history over
710 an earlier (defvar <var> <val>), so only add to history if the default
711 value is still unbound. */
713 LOADHIST_ATTACH (sym
);
718 DEFUN ("defconst", Fdefconst
, Sdefconst
, 2, UNEVALLED
, 0,
719 "Define SYMBOL as a constant variable.\n\
720 The intent is that neither programs nor users should ever change this value.\n\
721 Always sets the value of SYMBOL to the result of evalling INITVALUE.\n\
722 If SYMBOL is buffer-local, its default value is what is set;\n\
723 buffer-local values are not affected.\n\
724 DOCSTRING is optional.")
728 register Lisp_Object sym
, tem
;
731 if (!NILP (Fcdr (Fcdr (Fcdr (args
)))))
732 error ("too many arguments");
734 tem
= Feval (Fcar (Fcdr (args
)));
735 if (!NILP (Vpurify_flag
))
736 tem
= Fpurecopy (tem
);
737 Fset_default (sym
, tem
);
738 tem
= Fcar (Fcdr (Fcdr (args
)));
741 if (!NILP (Vpurify_flag
))
742 tem
= Fpurecopy (tem
);
743 Fput (sym
, Qvariable_documentation
, tem
);
745 LOADHIST_ATTACH (sym
);
749 DEFUN ("user-variable-p", Fuser_variable_p
, Suser_variable_p
, 1, 1, 0,
750 "Returns t if VARIABLE is intended to be set and modified by users.\n\
751 \(The alternative is a variable used internally in a Lisp program.)\n\
752 Determined by whether the first character of the documentation\n\
753 for the variable is `*' or if the variable is customizable (has a non-nil\n\
754 value of any of `custom-type', `custom-loads' or `standard-value'\n\
755 on its property list).")
757 Lisp_Object variable
;
759 Lisp_Object documentation
;
761 if (!SYMBOLP (variable
))
764 documentation
= Fget (variable
, Qvariable_documentation
);
765 if (INTEGERP (documentation
) && XINT (documentation
) < 0)
767 if (STRINGP (documentation
)
768 && ((unsigned char) XSTRING (documentation
)->data
[0] == '*'))
770 /* If it is (STRING . INTEGER), a negative integer means a user variable. */
771 if (CONSP (documentation
)
772 && STRINGP (XCAR (documentation
))
773 && INTEGERP (XCDR (documentation
))
774 && XINT (XCDR (documentation
)) < 0)
777 if ((!NILP (Fget (variable
, intern ("custom-type"))))
778 || (!NILP (Fget (variable
, intern ("custom-loads"))))
779 || (!NILP (Fget (variable
, intern ("standard-value")))))
784 DEFUN ("let*", FletX
, SletX
, 1, UNEVALLED
, 0,
785 "Bind variables according to VARLIST then eval BODY.\n\
786 The value of the last form in BODY is returned.\n\
787 Each element of VARLIST is a symbol (which is bound to nil)\n\
788 or a list (SYMBOL VALUEFORM) (which binds SYMBOL to the value of VALUEFORM).\n\
789 Each VALUEFORM can refer to the symbols already bound by this VARLIST.")
793 Lisp_Object varlist
, val
, elt
;
794 int count
= specpdl_ptr
- specpdl
;
795 struct gcpro gcpro1
, gcpro2
, gcpro3
;
797 GCPRO3 (args
, elt
, varlist
);
799 varlist
= Fcar (args
);
800 while (!NILP (varlist
))
803 elt
= Fcar (varlist
);
805 specbind (elt
, Qnil
);
806 else if (! NILP (Fcdr (Fcdr (elt
))))
808 Fcons (build_string ("`let' bindings can have only one value-form"),
812 val
= Feval (Fcar (Fcdr (elt
)));
813 specbind (Fcar (elt
), val
);
815 varlist
= Fcdr (varlist
);
818 val
= Fprogn (Fcdr (args
));
819 return unbind_to (count
, val
);
822 DEFUN ("let", Flet
, Slet
, 1, UNEVALLED
, 0,
823 "Bind variables according to VARLIST then eval BODY.\n\
824 The value of the last form in BODY is returned.\n\
825 Each element of VARLIST is a symbol (which is bound to nil)\n\
826 or a list (SYMBOL VALUEFORM) (which binds SYMBOL to the value of VALUEFORM).\n\
827 All the VALUEFORMs are evalled before any symbols are bound.")
831 Lisp_Object
*temps
, tem
;
832 register Lisp_Object elt
, varlist
;
833 int count
= specpdl_ptr
- specpdl
;
835 struct gcpro gcpro1
, gcpro2
;
837 varlist
= Fcar (args
);
839 /* Make space to hold the values to give the bound variables */
840 elt
= Flength (varlist
);
841 temps
= (Lisp_Object
*) alloca (XFASTINT (elt
) * sizeof (Lisp_Object
));
843 /* Compute the values and store them in `temps' */
845 GCPRO2 (args
, *temps
);
848 for (argnum
= 0; !NILP (varlist
); varlist
= Fcdr (varlist
))
851 elt
= Fcar (varlist
);
853 temps
[argnum
++] = Qnil
;
854 else if (! NILP (Fcdr (Fcdr (elt
))))
856 Fcons (build_string ("`let' bindings can have only one value-form"),
859 temps
[argnum
++] = Feval (Fcar (Fcdr (elt
)));
860 gcpro2
.nvars
= argnum
;
864 varlist
= Fcar (args
);
865 for (argnum
= 0; !NILP (varlist
); varlist
= Fcdr (varlist
))
867 elt
= Fcar (varlist
);
868 tem
= temps
[argnum
++];
872 specbind (Fcar (elt
), tem
);
875 elt
= Fprogn (Fcdr (args
));
876 return unbind_to (count
, elt
);
879 DEFUN ("while", Fwhile
, Swhile
, 1, UNEVALLED
, 0,
880 "If TEST yields non-nil, eval BODY... and repeat.\n\
881 The order of execution is thus TEST, BODY, TEST, BODY and so on\n\
882 until TEST returns nil.")
886 Lisp_Object test
, body
, tem
;
887 struct gcpro gcpro1
, gcpro2
;
893 while (tem
= Feval (test
),
894 (!EQ (Vmocklisp_arguments
, Qt
) ? XINT (tem
) : !NILP (tem
)))
904 DEFUN ("macroexpand", Fmacroexpand
, Smacroexpand
, 1, 2, 0,
905 "Return result of expanding macros at top level of FORM.\n\
906 If FORM is not a macro call, it is returned unchanged.\n\
907 Otherwise, the macro is expanded and the expansion is considered\n\
908 in place of FORM. When a non-macro-call results, it is returned.\n\n\
909 The second optional arg ENVIRONMENT specifies an environment of macro\n\
910 definitions to shadow the loaded ones for use in file byte-compilation.")
913 Lisp_Object environment
;
915 /* With cleanups from Hallvard Furuseth. */
916 register Lisp_Object expander
, sym
, def
, tem
;
920 /* Come back here each time we expand a macro call,
921 in case it expands into another macro call. */
924 /* Set SYM, give DEF and TEM right values in case SYM is not a symbol. */
925 def
= sym
= XCAR (form
);
927 /* Trace symbols aliases to other symbols
928 until we get a symbol that is not an alias. */
929 while (SYMBOLP (def
))
933 tem
= Fassq (sym
, environment
);
936 def
= XSYMBOL (sym
)->function
;
937 if (!EQ (def
, Qunbound
))
942 /* Right now TEM is the result from SYM in ENVIRONMENT,
943 and if TEM is nil then DEF is SYM's function definition. */
946 /* SYM is not mentioned in ENVIRONMENT.
947 Look at its function definition. */
948 if (EQ (def
, Qunbound
) || !CONSP (def
))
949 /* Not defined or definition not suitable */
951 if (EQ (XCAR (def
), Qautoload
))
953 /* Autoloading function: will it be a macro when loaded? */
954 tem
= Fnth (make_number (4), def
);
955 if (EQ (tem
, Qt
) || EQ (tem
, Qmacro
))
956 /* Yes, load it and try again. */
960 do_autoload (def
, sym
);
967 else if (!EQ (XCAR (def
), Qmacro
))
969 else expander
= XCDR (def
);
973 expander
= XCDR (tem
);
977 form
= apply1 (expander
, XCDR (form
));
982 DEFUN ("catch", Fcatch
, Scatch
, 1, UNEVALLED
, 0,
983 "Eval BODY allowing nonlocal exits using `throw'.\n\
984 TAG is evalled to get the tag to use; it must not be nil.\n\
986 Then the BODY is executed.\n\
987 Within BODY, (throw TAG) with same tag exits BODY and exits this `catch'.\n\
988 If no throw happens, `catch' returns the value of the last BODY form.\n\
989 If a throw happens, it specifies the value to return from `catch'.")
993 register Lisp_Object tag
;
997 tag
= Feval (Fcar (args
));
999 return internal_catch (tag
, Fprogn
, Fcdr (args
));
1002 /* Set up a catch, then call C function FUNC on argument ARG.
1003 FUNC should return a Lisp_Object.
1004 This is how catches are done from within C code. */
1007 internal_catch (tag
, func
, arg
)
1009 Lisp_Object (*func
) ();
1012 /* This structure is made part of the chain `catchlist'. */
1015 /* Fill in the components of c, and put it on the list. */
1019 c
.backlist
= backtrace_list
;
1020 c
.handlerlist
= handlerlist
;
1021 c
.lisp_eval_depth
= lisp_eval_depth
;
1022 c
.pdlcount
= specpdl_ptr
- specpdl
;
1023 c
.poll_suppress_count
= poll_suppress_count
;
1024 c
.gcpro
= gcprolist
;
1025 c
.byte_stack
= byte_stack_list
;
1029 if (! _setjmp (c
.jmp
))
1030 c
.val
= (*func
) (arg
);
1032 /* Throw works by a longjmp that comes right here. */
1037 /* Unwind the specbind, catch, and handler stacks back to CATCH, and
1038 jump to that CATCH, returning VALUE as the value of that catch.
1040 This is the guts Fthrow and Fsignal; they differ only in the way
1041 they choose the catch tag to throw to. A catch tag for a
1042 condition-case form has a TAG of Qnil.
1044 Before each catch is discarded, unbind all special bindings and
1045 execute all unwind-protect clauses made above that catch. Unwind
1046 the handler stack as we go, so that the proper handlers are in
1047 effect for each unwind-protect clause we run. At the end, restore
1048 some static info saved in CATCH, and longjmp to the location
1051 This is used for correct unwinding in Fthrow and Fsignal. */
1054 unwind_to_catch (catch, value
)
1055 struct catchtag
*catch;
1058 register int last_time
;
1060 /* Save the value in the tag. */
1063 /* Restore the polling-suppression count. */
1064 set_poll_suppress_count (catch->poll_suppress_count
);
1068 last_time
= catchlist
== catch;
1070 /* Unwind the specpdl stack, and then restore the proper set of
1072 unbind_to (catchlist
->pdlcount
, Qnil
);
1073 handlerlist
= catchlist
->handlerlist
;
1074 catchlist
= catchlist
->next
;
1076 while (! last_time
);
1078 byte_stack_list
= catch->byte_stack
;
1079 gcprolist
= catch->gcpro
;
1082 gcpro_level
= gcprolist
->level
+ 1;
1086 backtrace_list
= catch->backlist
;
1087 lisp_eval_depth
= catch->lisp_eval_depth
;
1089 _longjmp (catch->jmp
, 1);
1092 DEFUN ("throw", Fthrow
, Sthrow
, 2, 2, 0,
1093 "Throw to the catch for TAG and return VALUE from it.\n\
1094 Both TAG and VALUE are evalled.")
1096 register Lisp_Object tag
, value
;
1098 register struct catchtag
*c
;
1103 for (c
= catchlist
; c
; c
= c
->next
)
1105 if (EQ (c
->tag
, tag
))
1106 unwind_to_catch (c
, value
);
1108 tag
= Fsignal (Qno_catch
, Fcons (tag
, Fcons (value
, Qnil
)));
1113 DEFUN ("unwind-protect", Funwind_protect
, Sunwind_protect
, 1, UNEVALLED
, 0,
1114 "Do BODYFORM, protecting with UNWINDFORMS.\n\
1115 If BODYFORM completes normally, its value is returned\n\
1116 after executing the UNWINDFORMS.\n\
1117 If BODYFORM exits nonlocally, the UNWINDFORMS are executed anyway.")
1122 int count
= specpdl_ptr
- specpdl
;
1124 record_unwind_protect (0, Fcdr (args
));
1125 val
= Feval (Fcar (args
));
1126 return unbind_to (count
, val
);
1129 /* Chain of condition handlers currently in effect.
1130 The elements of this chain are contained in the stack frames
1131 of Fcondition_case and internal_condition_case.
1132 When an error is signaled (by calling Fsignal, below),
1133 this chain is searched for an element that applies. */
1135 struct handler
*handlerlist
;
1137 DEFUN ("condition-case", Fcondition_case
, Scondition_case
, 2, UNEVALLED
, 0,
1138 "Regain control when an error is signaled.\n\
1139 executes BODYFORM and returns its value if no error happens.\n\
1140 Each element of HANDLERS looks like (CONDITION-NAME BODY...)\n\
1141 where the BODY is made of Lisp expressions.\n\n\
1142 A handler is applicable to an error\n\
1143 if CONDITION-NAME is one of the error's condition names.\n\
1144 If an error happens, the first applicable handler is run.\n\
1146 The car of a handler may be a list of condition names\n\
1147 instead of a single condition name.\n\
1149 When a handler handles an error,\n\
1150 control returns to the condition-case and the handler BODY... is executed\n\
1151 with VAR bound to (SIGNALED-CONDITIONS . SIGNAL-DATA).\n\
1152 VAR may be nil; then you do not get access to the signal information.\n\
1154 The value of the last BODY form is returned from the condition-case.\n\
1155 See also the function `signal' for more info.")
1162 register Lisp_Object bodyform
, handlers
;
1163 volatile Lisp_Object var
;
1166 bodyform
= Fcar (Fcdr (args
));
1167 handlers
= Fcdr (Fcdr (args
));
1168 CHECK_SYMBOL (var
, 0);
1170 for (val
= handlers
; ! NILP (val
); val
= Fcdr (val
))
1176 && (SYMBOLP (XCAR (tem
))
1177 || CONSP (XCAR (tem
))))))
1178 error ("Invalid condition handler", tem
);
1183 c
.backlist
= backtrace_list
;
1184 c
.handlerlist
= handlerlist
;
1185 c
.lisp_eval_depth
= lisp_eval_depth
;
1186 c
.pdlcount
= specpdl_ptr
- specpdl
;
1187 c
.poll_suppress_count
= poll_suppress_count
;
1188 c
.gcpro
= gcprolist
;
1189 c
.byte_stack
= byte_stack_list
;
1190 if (_setjmp (c
.jmp
))
1193 specbind (h
.var
, c
.val
);
1194 val
= Fprogn (Fcdr (h
.chosen_clause
));
1196 /* Note that this just undoes the binding of h.var; whoever
1197 longjumped to us unwound the stack to c.pdlcount before
1199 unbind_to (c
.pdlcount
, Qnil
);
1206 h
.handler
= handlers
;
1207 h
.next
= handlerlist
;
1211 val
= Feval (bodyform
);
1213 handlerlist
= h
.next
;
1217 /* Call the function BFUN with no arguments, catching errors within it
1218 according to HANDLERS. If there is an error, call HFUN with
1219 one argument which is the data that describes the error:
1222 HANDLERS can be a list of conditions to catch.
1223 If HANDLERS is Qt, catch all errors.
1224 If HANDLERS is Qerror, catch all errors
1225 but allow the debugger to run if that is enabled. */
1228 internal_condition_case (bfun
, handlers
, hfun
)
1229 Lisp_Object (*bfun
) ();
1230 Lisp_Object handlers
;
1231 Lisp_Object (*hfun
) ();
1237 #if 0 /* Can't do this check anymore because realize_basic_faces has
1238 to BLOCK_INPUT, and can call Lisp. What's really needed is a
1239 flag indicating that we're currently handling a signal. */
1240 /* Since Fsignal resets this to 0, it had better be 0 now
1241 or else we have a potential bug. */
1242 if (interrupt_input_blocked
!= 0)
1248 c
.backlist
= backtrace_list
;
1249 c
.handlerlist
= handlerlist
;
1250 c
.lisp_eval_depth
= lisp_eval_depth
;
1251 c
.pdlcount
= specpdl_ptr
- specpdl
;
1252 c
.poll_suppress_count
= poll_suppress_count
;
1253 c
.gcpro
= gcprolist
;
1254 c
.byte_stack
= byte_stack_list
;
1255 if (_setjmp (c
.jmp
))
1257 return (*hfun
) (c
.val
);
1261 h
.handler
= handlers
;
1263 h
.next
= handlerlist
;
1269 handlerlist
= h
.next
;
1273 /* Like internal_condition_case but call HFUN with ARG as its argument. */
1276 internal_condition_case_1 (bfun
, arg
, handlers
, hfun
)
1277 Lisp_Object (*bfun
) ();
1279 Lisp_Object handlers
;
1280 Lisp_Object (*hfun
) ();
1288 c
.backlist
= backtrace_list
;
1289 c
.handlerlist
= handlerlist
;
1290 c
.lisp_eval_depth
= lisp_eval_depth
;
1291 c
.pdlcount
= specpdl_ptr
- specpdl
;
1292 c
.poll_suppress_count
= poll_suppress_count
;
1293 c
.gcpro
= gcprolist
;
1294 c
.byte_stack
= byte_stack_list
;
1295 if (_setjmp (c
.jmp
))
1297 return (*hfun
) (c
.val
);
1301 h
.handler
= handlers
;
1303 h
.next
= handlerlist
;
1307 val
= (*bfun
) (arg
);
1309 handlerlist
= h
.next
;
1314 /* Like internal_condition_case but call HFUN with NARGS as first,
1315 and ARGS as second argument. */
1318 internal_condition_case_2 (bfun
, nargs
, args
, handlers
, hfun
)
1319 Lisp_Object (*bfun
) ();
1322 Lisp_Object handlers
;
1323 Lisp_Object (*hfun
) ();
1331 c
.backlist
= backtrace_list
;
1332 c
.handlerlist
= handlerlist
;
1333 c
.lisp_eval_depth
= lisp_eval_depth
;
1334 c
.pdlcount
= specpdl_ptr
- specpdl
;
1335 c
.poll_suppress_count
= poll_suppress_count
;
1336 c
.gcpro
= gcprolist
;
1337 c
.byte_stack
= byte_stack_list
;
1338 if (_setjmp (c
.jmp
))
1340 return (*hfun
) (c
.val
);
1344 h
.handler
= handlers
;
1346 h
.next
= handlerlist
;
1350 val
= (*bfun
) (nargs
, args
);
1352 handlerlist
= h
.next
;
1357 static Lisp_Object
find_handler_clause ();
1359 DEFUN ("signal", Fsignal
, Ssignal
, 2, 2, 0,
1360 "Signal an error. Args are ERROR-SYMBOL and associated DATA.\n\
1361 This function does not return.\n\n\
1362 An error symbol is a symbol with an `error-conditions' property\n\
1363 that is a list of condition names.\n\
1364 A handler for any of those names will get to handle this signal.\n\
1365 The symbol `error' should normally be one of them.\n\
1367 DATA should be a list. Its elements are printed as part of the error message.\n\
1368 If the signal is handled, DATA is made available to the handler.\n\
1369 See also the function `condition-case'.")
1370 (error_symbol
, data
)
1371 Lisp_Object error_symbol
, data
;
1373 /* When memory is full, ERROR-SYMBOL is nil,
1374 and DATA is (REAL-ERROR-SYMBOL . REAL-DATA). */
1375 register struct handler
*allhandlers
= handlerlist
;
1376 Lisp_Object conditions
;
1377 extern int gc_in_progress
;
1378 extern int waiting_for_input
;
1379 Lisp_Object debugger_value
;
1381 Lisp_Object real_error_symbol
;
1382 extern int display_hourglass_p
;
1383 struct backtrace
*bp
;
1385 immediate_quit
= handling_signal
= 0;
1386 if (gc_in_progress
|| waiting_for_input
)
1389 TOTALLY_UNBLOCK_INPUT
;
1391 if (NILP (error_symbol
))
1392 real_error_symbol
= Fcar (data
);
1394 real_error_symbol
= error_symbol
;
1396 #ifdef HAVE_X_WINDOWS
1397 if (display_hourglass_p
)
1398 cancel_hourglass ();
1401 /* This hook is used by edebug. */
1402 if (! NILP (Vsignal_hook_function
))
1403 call2 (Vsignal_hook_function
, error_symbol
, data
);
1405 conditions
= Fget (real_error_symbol
, Qerror_conditions
);
1407 /* Remember from where signal was called. Skip over the frame for
1408 `signal' itself. If a frame for `error' follows, skip that,
1410 Vsignaling_function
= Qnil
;
1413 bp
= backtrace_list
->next
;
1414 if (bp
&& bp
->function
&& EQ (*bp
->function
, Qerror
))
1416 if (bp
&& bp
->function
)
1417 Vsignaling_function
= *bp
->function
;
1420 for (; handlerlist
; handlerlist
= handlerlist
->next
)
1422 register Lisp_Object clause
;
1424 if (lisp_eval_depth
+ 20 > max_lisp_eval_depth
)
1425 max_lisp_eval_depth
= lisp_eval_depth
+ 20;
1427 if (specpdl_size
+ 40 > max_specpdl_size
)
1428 max_specpdl_size
= specpdl_size
+ 40;
1430 clause
= find_handler_clause (handlerlist
->handler
, conditions
,
1431 error_symbol
, data
, &debugger_value
);
1433 #if 0 /* Most callers are not prepared to handle gc if this returns.
1434 So, since this feature is not very useful, take it out. */
1435 /* If have called debugger and user wants to continue,
1437 if (EQ (clause
, Qlambda
))
1438 return debugger_value
;
1440 if (EQ (clause
, Qlambda
))
1442 /* We can't return values to code which signaled an error, but we
1443 can continue code which has signaled a quit. */
1444 if (EQ (real_error_symbol
, Qquit
))
1447 error ("Cannot return from the debugger in an error");
1453 Lisp_Object unwind_data
;
1454 struct handler
*h
= handlerlist
;
1456 handlerlist
= allhandlers
;
1458 if (NILP (error_symbol
))
1461 unwind_data
= Fcons (error_symbol
, data
);
1462 h
->chosen_clause
= clause
;
1463 unwind_to_catch (h
->tag
, unwind_data
);
1467 handlerlist
= allhandlers
;
1468 /* If no handler is present now, try to run the debugger,
1469 and if that fails, throw to top level. */
1470 find_handler_clause (Qerror
, conditions
, error_symbol
, data
, &debugger_value
);
1472 Fthrow (Qtop_level
, Qt
);
1474 if (! NILP (error_symbol
))
1475 data
= Fcons (error_symbol
, data
);
1477 string
= Ferror_message_string (data
);
1478 fatal ("%s", XSTRING (string
)->data
, 0);
1481 /* Return nonzero iff LIST is a non-nil atom or
1482 a list containing one of CONDITIONS. */
1485 wants_debugger (list
, conditions
)
1486 Lisp_Object list
, conditions
;
1493 while (CONSP (conditions
))
1495 Lisp_Object
this, tail
;
1496 this = XCAR (conditions
);
1497 for (tail
= list
; CONSP (tail
); tail
= XCDR (tail
))
1498 if (EQ (XCAR (tail
), this))
1500 conditions
= XCDR (conditions
);
1505 /* Return 1 if an error with condition-symbols CONDITIONS,
1506 and described by SIGNAL-DATA, should skip the debugger
1507 according to debugger-ignore-errors. */
1510 skip_debugger (conditions
, data
)
1511 Lisp_Object conditions
, data
;
1514 int first_string
= 1;
1515 Lisp_Object error_message
;
1517 error_message
= Qnil
;
1518 for (tail
= Vdebug_ignored_errors
; CONSP (tail
); tail
= XCDR (tail
))
1520 if (STRINGP (XCAR (tail
)))
1524 error_message
= Ferror_message_string (data
);
1528 if (fast_string_match (XCAR (tail
), error_message
) >= 0)
1533 Lisp_Object contail
;
1535 for (contail
= conditions
; CONSP (contail
); contail
= XCDR (contail
))
1536 if (EQ (XCAR (tail
), XCAR (contail
)))
1544 /* Value of Qlambda means we have called debugger and user has continued.
1545 There are two ways to pass SIG and DATA:
1546 = SIG is the error symbol, and DATA is the rest of the data.
1547 = SIG is nil, and DATA is (SYMBOL . REST-OF-DATA).
1548 This is for memory-full errors only.
1550 Store value returned from debugger into *DEBUGGER_VALUE_PTR. */
1553 find_handler_clause (handlers
, conditions
, sig
, data
, debugger_value_ptr
)
1554 Lisp_Object handlers
, conditions
, sig
, data
;
1555 Lisp_Object
*debugger_value_ptr
;
1557 register Lisp_Object h
;
1558 register Lisp_Object tem
;
1560 if (EQ (handlers
, Qt
)) /* t is used by handlers for all conditions, set up by C code. */
1562 /* error is used similarly, but means print an error message
1563 and run the debugger if that is enabled. */
1564 if (EQ (handlers
, Qerror
)
1565 || !NILP (Vdebug_on_signal
)) /* This says call debugger even if
1566 there is a handler. */
1568 int count
= specpdl_ptr
- specpdl
;
1569 int debugger_called
= 0;
1570 Lisp_Object sig_symbol
, combined_data
;
1571 /* This is set to 1 if we are handling a memory-full error,
1572 because these must not run the debugger.
1573 (There is no room in memory to do that!) */
1574 int no_debugger
= 0;
1578 combined_data
= data
;
1579 sig_symbol
= Fcar (data
);
1584 combined_data
= Fcons (sig
, data
);
1588 if (wants_debugger (Vstack_trace_on_error
, conditions
))
1591 internal_with_output_to_temp_buffer ("*Backtrace*",
1592 (Lisp_Object (*) (Lisp_Object
)) Fbacktrace
,
1595 internal_with_output_to_temp_buffer ("*Backtrace*",
1600 && (EQ (sig_symbol
, Qquit
)
1602 : wants_debugger (Vdebug_on_error
, conditions
))
1603 && ! skip_debugger (conditions
, combined_data
)
1604 && when_entered_debugger
< num_nonmacro_input_events
)
1606 specbind (Qdebug_on_error
, Qnil
);
1608 = call_debugger (Fcons (Qerror
,
1609 Fcons (combined_data
, Qnil
)));
1610 debugger_called
= 1;
1612 /* If there is no handler, return saying whether we ran the debugger. */
1613 if (EQ (handlers
, Qerror
))
1615 if (debugger_called
)
1616 return unbind_to (count
, Qlambda
);
1620 for (h
= handlers
; CONSP (h
); h
= Fcdr (h
))
1622 Lisp_Object handler
, condit
;
1625 if (!CONSP (handler
))
1627 condit
= Fcar (handler
);
1628 /* Handle a single condition name in handler HANDLER. */
1629 if (SYMBOLP (condit
))
1631 tem
= Fmemq (Fcar (handler
), conditions
);
1635 /* Handle a list of condition names in handler HANDLER. */
1636 else if (CONSP (condit
))
1638 while (CONSP (condit
))
1640 tem
= Fmemq (Fcar (condit
), conditions
);
1643 condit
= XCDR (condit
);
1650 /* dump an error message; called like printf */
1654 error (m
, a1
, a2
, a3
)
1674 int used
= doprnt (buffer
, size
, m
, m
+ mlen
, 3, args
);
1679 buffer
= (char *) xrealloc (buffer
, size
);
1682 buffer
= (char *) xmalloc (size
);
1687 string
= build_string (buffer
);
1691 Fsignal (Qerror
, Fcons (string
, Qnil
));
1695 DEFUN ("commandp", Fcommandp
, Scommandp
, 1, 1, 0,
1696 "T if FUNCTION makes provisions for interactive calling.\n\
1697 This means it contains a description for how to read arguments to give it.\n\
1698 The value is nil for an invalid function or a symbol with no function\n\
1701 Interactively callable functions include strings and vectors (treated\n\
1702 as keyboard macros), lambda-expressions that contain a top-level call\n\
1703 to `interactive', autoload definitions made by `autoload' with non-nil\n\
1704 fourth argument, and some of the built-in functions of Lisp.\n\
1706 Also, a symbol satisfies `commandp' if its function definition does so.")
1708 Lisp_Object function
;
1710 register Lisp_Object fun
;
1711 register Lisp_Object funcar
;
1715 fun
= indirect_function (fun
);
1716 if (EQ (fun
, Qunbound
))
1719 /* Emacs primitives are interactive if their DEFUN specifies an
1720 interactive spec. */
1723 if (XSUBR (fun
)->prompt
)
1729 /* Bytecode objects are interactive if they are long enough to
1730 have an element whose index is COMPILED_INTERACTIVE, which is
1731 where the interactive spec is stored. */
1732 else if (COMPILEDP (fun
))
1733 return ((XVECTOR (fun
)->size
& PSEUDOVECTOR_SIZE_MASK
) > COMPILED_INTERACTIVE
1736 /* Strings and vectors are keyboard macros. */
1737 if (STRINGP (fun
) || VECTORP (fun
))
1740 /* Lists may represent commands. */
1743 funcar
= Fcar (fun
);
1744 if (!SYMBOLP (funcar
))
1745 return Fsignal (Qinvalid_function
, Fcons (fun
, Qnil
));
1746 if (EQ (funcar
, Qlambda
))
1747 return Fassq (Qinteractive
, Fcdr (Fcdr (fun
)));
1748 if (EQ (funcar
, Qmocklisp
))
1749 return Qt
; /* All mocklisp functions can be called interactively */
1750 if (EQ (funcar
, Qautoload
))
1751 return Fcar (Fcdr (Fcdr (Fcdr (fun
))));
1757 DEFUN ("autoload", Fautoload
, Sautoload
, 2, 5, 0,
1758 "Define FUNCTION to autoload from FILE.\n\
1759 FUNCTION is a symbol; FILE is a file name string to pass to `load'.\n\
1760 Third arg DOCSTRING is documentation for the function.\n\
1761 Fourth arg INTERACTIVE if non-nil says function can be called interactively.\n\
1762 Fifth arg TYPE indicates the type of the object:\n\
1763 nil or omitted says FUNCTION is a function,\n\
1764 `keymap' says FUNCTION is really a keymap, and\n\
1765 `macro' or t says FUNCTION is really a macro.\n\
1766 Third through fifth args give info about the real definition.\n\
1767 They default to nil.\n\
1768 If FUNCTION is already defined other than as an autoload,\n\
1769 this does nothing and returns nil.")
1770 (function
, file
, docstring
, interactive
, type
)
1771 Lisp_Object function
, file
, docstring
, interactive
, type
;
1774 Lisp_Object args
[4];
1777 CHECK_SYMBOL (function
, 0);
1778 CHECK_STRING (file
, 1);
1780 /* If function is defined and not as an autoload, don't override */
1781 if (!EQ (XSYMBOL (function
)->function
, Qunbound
)
1782 && !(CONSP (XSYMBOL (function
)->function
)
1783 && EQ (XCAR (XSYMBOL (function
)->function
), Qautoload
)))
1786 if (NILP (Vpurify_flag
))
1787 /* Only add entries after dumping, because the ones before are
1788 not useful and else we get loads of them from the loaddefs.el. */
1789 LOADHIST_ATTACH (Fcons (Qautoload
, function
));
1793 args
[1] = docstring
;
1794 args
[2] = interactive
;
1797 return Ffset (function
, Fcons (Qautoload
, Flist (4, &args
[0])));
1798 #else /* NO_ARG_ARRAY */
1799 return Ffset (function
, Fcons (Qautoload
, Flist (4, &file
)));
1800 #endif /* not NO_ARG_ARRAY */
1804 un_autoload (oldqueue
)
1805 Lisp_Object oldqueue
;
1807 register Lisp_Object queue
, first
, second
;
1809 /* Queue to unwind is current value of Vautoload_queue.
1810 oldqueue is the shadowed value to leave in Vautoload_queue. */
1811 queue
= Vautoload_queue
;
1812 Vautoload_queue
= oldqueue
;
1813 while (CONSP (queue
))
1815 first
= Fcar (queue
);
1816 second
= Fcdr (first
);
1817 first
= Fcar (first
);
1818 if (EQ (second
, Qnil
))
1821 Ffset (first
, second
);
1822 queue
= Fcdr (queue
);
1827 /* Load an autoloaded function.
1828 FUNNAME is the symbol which is the function's name.
1829 FUNDEF is the autoload definition (a list). */
1832 do_autoload (fundef
, funname
)
1833 Lisp_Object fundef
, funname
;
1835 int count
= specpdl_ptr
- specpdl
;
1836 Lisp_Object fun
, queue
, first
, second
;
1837 struct gcpro gcpro1
, gcpro2
, gcpro3
;
1840 CHECK_SYMBOL (funname
, 0);
1841 GCPRO3 (fun
, funname
, fundef
);
1843 /* Preserve the match data. */
1844 record_unwind_protect (Fset_match_data
, Fmatch_data (Qnil
, Qnil
));
1846 /* Value saved here is to be restored into Vautoload_queue. */
1847 record_unwind_protect (un_autoload
, Vautoload_queue
);
1848 Vautoload_queue
= Qt
;
1849 Fload (Fcar (Fcdr (fundef
)), Qnil
, noninteractive
? Qt
: Qnil
, Qnil
, Qt
);
1851 /* Save the old autoloads, in case we ever do an unload. */
1852 queue
= Vautoload_queue
;
1853 while (CONSP (queue
))
1855 first
= Fcar (queue
);
1856 second
= Fcdr (first
);
1857 first
= Fcar (first
);
1859 /* Note: This test is subtle. The cdr of an autoload-queue entry
1860 may be an atom if the autoload entry was generated by a defalias
1863 Fput (first
, Qautoload
, (Fcdr (second
)));
1865 queue
= Fcdr (queue
);
1868 /* Once loading finishes, don't undo it. */
1869 Vautoload_queue
= Qt
;
1870 unbind_to (count
, Qnil
);
1872 fun
= Findirect_function (fun
);
1874 if (!NILP (Fequal (fun
, fundef
)))
1875 error ("Autoloading failed to define function %s",
1876 XSYMBOL (funname
)->name
->data
);
1881 DEFUN ("eval", Feval
, Seval
, 1, 1, 0,
1882 "Evaluate FORM and return its value.")
1886 Lisp_Object fun
, val
, original_fun
, original_args
;
1888 struct backtrace backtrace
;
1889 struct gcpro gcpro1
, gcpro2
, gcpro3
;
1891 if (handling_signal
)
1896 if (EQ (Vmocklisp_arguments
, Qt
))
1897 return Fsymbol_value (form
);
1898 val
= Fsymbol_value (form
);
1900 XSETFASTINT (val
, 0);
1901 else if (EQ (val
, Qt
))
1902 XSETFASTINT (val
, 1);
1909 if (consing_since_gc
> gc_cons_threshold
)
1912 Fgarbage_collect ();
1916 if (++lisp_eval_depth
> max_lisp_eval_depth
)
1918 if (max_lisp_eval_depth
< 100)
1919 max_lisp_eval_depth
= 100;
1920 if (lisp_eval_depth
> max_lisp_eval_depth
)
1921 error ("Lisp nesting exceeds max-lisp-eval-depth");
1924 original_fun
= Fcar (form
);
1925 original_args
= Fcdr (form
);
1927 backtrace
.next
= backtrace_list
;
1928 backtrace_list
= &backtrace
;
1929 backtrace
.function
= &original_fun
; /* This also protects them from gc */
1930 backtrace
.args
= &original_args
;
1931 backtrace
.nargs
= UNEVALLED
;
1932 backtrace
.evalargs
= 1;
1933 backtrace
.debug_on_exit
= 0;
1935 if (debug_on_next_call
)
1936 do_debug_on_call (Qt
);
1938 /* At this point, only original_fun and original_args
1939 have values that will be used below */
1941 fun
= Findirect_function (original_fun
);
1945 Lisp_Object numargs
;
1946 Lisp_Object argvals
[8];
1947 Lisp_Object args_left
;
1948 register int i
, maxargs
;
1950 args_left
= original_args
;
1951 numargs
= Flength (args_left
);
1953 if (XINT (numargs
) < XSUBR (fun
)->min_args
||
1954 (XSUBR (fun
)->max_args
>= 0 && XSUBR (fun
)->max_args
< XINT (numargs
)))
1955 return Fsignal (Qwrong_number_of_arguments
, Fcons (fun
, Fcons (numargs
, Qnil
)));
1957 if (XSUBR (fun
)->max_args
== UNEVALLED
)
1959 backtrace
.evalargs
= 0;
1960 val
= (*XSUBR (fun
)->function
) (args_left
);
1964 if (XSUBR (fun
)->max_args
== MANY
)
1966 /* Pass a vector of evaluated arguments */
1968 register int argnum
= 0;
1970 vals
= (Lisp_Object
*) alloca (XINT (numargs
) * sizeof (Lisp_Object
));
1972 GCPRO3 (args_left
, fun
, fun
);
1976 while (!NILP (args_left
))
1978 vals
[argnum
++] = Feval (Fcar (args_left
));
1979 args_left
= Fcdr (args_left
);
1980 gcpro3
.nvars
= argnum
;
1983 backtrace
.args
= vals
;
1984 backtrace
.nargs
= XINT (numargs
);
1986 val
= (*XSUBR (fun
)->function
) (XINT (numargs
), vals
);
1991 GCPRO3 (args_left
, fun
, fun
);
1992 gcpro3
.var
= argvals
;
1995 maxargs
= XSUBR (fun
)->max_args
;
1996 for (i
= 0; i
< maxargs
; args_left
= Fcdr (args_left
))
1998 argvals
[i
] = Feval (Fcar (args_left
));
2004 backtrace
.args
= argvals
;
2005 backtrace
.nargs
= XINT (numargs
);
2010 val
= (*XSUBR (fun
)->function
) ();
2013 val
= (*XSUBR (fun
)->function
) (argvals
[0]);
2016 val
= (*XSUBR (fun
)->function
) (argvals
[0], argvals
[1]);
2019 val
= (*XSUBR (fun
)->function
) (argvals
[0], argvals
[1],
2023 val
= (*XSUBR (fun
)->function
) (argvals
[0], argvals
[1],
2024 argvals
[2], argvals
[3]);
2027 val
= (*XSUBR (fun
)->function
) (argvals
[0], argvals
[1], argvals
[2],
2028 argvals
[3], argvals
[4]);
2031 val
= (*XSUBR (fun
)->function
) (argvals
[0], argvals
[1], argvals
[2],
2032 argvals
[3], argvals
[4], argvals
[5]);
2035 val
= (*XSUBR (fun
)->function
) (argvals
[0], argvals
[1], argvals
[2],
2036 argvals
[3], argvals
[4], argvals
[5],
2041 val
= (*XSUBR (fun
)->function
) (argvals
[0], argvals
[1], argvals
[2],
2042 argvals
[3], argvals
[4], argvals
[5],
2043 argvals
[6], argvals
[7]);
2047 /* Someone has created a subr that takes more arguments than
2048 is supported by this code. We need to either rewrite the
2049 subr to use a different argument protocol, or add more
2050 cases to this switch. */
2054 if (COMPILEDP (fun
))
2055 val
= apply_lambda (fun
, original_args
, 1);
2059 return Fsignal (Qinvalid_function
, Fcons (fun
, Qnil
));
2060 funcar
= Fcar (fun
);
2061 if (!SYMBOLP (funcar
))
2062 return Fsignal (Qinvalid_function
, Fcons (fun
, Qnil
));
2063 if (EQ (funcar
, Qautoload
))
2065 do_autoload (fun
, original_fun
);
2068 if (EQ (funcar
, Qmacro
))
2069 val
= Feval (apply1 (Fcdr (fun
), original_args
));
2070 else if (EQ (funcar
, Qlambda
))
2071 val
= apply_lambda (fun
, original_args
, 1);
2072 else if (EQ (funcar
, Qmocklisp
))
2073 val
= ml_apply (fun
, original_args
);
2075 return Fsignal (Qinvalid_function
, Fcons (fun
, Qnil
));
2078 if (!EQ (Vmocklisp_arguments
, Qt
))
2081 XSETFASTINT (val
, 0);
2082 else if (EQ (val
, Qt
))
2083 XSETFASTINT (val
, 1);
2086 if (backtrace
.debug_on_exit
)
2087 val
= call_debugger (Fcons (Qexit
, Fcons (val
, Qnil
)));
2088 backtrace_list
= backtrace
.next
;
2092 DEFUN ("apply", Fapply
, Sapply
, 2, MANY
, 0,
2093 "Call FUNCTION with our remaining args, using our last arg as list of args.\n\
2094 Then return the value FUNCTION returns.\n\
2095 Thus, (apply '+ 1 2 '(3 4)) returns 10.")
2100 register int i
, numargs
;
2101 register Lisp_Object spread_arg
;
2102 register Lisp_Object
*funcall_args
;
2104 struct gcpro gcpro1
;
2108 spread_arg
= args
[nargs
- 1];
2109 CHECK_LIST (spread_arg
, nargs
);
2111 numargs
= XINT (Flength (spread_arg
));
2114 return Ffuncall (nargs
- 1, args
);
2115 else if (numargs
== 1)
2117 args
[nargs
- 1] = XCAR (spread_arg
);
2118 return Ffuncall (nargs
, args
);
2121 numargs
+= nargs
- 2;
2123 fun
= indirect_function (fun
);
2124 if (EQ (fun
, Qunbound
))
2126 /* Let funcall get the error */
2133 if (numargs
< XSUBR (fun
)->min_args
2134 || (XSUBR (fun
)->max_args
>= 0 && XSUBR (fun
)->max_args
< numargs
))
2135 goto funcall
; /* Let funcall get the error */
2136 else if (XSUBR (fun
)->max_args
> numargs
)
2138 /* Avoid making funcall cons up a yet another new vector of arguments
2139 by explicitly supplying nil's for optional values */
2140 funcall_args
= (Lisp_Object
*) alloca ((1 + XSUBR (fun
)->max_args
)
2141 * sizeof (Lisp_Object
));
2142 for (i
= numargs
; i
< XSUBR (fun
)->max_args
;)
2143 funcall_args
[++i
] = Qnil
;
2144 GCPRO1 (*funcall_args
);
2145 gcpro1
.nvars
= 1 + XSUBR (fun
)->max_args
;
2149 /* We add 1 to numargs because funcall_args includes the
2150 function itself as well as its arguments. */
2153 funcall_args
= (Lisp_Object
*) alloca ((1 + numargs
)
2154 * sizeof (Lisp_Object
));
2155 GCPRO1 (*funcall_args
);
2156 gcpro1
.nvars
= 1 + numargs
;
2159 bcopy (args
, funcall_args
, nargs
* sizeof (Lisp_Object
));
2160 /* Spread the last arg we got. Its first element goes in
2161 the slot that it used to occupy, hence this value of I. */
2163 while (!NILP (spread_arg
))
2165 funcall_args
[i
++] = XCAR (spread_arg
);
2166 spread_arg
= XCDR (spread_arg
);
2169 RETURN_UNGCPRO (Ffuncall (gcpro1
.nvars
, funcall_args
));
2172 /* Run hook variables in various ways. */
2174 enum run_hooks_condition
{to_completion
, until_success
, until_failure
};
2176 DEFUN ("run-hooks", Frun_hooks
, Srun_hooks
, 0, MANY
, 0,
2177 "Run each hook in HOOKS. Major mode functions use this.\n\
2178 Each argument should be a symbol, a hook variable.\n\
2179 These symbols are processed in the order specified.\n\
2180 If a hook symbol has a non-nil value, that value may be a function\n\
2181 or a list of functions to be called to run the hook.\n\
2182 If the value is a function, it is called with no arguments.\n\
2183 If it is a list, the elements are called, in order, with no arguments.\n\
2185 To make a hook variable buffer-local, use `make-local-hook',\n\
2186 not `make-local-variable'.")
2191 Lisp_Object hook
[1];
2194 for (i
= 0; i
< nargs
; i
++)
2197 run_hook_with_args (1, hook
, to_completion
);
2203 DEFUN ("run-hook-with-args", Frun_hook_with_args
,
2204 Srun_hook_with_args
, 1, MANY
, 0,
2205 "Run HOOK with the specified arguments ARGS.\n\
2206 HOOK should be a symbol, a hook variable. If HOOK has a non-nil\n\
2207 value, that value may be a function or a list of functions to be\n\
2208 called to run the hook. If the value is a function, it is called with\n\
2209 the given arguments and its return value is returned. If it is a list\n\
2210 of functions, those functions are called, in order,\n\
2211 with the given arguments ARGS.\n\
2212 It is best not to depend on the value return by `run-hook-with-args',\n\
2213 as that may change.\n\
2215 To make a hook variable buffer-local, use `make-local-hook',\n\
2216 not `make-local-variable'.")
2221 return run_hook_with_args (nargs
, args
, to_completion
);
2224 DEFUN ("run-hook-with-args-until-success", Frun_hook_with_args_until_success
,
2225 Srun_hook_with_args_until_success
, 1, MANY
, 0,
2226 "Run HOOK with the specified arguments ARGS.\n\
2227 HOOK should be a symbol, a hook variable. Its value should\n\
2228 be a list of functions. We call those functions, one by one,\n\
2229 passing arguments ARGS to each of them, until one of them\n\
2230 returns a non-nil value. Then we return that value.\n\
2231 If all the functions return nil, we return nil.\n\
2233 To make a hook variable buffer-local, use `make-local-hook',\n\
2234 not `make-local-variable'.")
2239 return run_hook_with_args (nargs
, args
, until_success
);
2242 DEFUN ("run-hook-with-args-until-failure", Frun_hook_with_args_until_failure
,
2243 Srun_hook_with_args_until_failure
, 1, MANY
, 0,
2244 "Run HOOK with the specified arguments ARGS.\n\
2245 HOOK should be a symbol, a hook variable. Its value should\n\
2246 be a list of functions. We call those functions, one by one,\n\
2247 passing arguments ARGS to each of them, until one of them\n\
2248 returns nil. Then we return nil.\n\
2249 If all the functions return non-nil, we return non-nil.\n\
2251 To make a hook variable buffer-local, use `make-local-hook',\n\
2252 not `make-local-variable'.")
2257 return run_hook_with_args (nargs
, args
, until_failure
);
2260 /* ARGS[0] should be a hook symbol.
2261 Call each of the functions in the hook value, passing each of them
2262 as arguments all the rest of ARGS (all NARGS - 1 elements).
2263 COND specifies a condition to test after each call
2264 to decide whether to stop.
2265 The caller (or its caller, etc) must gcpro all of ARGS,
2266 except that it isn't necessary to gcpro ARGS[0]. */
2269 run_hook_with_args (nargs
, args
, cond
)
2272 enum run_hooks_condition cond
;
2274 Lisp_Object sym
, val
, ret
;
2275 Lisp_Object globals
;
2276 struct gcpro gcpro1
, gcpro2
, gcpro3
;
2278 /* If we are dying or still initializing,
2279 don't do anything--it would probably crash if we tried. */
2280 if (NILP (Vrun_hooks
))
2284 val
= find_symbol_value (sym
);
2285 ret
= (cond
== until_failure
? Qt
: Qnil
);
2287 if (EQ (val
, Qunbound
) || NILP (val
))
2289 else if (!CONSP (val
) || EQ (XCAR (val
), Qlambda
))
2292 return Ffuncall (nargs
, args
);
2297 GCPRO3 (sym
, val
, globals
);
2300 CONSP (val
) && ((cond
== to_completion
)
2301 || (cond
== until_success
? NILP (ret
)
2305 if (EQ (XCAR (val
), Qt
))
2307 /* t indicates this hook has a local binding;
2308 it means to run the global binding too. */
2310 for (globals
= Fdefault_value (sym
);
2311 CONSP (globals
) && ((cond
== to_completion
)
2312 || (cond
== until_success
? NILP (ret
)
2314 globals
= XCDR (globals
))
2316 args
[0] = XCAR (globals
);
2317 /* In a global value, t should not occur. If it does, we
2318 must ignore it to avoid an endless loop. */
2319 if (!EQ (args
[0], Qt
))
2320 ret
= Ffuncall (nargs
, args
);
2325 args
[0] = XCAR (val
);
2326 ret
= Ffuncall (nargs
, args
);
2335 /* Run a hook symbol ARGS[0], but use FUNLIST instead of the actual
2336 present value of that symbol.
2337 Call each element of FUNLIST,
2338 passing each of them the rest of ARGS.
2339 The caller (or its caller, etc) must gcpro all of ARGS,
2340 except that it isn't necessary to gcpro ARGS[0]. */
2343 run_hook_list_with_args (funlist
, nargs
, args
)
2344 Lisp_Object funlist
;
2350 Lisp_Object globals
;
2351 struct gcpro gcpro1
, gcpro2
, gcpro3
;
2355 GCPRO3 (sym
, val
, globals
);
2357 for (val
= funlist
; CONSP (val
); val
= XCDR (val
))
2359 if (EQ (XCAR (val
), Qt
))
2361 /* t indicates this hook has a local binding;
2362 it means to run the global binding too. */
2364 for (globals
= Fdefault_value (sym
);
2366 globals
= XCDR (globals
))
2368 args
[0] = XCAR (globals
);
2369 /* In a global value, t should not occur. If it does, we
2370 must ignore it to avoid an endless loop. */
2371 if (!EQ (args
[0], Qt
))
2372 Ffuncall (nargs
, args
);
2377 args
[0] = XCAR (val
);
2378 Ffuncall (nargs
, args
);
2385 /* Run the hook HOOK, giving each function the two args ARG1 and ARG2. */
2388 run_hook_with_args_2 (hook
, arg1
, arg2
)
2389 Lisp_Object hook
, arg1
, arg2
;
2391 Lisp_Object temp
[3];
2396 Frun_hook_with_args (3, temp
);
2399 /* Apply fn to arg */
2402 Lisp_Object fn
, arg
;
2404 struct gcpro gcpro1
;
2408 RETURN_UNGCPRO (Ffuncall (1, &fn
));
2412 Lisp_Object args
[2];
2416 RETURN_UNGCPRO (Fapply (2, args
));
2418 #else /* not NO_ARG_ARRAY */
2419 RETURN_UNGCPRO (Fapply (2, &fn
));
2420 #endif /* not NO_ARG_ARRAY */
2423 /* Call function fn on no arguments */
2428 struct gcpro gcpro1
;
2431 RETURN_UNGCPRO (Ffuncall (1, &fn
));
2434 /* Call function fn with 1 argument arg1 */
2438 Lisp_Object fn
, arg1
;
2440 struct gcpro gcpro1
;
2442 Lisp_Object args
[2];
2448 RETURN_UNGCPRO (Ffuncall (2, args
));
2449 #else /* not NO_ARG_ARRAY */
2452 RETURN_UNGCPRO (Ffuncall (2, &fn
));
2453 #endif /* not NO_ARG_ARRAY */
2456 /* Call function fn with 2 arguments arg1, arg2 */
2459 call2 (fn
, arg1
, arg2
)
2460 Lisp_Object fn
, arg1
, arg2
;
2462 struct gcpro gcpro1
;
2464 Lisp_Object args
[3];
2470 RETURN_UNGCPRO (Ffuncall (3, args
));
2471 #else /* not NO_ARG_ARRAY */
2474 RETURN_UNGCPRO (Ffuncall (3, &fn
));
2475 #endif /* not NO_ARG_ARRAY */
2478 /* Call function fn with 3 arguments arg1, arg2, arg3 */
2481 call3 (fn
, arg1
, arg2
, arg3
)
2482 Lisp_Object fn
, arg1
, arg2
, arg3
;
2484 struct gcpro gcpro1
;
2486 Lisp_Object args
[4];
2493 RETURN_UNGCPRO (Ffuncall (4, args
));
2494 #else /* not NO_ARG_ARRAY */
2497 RETURN_UNGCPRO (Ffuncall (4, &fn
));
2498 #endif /* not NO_ARG_ARRAY */
2501 /* Call function fn with 4 arguments arg1, arg2, arg3, arg4 */
2504 call4 (fn
, arg1
, arg2
, arg3
, arg4
)
2505 Lisp_Object fn
, arg1
, arg2
, arg3
, arg4
;
2507 struct gcpro gcpro1
;
2509 Lisp_Object args
[5];
2517 RETURN_UNGCPRO (Ffuncall (5, args
));
2518 #else /* not NO_ARG_ARRAY */
2521 RETURN_UNGCPRO (Ffuncall (5, &fn
));
2522 #endif /* not NO_ARG_ARRAY */
2525 /* Call function fn with 5 arguments arg1, arg2, arg3, arg4, arg5 */
2528 call5 (fn
, arg1
, arg2
, arg3
, arg4
, arg5
)
2529 Lisp_Object fn
, arg1
, arg2
, arg3
, arg4
, arg5
;
2531 struct gcpro gcpro1
;
2533 Lisp_Object args
[6];
2542 RETURN_UNGCPRO (Ffuncall (6, args
));
2543 #else /* not NO_ARG_ARRAY */
2546 RETURN_UNGCPRO (Ffuncall (6, &fn
));
2547 #endif /* not NO_ARG_ARRAY */
2550 /* Call function fn with 6 arguments arg1, arg2, arg3, arg4, arg5, arg6 */
2553 call6 (fn
, arg1
, arg2
, arg3
, arg4
, arg5
, arg6
)
2554 Lisp_Object fn
, arg1
, arg2
, arg3
, arg4
, arg5
, arg6
;
2556 struct gcpro gcpro1
;
2558 Lisp_Object args
[7];
2568 RETURN_UNGCPRO (Ffuncall (7, args
));
2569 #else /* not NO_ARG_ARRAY */
2572 RETURN_UNGCPRO (Ffuncall (7, &fn
));
2573 #endif /* not NO_ARG_ARRAY */
2576 DEFUN ("funcall", Ffuncall
, Sfuncall
, 1, MANY
, 0,
2577 "Call first argument as a function, passing remaining arguments to it.\n\
2578 Return the value that function returns.\n\
2579 Thus, (funcall 'cons 'x 'y) returns (x . y).")
2586 int numargs
= nargs
- 1;
2587 Lisp_Object lisp_numargs
;
2589 struct backtrace backtrace
;
2590 register Lisp_Object
*internal_args
;
2594 if (consing_since_gc
> gc_cons_threshold
)
2595 Fgarbage_collect ();
2597 if (++lisp_eval_depth
> max_lisp_eval_depth
)
2599 if (max_lisp_eval_depth
< 100)
2600 max_lisp_eval_depth
= 100;
2601 if (lisp_eval_depth
> max_lisp_eval_depth
)
2602 error ("Lisp nesting exceeds max-lisp-eval-depth");
2605 backtrace
.next
= backtrace_list
;
2606 backtrace_list
= &backtrace
;
2607 backtrace
.function
= &args
[0];
2608 backtrace
.args
= &args
[1];
2609 backtrace
.nargs
= nargs
- 1;
2610 backtrace
.evalargs
= 0;
2611 backtrace
.debug_on_exit
= 0;
2613 if (debug_on_next_call
)
2614 do_debug_on_call (Qlambda
);
2620 fun
= Findirect_function (fun
);
2624 if (numargs
< XSUBR (fun
)->min_args
2625 || (XSUBR (fun
)->max_args
>= 0 && XSUBR (fun
)->max_args
< numargs
))
2627 XSETFASTINT (lisp_numargs
, numargs
);
2628 return Fsignal (Qwrong_number_of_arguments
, Fcons (fun
, Fcons (lisp_numargs
, Qnil
)));
2631 if (XSUBR (fun
)->max_args
== UNEVALLED
)
2632 return Fsignal (Qinvalid_function
, Fcons (fun
, Qnil
));
2634 if (XSUBR (fun
)->max_args
== MANY
)
2636 val
= (*XSUBR (fun
)->function
) (numargs
, args
+ 1);
2640 if (XSUBR (fun
)->max_args
> numargs
)
2642 internal_args
= (Lisp_Object
*) alloca (XSUBR (fun
)->max_args
* sizeof (Lisp_Object
));
2643 bcopy (args
+ 1, internal_args
, numargs
* sizeof (Lisp_Object
));
2644 for (i
= numargs
; i
< XSUBR (fun
)->max_args
; i
++)
2645 internal_args
[i
] = Qnil
;
2648 internal_args
= args
+ 1;
2649 switch (XSUBR (fun
)->max_args
)
2652 val
= (*XSUBR (fun
)->function
) ();
2655 val
= (*XSUBR (fun
)->function
) (internal_args
[0]);
2658 val
= (*XSUBR (fun
)->function
) (internal_args
[0],
2662 val
= (*XSUBR (fun
)->function
) (internal_args
[0], internal_args
[1],
2666 val
= (*XSUBR (fun
)->function
) (internal_args
[0], internal_args
[1],
2671 val
= (*XSUBR (fun
)->function
) (internal_args
[0], internal_args
[1],
2672 internal_args
[2], internal_args
[3],
2676 val
= (*XSUBR (fun
)->function
) (internal_args
[0], internal_args
[1],
2677 internal_args
[2], internal_args
[3],
2678 internal_args
[4], internal_args
[5]);
2681 val
= (*XSUBR (fun
)->function
) (internal_args
[0], internal_args
[1],
2682 internal_args
[2], internal_args
[3],
2683 internal_args
[4], internal_args
[5],
2688 val
= (*XSUBR (fun
)->function
) (internal_args
[0], internal_args
[1],
2689 internal_args
[2], internal_args
[3],
2690 internal_args
[4], internal_args
[5],
2691 internal_args
[6], internal_args
[7]);
2696 /* If a subr takes more than 8 arguments without using MANY
2697 or UNEVALLED, we need to extend this function to support it.
2698 Until this is done, there is no way to call the function. */
2702 if (COMPILEDP (fun
))
2703 val
= funcall_lambda (fun
, numargs
, args
+ 1);
2707 return Fsignal (Qinvalid_function
, Fcons (fun
, Qnil
));
2708 funcar
= Fcar (fun
);
2709 if (!SYMBOLP (funcar
))
2710 return Fsignal (Qinvalid_function
, Fcons (fun
, Qnil
));
2711 if (EQ (funcar
, Qlambda
))
2712 val
= funcall_lambda (fun
, numargs
, args
+ 1);
2713 else if (EQ (funcar
, Qmocklisp
))
2714 val
= ml_apply (fun
, Flist (numargs
, args
+ 1));
2715 else if (EQ (funcar
, Qautoload
))
2717 do_autoload (fun
, args
[0]);
2721 return Fsignal (Qinvalid_function
, Fcons (fun
, Qnil
));
2725 if (backtrace
.debug_on_exit
)
2726 val
= call_debugger (Fcons (Qexit
, Fcons (val
, Qnil
)));
2727 backtrace_list
= backtrace
.next
;
2732 apply_lambda (fun
, args
, eval_flag
)
2733 Lisp_Object fun
, args
;
2736 Lisp_Object args_left
;
2737 Lisp_Object numargs
;
2738 register Lisp_Object
*arg_vector
;
2739 struct gcpro gcpro1
, gcpro2
, gcpro3
;
2741 register Lisp_Object tem
;
2743 numargs
= Flength (args
);
2744 arg_vector
= (Lisp_Object
*) alloca (XINT (numargs
) * sizeof (Lisp_Object
));
2747 GCPRO3 (*arg_vector
, args_left
, fun
);
2750 for (i
= 0; i
< XINT (numargs
);)
2752 tem
= Fcar (args_left
), args_left
= Fcdr (args_left
);
2753 if (eval_flag
) tem
= Feval (tem
);
2754 arg_vector
[i
++] = tem
;
2762 backtrace_list
->args
= arg_vector
;
2763 backtrace_list
->nargs
= i
;
2765 backtrace_list
->evalargs
= 0;
2766 tem
= funcall_lambda (fun
, XINT (numargs
), arg_vector
);
2768 /* Do the debug-on-exit now, while arg_vector still exists. */
2769 if (backtrace_list
->debug_on_exit
)
2770 tem
= call_debugger (Fcons (Qexit
, Fcons (tem
, Qnil
)));
2771 /* Don't do it again when we return to eval. */
2772 backtrace_list
->debug_on_exit
= 0;
2776 /* Apply a Lisp function FUN to the NARGS evaluated arguments in ARG_VECTOR
2777 and return the result of evaluation.
2778 FUN must be either a lambda-expression or a compiled-code object. */
2781 funcall_lambda (fun
, nargs
, arg_vector
)
2784 register Lisp_Object
*arg_vector
;
2786 Lisp_Object val
, syms_left
, next
;
2787 int count
= specpdl_ptr
- specpdl
;
2788 int i
, optional
, rest
;
2790 if (NILP (Vmocklisp_arguments
))
2791 specbind (Qmocklisp_arguments
, Qt
); /* t means NOT mocklisp! */
2795 syms_left
= XCDR (fun
);
2796 if (CONSP (syms_left
))
2797 syms_left
= XCAR (syms_left
);
2799 return Fsignal (Qinvalid_function
, Fcons (fun
, Qnil
));
2801 else if (COMPILEDP (fun
))
2802 syms_left
= XVECTOR (fun
)->contents
[COMPILED_ARGLIST
];
2806 i
= optional
= rest
= 0;
2807 for (; CONSP (syms_left
); syms_left
= XCDR (syms_left
))
2811 next
= XCAR (syms_left
);
2812 while (!SYMBOLP (next
))
2813 next
= Fsignal (Qinvalid_function
, Fcons (fun
, Qnil
));
2815 if (EQ (next
, Qand_rest
))
2817 else if (EQ (next
, Qand_optional
))
2821 specbind (next
, Flist (nargs
- i
, &arg_vector
[i
]));
2825 specbind (next
, arg_vector
[i
++]);
2827 return Fsignal (Qwrong_number_of_arguments
,
2828 Fcons (fun
, Fcons (make_number (nargs
), Qnil
)));
2830 specbind (next
, Qnil
);
2833 if (!NILP (syms_left
))
2834 return Fsignal (Qinvalid_function
, Fcons (fun
, Qnil
));
2836 return Fsignal (Qwrong_number_of_arguments
,
2837 Fcons (fun
, Fcons (make_number (nargs
), Qnil
)));
2840 val
= Fprogn (XCDR (XCDR (fun
)));
2843 /* If we have not actually read the bytecode string
2844 and constants vector yet, fetch them from the file. */
2845 if (CONSP (XVECTOR (fun
)->contents
[COMPILED_BYTECODE
]))
2846 Ffetch_bytecode (fun
);
2847 val
= Fbyte_code (XVECTOR (fun
)->contents
[COMPILED_BYTECODE
],
2848 XVECTOR (fun
)->contents
[COMPILED_CONSTANTS
],
2849 XVECTOR (fun
)->contents
[COMPILED_STACK_DEPTH
]);
2852 return unbind_to (count
, val
);
2855 DEFUN ("fetch-bytecode", Ffetch_bytecode
, Sfetch_bytecode
,
2857 "If byte-compiled OBJECT is lazy-loaded, fetch it now.")
2863 if (COMPILEDP (object
)
2864 && CONSP (XVECTOR (object
)->contents
[COMPILED_BYTECODE
]))
2866 tem
= read_doc_string (XVECTOR (object
)->contents
[COMPILED_BYTECODE
]);
2868 error ("invalid byte code");
2869 XVECTOR (object
)->contents
[COMPILED_BYTECODE
] = XCAR (tem
);
2870 XVECTOR (object
)->contents
[COMPILED_CONSTANTS
] = XCDR (tem
);
2878 register int count
= specpdl_ptr
- specpdl
;
2879 if (specpdl_size
>= max_specpdl_size
)
2881 if (max_specpdl_size
< 400)
2882 max_specpdl_size
= 400;
2883 if (specpdl_size
>= max_specpdl_size
)
2885 if (!NILP (Vdebug_on_error
))
2886 /* Leave room for some specpdl in the debugger. */
2887 max_specpdl_size
= specpdl_size
+ 100;
2889 Fcons (build_string ("Variable binding depth exceeds max-specpdl-size"), Qnil
));
2893 if (specpdl_size
> max_specpdl_size
)
2894 specpdl_size
= max_specpdl_size
;
2895 specpdl
= (struct specbinding
*) xrealloc (specpdl
, specpdl_size
* sizeof (struct specbinding
));
2896 specpdl_ptr
= specpdl
+ count
;
2900 specbind (symbol
, value
)
2901 Lisp_Object symbol
, value
;
2905 CHECK_SYMBOL (symbol
, 0);
2906 if (specpdl_ptr
== specpdl
+ specpdl_size
)
2909 /* The most common case is that a non-constant symbol with a trivial
2910 value. Make that as fast as we can. */
2911 if (!MISCP (XSYMBOL (symbol
)->value
)
2912 && !EQ (symbol
, Qnil
)
2914 && !(XSYMBOL (symbol
)->name
->data
[0] == ':'
2915 && EQ (XSYMBOL (symbol
)->obarray
, initial_obarray
)
2916 && !EQ (value
, symbol
)))
2918 specpdl_ptr
->symbol
= symbol
;
2919 specpdl_ptr
->old_value
= XSYMBOL (symbol
)->value
;
2920 specpdl_ptr
->func
= NULL
;
2922 XSYMBOL (symbol
)->value
= value
;
2926 ovalue
= find_symbol_value (symbol
);
2927 specpdl_ptr
->func
= 0;
2928 specpdl_ptr
->old_value
= ovalue
;
2930 if (BUFFER_LOCAL_VALUEP (XSYMBOL (symbol
)->value
)
2931 || SOME_BUFFER_LOCAL_VALUEP (XSYMBOL (symbol
)->value
)
2932 || BUFFER_OBJFWDP (XSYMBOL (symbol
)->value
))
2934 Lisp_Object current_buffer
, binding_buffer
;
2936 /* For a local variable, record both the symbol and which
2937 buffer's value we are saving. */
2938 current_buffer
= Fcurrent_buffer ();
2939 binding_buffer
= current_buffer
;
2941 /* If the variable is not local in this buffer,
2942 we are saving the global value, so restore that. */
2943 if (NILP (Flocal_variable_p (symbol
, binding_buffer
)))
2944 binding_buffer
= Qnil
;
2946 = Fcons (symbol
, Fcons (binding_buffer
, current_buffer
));
2948 /* If SYMBOL is a per-buffer variable which doesn't have a
2949 buffer-local value here, make the `let' change the global
2950 value by changing the value of SYMBOL in all buffers not
2951 having their own value. This is consistent with what
2952 happens with other buffer-local variables. */
2953 if (NILP (binding_buffer
)
2954 && BUFFER_OBJFWDP (XSYMBOL (symbol
)->value
))
2957 Fset_default (symbol
, value
);
2962 specpdl_ptr
->symbol
= symbol
;
2965 if (BUFFER_OBJFWDP (ovalue
) || KBOARD_OBJFWDP (ovalue
))
2966 store_symval_forwarding (symbol
, ovalue
, value
, NULL
);
2968 set_internal (symbol
, value
, 0, 1);
2973 record_unwind_protect (function
, arg
)
2974 Lisp_Object (*function
) P_ ((Lisp_Object
));
2977 if (specpdl_ptr
== specpdl
+ specpdl_size
)
2979 specpdl_ptr
->func
= function
;
2980 specpdl_ptr
->symbol
= Qnil
;
2981 specpdl_ptr
->old_value
= arg
;
2986 unbind_to (count
, value
)
2990 int quitf
= !NILP (Vquit_flag
);
2991 struct gcpro gcpro1
;
2996 while (specpdl_ptr
!= specpdl
+ count
)
3000 if (specpdl_ptr
->func
!= 0)
3001 (*specpdl_ptr
->func
) (specpdl_ptr
->old_value
);
3002 /* Note that a "binding" of nil is really an unwind protect,
3003 so in that case the "old value" is a list of forms to evaluate. */
3004 else if (NILP (specpdl_ptr
->symbol
))
3005 Fprogn (specpdl_ptr
->old_value
);
3006 /* If the symbol is a list, it is really (SYMBOL BINDING_BUFFER
3007 . CURRENT_BUFFER) and it indicates we bound a variable that
3008 has buffer-local bindings. BINDING_BUFFER nil means that the
3009 variable had the default value when it was bound. */
3010 else if (CONSP (specpdl_ptr
->symbol
))
3012 Lisp_Object symbol
, buffer
;
3014 symbol
= XCAR (specpdl_ptr
->symbol
);
3015 buffer
= XCAR (XCDR (specpdl_ptr
->symbol
));
3017 /* Handle restoring a default value. */
3019 Fset_default (symbol
, specpdl_ptr
->old_value
);
3020 /* Handle restoring a value saved from a live buffer. */
3022 set_internal (symbol
, specpdl_ptr
->old_value
, XBUFFER (buffer
), 1);
3026 /* If variable has a trivial value (no forwarding), we can
3027 just set it. No need to check for constant symbols here,
3028 since that was already done by specbind. */
3029 if (!MISCP (XSYMBOL (specpdl_ptr
->symbol
)->value
))
3030 XSYMBOL (specpdl_ptr
->symbol
)->value
= specpdl_ptr
->old_value
;
3032 set_internal (specpdl_ptr
->symbol
, specpdl_ptr
->old_value
, 0, 1);
3036 if (NILP (Vquit_flag
) && quitf
)
3045 /* Get the value of symbol's global binding, even if that binding
3046 is not now dynamically visible. */
3049 top_level_value (symbol
)
3052 register struct specbinding
*ptr
= specpdl
;
3054 CHECK_SYMBOL (symbol
, 0);
3055 for (; ptr
!= specpdl_ptr
; ptr
++)
3057 if (EQ (ptr
->symbol
, symbol
))
3058 return ptr
->old_value
;
3060 return Fsymbol_value (symbol
);
3064 top_level_set (symbol
, newval
)
3065 Lisp_Object symbol
, newval
;
3067 register struct specbinding
*ptr
= specpdl
;
3069 CHECK_SYMBOL (symbol
, 0);
3070 for (; ptr
!= specpdl_ptr
; ptr
++)
3072 if (EQ (ptr
->symbol
, symbol
))
3074 ptr
->old_value
= newval
;
3078 return Fset (symbol
, newval
);
3083 DEFUN ("backtrace-debug", Fbacktrace_debug
, Sbacktrace_debug
, 2, 2, 0,
3084 "Set the debug-on-exit flag of eval frame LEVEL levels down to FLAG.\n\
3085 The debugger is entered when that frame exits, if the flag is non-nil.")
3087 Lisp_Object level
, flag
;
3089 register struct backtrace
*backlist
= backtrace_list
;
3092 CHECK_NUMBER (level
, 0);
3094 for (i
= 0; backlist
&& i
< XINT (level
); i
++)
3096 backlist
= backlist
->next
;
3100 backlist
->debug_on_exit
= !NILP (flag
);
3105 DEFUN ("backtrace", Fbacktrace
, Sbacktrace
, 0, 0, "",
3106 "Print a trace of Lisp function calls currently active.\n\
3107 Output stream used is value of `standard-output'.")
3110 register struct backtrace
*backlist
= backtrace_list
;
3114 extern Lisp_Object Vprint_level
;
3115 struct gcpro gcpro1
;
3117 XSETFASTINT (Vprint_level
, 3);
3124 write_string (backlist
->debug_on_exit
? "* " : " ", 2);
3125 if (backlist
->nargs
== UNEVALLED
)
3127 Fprin1 (Fcons (*backlist
->function
, *backlist
->args
), Qnil
);
3128 write_string ("\n", -1);
3132 tem
= *backlist
->function
;
3133 Fprin1 (tem
, Qnil
); /* This can QUIT */
3134 write_string ("(", -1);
3135 if (backlist
->nargs
== MANY
)
3137 for (tail
= *backlist
->args
, i
= 0;
3139 tail
= Fcdr (tail
), i
++)
3141 if (i
) write_string (" ", -1);
3142 Fprin1 (Fcar (tail
), Qnil
);
3147 for (i
= 0; i
< backlist
->nargs
; i
++)
3149 if (i
) write_string (" ", -1);
3150 Fprin1 (backlist
->args
[i
], Qnil
);
3153 write_string (")\n", -1);
3155 backlist
= backlist
->next
;
3158 Vprint_level
= Qnil
;
3163 DEFUN ("backtrace-frame", Fbacktrace_frame
, Sbacktrace_frame
, 1, 1, NULL
,
3164 "Return the function and arguments NFRAMES up from current execution point.\n\
3165 If that frame has not evaluated the arguments yet (or is a special form),\n\
3166 the value is (nil FUNCTION ARG-FORMS...).\n\
3167 If that frame has evaluated its arguments and called its function already,\n\
3168 the value is (t FUNCTION ARG-VALUES...).\n\
3169 A &rest arg is represented as the tail of the list ARG-VALUES.\n\
3170 FUNCTION is whatever was supplied as car of evaluated list,\n\
3171 or a lambda expression for macro calls.\n\
3172 If NFRAMES is more than the number of frames, the value is nil.")
3174 Lisp_Object nframes
;
3176 register struct backtrace
*backlist
= backtrace_list
;
3180 CHECK_NATNUM (nframes
, 0);
3182 /* Find the frame requested. */
3183 for (i
= 0; backlist
&& i
< XFASTINT (nframes
); i
++)
3184 backlist
= backlist
->next
;
3188 if (backlist
->nargs
== UNEVALLED
)
3189 return Fcons (Qnil
, Fcons (*backlist
->function
, *backlist
->args
));
3192 if (backlist
->nargs
== MANY
)
3193 tem
= *backlist
->args
;
3195 tem
= Flist (backlist
->nargs
, backlist
->args
);
3197 return Fcons (Qt
, Fcons (*backlist
->function
, tem
));
3205 DEFVAR_INT ("max-specpdl-size", &max_specpdl_size
,
3206 "*Limit on number of Lisp variable bindings & unwind-protects.\n\
3207 If Lisp code tries to make more than this many at once,\n\
3208 an error is signaled.");
3210 DEFVAR_INT ("max-lisp-eval-depth", &max_lisp_eval_depth
,
3211 "*Limit on depth in `eval', `apply' and `funcall' before error.\n\
3212 This limit is to catch infinite recursions for you before they cause\n\
3213 actual stack overflow in C, which would be fatal for Emacs.\n\
3214 You can safely make it considerably larger than its default value,\n\
3215 if that proves inconveniently small.");
3217 DEFVAR_LISP ("quit-flag", &Vquit_flag
,
3218 "Non-nil causes `eval' to abort, unless `inhibit-quit' is non-nil.\n\
3219 Typing C-g sets `quit-flag' non-nil, regardless of `inhibit-quit'.");
3222 DEFVAR_LISP ("inhibit-quit", &Vinhibit_quit
,
3223 "Non-nil inhibits C-g quitting from happening immediately.\n\
3224 Note that `quit-flag' will still be set by typing C-g,\n\
3225 so a quit will be signaled as soon as `inhibit-quit' is nil.\n\
3226 To prevent this happening, set `quit-flag' to nil\n\
3227 before making `inhibit-quit' nil.");
3228 Vinhibit_quit
= Qnil
;
3230 Qinhibit_quit
= intern ("inhibit-quit");
3231 staticpro (&Qinhibit_quit
);
3233 Qautoload
= intern ("autoload");
3234 staticpro (&Qautoload
);
3236 Qdebug_on_error
= intern ("debug-on-error");
3237 staticpro (&Qdebug_on_error
);
3239 Qmacro
= intern ("macro");
3240 staticpro (&Qmacro
);
3242 /* Note that the process handling also uses Qexit, but we don't want
3243 to staticpro it twice, so we just do it here. */
3244 Qexit
= intern ("exit");
3247 Qinteractive
= intern ("interactive");
3248 staticpro (&Qinteractive
);
3250 Qcommandp
= intern ("commandp");
3251 staticpro (&Qcommandp
);
3253 Qdefun
= intern ("defun");
3254 staticpro (&Qdefun
);
3256 Qand_rest
= intern ("&rest");
3257 staticpro (&Qand_rest
);
3259 Qand_optional
= intern ("&optional");
3260 staticpro (&Qand_optional
);
3262 DEFVAR_LISP ("stack-trace-on-error", &Vstack_trace_on_error
,
3263 "*Non-nil means automatically display a backtrace buffer\n\
3264 after any error that is handled by the editor command loop.\n\
3265 If the value is a list, an error only means to display a backtrace\n\
3266 if one of its condition symbols appears in the list.");
3267 Vstack_trace_on_error
= Qnil
;
3269 DEFVAR_LISP ("debug-on-error", &Vdebug_on_error
,
3270 "*Non-nil means enter debugger if an error is signaled.\n\
3271 Does not apply to errors handled by `condition-case' or those\n\
3272 matched by `debug-ignored-errors'.\n\
3273 If the value is a list, an error only means to enter the debugger\n\
3274 if one of its condition symbols appears in the list.\n\
3275 See also variable `debug-on-quit'.");
3276 Vdebug_on_error
= Qnil
;
3278 DEFVAR_LISP ("debug-ignored-errors", &Vdebug_ignored_errors
,
3279 "*List of errors for which the debugger should not be called.\n\
3280 Each element may be a condition-name or a regexp that matches error messages.\n\
3281 If any element applies to a given error, that error skips the debugger\n\
3282 and just returns to top level.\n\
3283 This overrides the variable `debug-on-error'.\n\
3284 It does not apply to errors handled by `condition-case'.");
3285 Vdebug_ignored_errors
= Qnil
;
3287 DEFVAR_BOOL ("debug-on-quit", &debug_on_quit
,
3288 "*Non-nil means enter debugger if quit is signaled (C-g, for example).\n\
3289 Does not apply if quit is handled by a `condition-case'.");
3292 DEFVAR_BOOL ("debug-on-next-call", &debug_on_next_call
,
3293 "Non-nil means enter debugger before next `eval', `apply' or `funcall'.");
3295 DEFVAR_BOOL ("debugger-may-continue", &debugger_may_continue
,
3296 "Non-nil means debugger may continue execution.\n\
3297 This is nil when the debugger is called under circumstances where it\n\
3298 might not be safe to continue.");
3299 debugger_may_continue
= 1;
3301 DEFVAR_LISP ("debugger", &Vdebugger
,
3302 "Function to call to invoke debugger.\n\
3303 If due to frame exit, args are `exit' and the value being returned;\n\
3304 this function's value will be returned instead of that.\n\
3305 If due to error, args are `error' and a list of the args to `signal'.\n\
3306 If due to `apply' or `funcall' entry, one arg, `lambda'.\n\
3307 If due to `eval' entry, one arg, t.");
3310 DEFVAR_LISP ("signal-hook-function", &Vsignal_hook_function
,
3311 "If non-nil, this is a function for `signal' to call.\n\
3312 It receives the same arguments that `signal' was given.\n\
3313 The Edebug package uses this to regain control.");
3314 Vsignal_hook_function
= Qnil
;
3316 Qmocklisp_arguments
= intern ("mocklisp-arguments");
3317 staticpro (&Qmocklisp_arguments
);
3318 DEFVAR_LISP ("mocklisp-arguments", &Vmocklisp_arguments
,
3319 "While in a mocklisp function, the list of its unevaluated args.");
3320 Vmocklisp_arguments
= Qt
;
3322 DEFVAR_LISP ("debug-on-signal", &Vdebug_on_signal
,
3323 "*Non-nil means call the debugger regardless of condition handlers.\n\
3324 Note that `debug-on-error', `debug-on-quit' and friends\n\
3325 still determine whether to handle the particular condition.");
3326 Vdebug_on_signal
= Qnil
;
3328 Vrun_hooks
= intern ("run-hooks");
3329 staticpro (&Vrun_hooks
);
3331 staticpro (&Vautoload_queue
);
3332 Vautoload_queue
= Qnil
;
3333 staticpro (&Vsignaling_function
);
3334 Vsignaling_function
= Qnil
;
3345 defsubr (&Sfunction
);
3347 defsubr (&Sdefmacro
);
3349 defsubr (&Sdefconst
);
3350 defsubr (&Suser_variable_p
);
3354 defsubr (&Smacroexpand
);
3357 defsubr (&Sunwind_protect
);
3358 defsubr (&Scondition_case
);
3360 defsubr (&Sinteractive_p
);
3361 defsubr (&Scommandp
);
3362 defsubr (&Sautoload
);
3365 defsubr (&Sfuncall
);
3366 defsubr (&Srun_hooks
);
3367 defsubr (&Srun_hook_with_args
);
3368 defsubr (&Srun_hook_with_args_until_success
);
3369 defsubr (&Srun_hook_with_args_until_failure
);
3370 defsubr (&Sfetch_bytecode
);
3371 defsubr (&Sbacktrace_debug
);
3372 defsubr (&Sbacktrace
);
3373 defsubr (&Sbacktrace_frame
);