home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / lucid / lemacs-19.6 / src / eval.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-02-14  |  64.8 KB  |  2,468 lines

  1. /* Evaluator for GNU Emacs Lisp interpreter.
  2.    Copyright (C) 1985-1993 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU Emacs.
  5.  
  6. GNU Emacs is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. GNU Emacs is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU Emacs; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. /* Debugging hack */
  21. int always_gc;
  22.  
  23.  
  24. #include "config.h"
  25. #include "lisp.h"
  26. #include <stdio.h>
  27. #include <setjmp.h>
  28.  
  29. #ifdef HAVE_X_WINDOWS
  30. #include "blockio.h"
  31. #endif
  32.  
  33. #ifndef standalone
  34. #include "commands.h"
  35. #else
  36. #define INTERACTIVE 1
  37. #endif
  38.  
  39. #include "backtrace.h"
  40.  
  41. struct backtrace *backtrace_list;
  42. struct catchtag *catchlist;
  43.  
  44. Lisp_Object Qautoload, Qmacro, Qexit, Qinteractive, Qcommandp, Qdefun;
  45. Lisp_Object Vquit_flag, Vinhibit_quit, Qinhibit_quit;
  46. Lisp_Object Qmocklisp_arguments, Vmocklisp_arguments, Qmocklisp;
  47. Lisp_Object Qand_rest, Qand_optional;
  48. Lisp_Object Qeval;
  49. Lisp_Object Qdebug_on_error;
  50.  
  51. Lisp_Object Vrun_hooks;
  52.  
  53. /* Non-nil means record all fset's and provide's, to be undone
  54.    if the file being autoloaded is not fully loaded.
  55.    They are recorded by being consed onto the front of Vautoload_queue:
  56.    (FUN . ODEF) for a defun, (OFEATURES . nil) for a provide.  */
  57.  
  58. Lisp_Object Vautoload_queue;
  59.  
  60. /* Current number of specbindings allocated in specpdl.  */
  61. static int specpdl_size;
  62.  
  63. /* Pointer to beginning of specpdl.  */
  64. struct specbinding *specpdl;
  65.  
  66. /* Pointer to first unused element in specpdl.  */
  67. struct specbinding *specpdl_ptr;
  68.  
  69. /* specpdl_ptr - specpdl.  */
  70. int specpdl_depth;
  71.  
  72. /* Maximum size allowed for specpdl allocation */
  73. int max_specpdl_size;
  74.  
  75. /* Depth in Lisp evaluations and function calls.  */
  76. int lisp_eval_depth;
  77.  
  78. /* Maximum allowed depth in Lisp evaluations and function calls.  */
  79. int max_lisp_eval_depth;
  80.  
  81. /* Nonzero means enter debugger before next function call */
  82. int debug_on_next_call;
  83.  
  84. /* List of conditions (non-nil atom means all) which cause a backtrace
  85.    if an error is handled by the command loop's error handler.  */
  86. Lisp_Object Vstack_trace_on_error;
  87.  
  88. /* List of conditions (non-nil atom means all) which enter the debugger
  89.    if an error is handled by the command loop's error handler.  */
  90. Lisp_Object Vdebug_on_error;
  91.  
  92. /* Nonzero means enter debugger if a quit signal
  93.  is handled by the command loop's error handler. */
  94. int debug_on_quit;
  95.  
  96. /* Nonzero means we are trying to enter the debugger.
  97.    This is to prevent recursive attempts.  */
  98. int entering_debugger;
  99.  
  100. Lisp_Object Vdebugger;
  101.  
  102. static Lisp_Object funcall_lambda (Lisp_Object fn, 
  103.                                    int nargs, Lisp_Object *args);
  104.  
  105. static Lisp_Object apply_lambda (Lisp_Object fun, Lisp_Object args, 
  106.                                  int evalflag);
  107.  
  108.  
  109. extern Lisp_Object ml_apply ();    /* Apply a mocklisp function to
  110.                       unevaluated argument list */
  111.  
  112.  
  113.  
  114. void
  115. init_eval_once ()
  116. {
  117.   specpdl_size = 50;
  118.   specpdl_depth = 0;
  119.   specpdl = (struct specbinding *)
  120.     xmalloc (specpdl_size * sizeof (struct specbinding));
  121.   max_specpdl_size = 600;
  122.   max_lisp_eval_depth = 200;
  123. }
  124.  
  125. void
  126. init_eval ()
  127. {
  128.   specpdl_ptr = specpdl;
  129.   specpdl_depth = 0;
  130.   catchlist = 0;
  131.   handlerlist = 0;
  132.   backtrace_list = 0;
  133.   Vquit_flag = Qnil;
  134.   debug_on_next_call = 0;
  135.   lisp_eval_depth = 0;
  136.   entering_debugger = 0;
  137. }
  138.  
  139. static Lisp_Object
  140. call_debugger (arg)
  141.      Lisp_Object arg;
  142. {
  143.   if (lisp_eval_depth + 20 > max_lisp_eval_depth)
  144.     max_lisp_eval_depth = lisp_eval_depth + 20;
  145.   if (specpdl_size + 40 > max_specpdl_size)
  146.     max_specpdl_size = specpdl_size + 40;
  147.   debug_on_next_call = 0;
  148.   entering_debugger = 1;
  149.   return apply1 (Vdebugger, arg);
  150. }
  151.  
  152. static void
  153. do_debug_on_call (code)
  154.      Lisp_Object code;
  155. {
  156.   debug_on_next_call = 0;
  157.   backtrace_list->debug_on_exit = 1;
  158.   call_debugger (list1 (code));
  159. }
  160.  
  161. static int
  162. wants_debugger (list, conditions)
  163.      Lisp_Object list, conditions;
  164. {
  165.   if (NILP (list))
  166.     return 0;
  167.   if (! CONSP (list))
  168.     return 1;
  169.  
  170.   while (CONSP (conditions))
  171.     {
  172.       Lisp_Object this, tail;
  173.       this = XCONS (conditions)->car;
  174.       for (tail = list; CONSP (tail); tail = XCONS (tail)->cdr)
  175.     if (EQ (XCONS (tail)->car, this))
  176.       return 1;
  177.       conditions = XCONS (conditions)->cdr;
  178.     }
  179.   return 0;
  180. }
  181.  
  182. /* Returns Qunbound if didn't call debugger */
  183. static Lisp_Object
  184. signal_call_debugger (conditions, sig, data)
  185.      Lisp_Object conditions, sig, data;
  186. {
  187.   if (wants_debugger (Vstack_trace_on_error, conditions))
  188.     internal_with_output_to_temp_buffer ("*Backtrace*", 
  189.                                          Fbacktrace,
  190.                                          Qnil,
  191.                                          Qnil);
  192.   if (!entering_debugger
  193.       && (EQ (sig, Qquit)
  194.           ? debug_on_quit
  195.           : wants_debugger (Vdebug_on_error, conditions)))
  196.   {
  197.     Lisp_Object val;
  198.     int count = specpdl_depth;
  199.  
  200.     specbind (Qdebug_on_error, Qnil);
  201.     val = call_debugger (list2 (Qerror, (Fcons (sig, data))));
  202.     return unbind_to (count, val);
  203.   }
  204.   /* Tell caller that debugger wasn't called */
  205.   return (Qunbound);
  206. }
  207.  
  208.  
  209.  
  210. /* NOTE!!! Every function that can call EVAL must protect its args
  211.    and temporaries from garbage collection while it needs them.
  212.    The definition of `For' shows what you have to do.  */
  213.  
  214. DEFUN ("or", For, Sor, 0, UNEVALLED, 0,
  215.   "Eval args until one of them yields non-nil, then return that value.\n\
  216. The remaining args are not evalled at all.\n\
  217. If all args return nil, return nil.")
  218.   (args)
  219.      Lisp_Object args;
  220. {
  221.   register Lisp_Object val;
  222.   Lisp_Object args_left;
  223.   struct gcpro gcpro1;
  224.  
  225.   if (NILP (args))
  226.     return Qnil;
  227.  
  228.   args_left = args;
  229.   GCPRO1 (args_left);
  230.  
  231.   do
  232.     {
  233.       val = Feval (Fcar (args_left));
  234.       if (!NILP (val))
  235.     break;
  236.       args_left = Fcdr (args_left);
  237.     }
  238.   while (!NILP (args_left));
  239.  
  240.   UNGCPRO;
  241.   return val;
  242. }
  243.  
  244. DEFUN ("and", Fand, Sand, 0, UNEVALLED, 0,
  245.   "Eval args until one of them yields nil, then return nil.\n\
  246. The remaining args are not evalled at all.\n\
  247. If no arg yields nil, return the last arg's value.")
  248.   (args)
  249.      Lisp_Object args;
  250. {
  251.   register Lisp_Object val;
  252.   Lisp_Object args_left;
  253.   struct gcpro gcpro1;
  254.  
  255.   if (NILP (args))
  256.     return Qt;
  257.  
  258.   args_left = args;
  259.   GCPRO1 (args_left);
  260.  
  261.   do
  262.     {
  263.       val = Feval (Fcar (args_left));
  264.       if (NILP (val))
  265.     break;
  266.       args_left = Fcdr (args_left);
  267.     }
  268.   while (!NILP (args_left));
  269.  
  270.   UNGCPRO;
  271.   return val;
  272. }
  273.  
  274. DEFUN ("if", Fif, Sif, 2, UNEVALLED, 0,
  275.   "(if COND THEN ELSE...): if COND yields non-nil, do THEN, else do ELSE...\n\
  276. Returns the value of THEN or the value of the last of the ELSE's.\n\
  277. THEN must be one expression, but ELSE... can be zero or more expressions.\n\
  278. If COND yields nil, and there are no ELSE's, the value is nil.")
  279.   (args)
  280.      Lisp_Object args;
  281. {
  282.   register Lisp_Object cond;
  283.   struct gcpro gcpro1;
  284.  
  285.   GCPRO1 (args);
  286.   cond = Feval (Fcar (args));
  287.   UNGCPRO;
  288.  
  289.   if (!NILP (cond))
  290.     return Feval (Fcar (Fcdr (args)));
  291.   return Fprogn (Fcdr (Fcdr (args)));
  292. }
  293.  
  294. DEFUN ("cond", Fcond, Scond, 0, UNEVALLED, 0,
  295.   "(cond CLAUSES...): try each clause until one succeeds.\n\
  296. Each clause looks like (CONDITION BODY...).  CONDITION is evaluated\n\
  297. and, if the value is non-nil, this clause succeeds:\n\
  298. then the expressions in BODY are evaluated and the last one's\n\
  299. value is the value of the cond-form.\n\
  300. If no clause succeeds, cond returns nil.\n\
  301. If a clause has one element, as in (CONDITION),\n\
  302. CONDITION's value if non-nil is returned from the cond-form.")
  303.   (args)
  304.      Lisp_Object args;
  305. {
  306.   register Lisp_Object clause, val;
  307.   struct gcpro gcpro1;
  308.  
  309.   val = Qnil;
  310.   GCPRO1 (args);
  311.   while (!NILP (args))
  312.     {
  313.       clause = Fcar (args);
  314.       val = Feval (Fcar (clause));
  315.       if (!NILP (val))
  316.     {
  317.       if (!EQ (XCONS (clause)->cdr, Qnil))
  318.         val = Fprogn (XCONS (clause)->cdr);
  319.       break;
  320.     }
  321.       args = XCONS (args)->cdr;
  322.     }
  323.   UNGCPRO;
  324.  
  325.   return val;
  326. }
  327.  
  328. DEFUN ("progn", Fprogn, Sprogn, 0, UNEVALLED, 0,
  329.   "(progn BODY...): eval BODY forms sequentially and return value of last one.")
  330.   (args)
  331.      Lisp_Object args;
  332. {
  333.   register Lisp_Object val, tem;
  334.   Lisp_Object args_left;
  335.   struct gcpro gcpro1;
  336.  
  337.   /* In Mocklisp code, symbols at the front of the progn arglist
  338.    are to be bound to zero. */
  339.   if (!EQ (Vmocklisp_arguments, Qt))
  340.     {
  341.       val = make_number (0);
  342.       while (!NILP (args) && (tem = Fcar (args), SYMBOLP (tem)))
  343.     {
  344.       QUIT;
  345.       specbind (tem, val), args = Fcdr (args);
  346.     }
  347.     }
  348.  
  349.   if (NILP (args))
  350.     return Qnil;
  351.  
  352.   args_left = args;
  353.   GCPRO1 (args_left);
  354.  
  355.   do
  356.     {
  357.       val = Feval (Fcar (args_left));
  358.       args_left = Fcdr (args_left);
  359.     }
  360.   while (!NILP (args_left));
  361.  
  362.   UNGCPRO;
  363.   return val;
  364. }
  365.  
  366. DEFUN ("prog1", Fprog1, Sprog1, 1, UNEVALLED, 0,
  367.   "(prog1 FIRST BODY...): eval FIRST and BODY sequentially; value from FIRST.\n\
  368. The value of FIRST is saved during the evaluation of the remaining args,\n\
  369. whose values are discarded.")
  370.   (args)
  371.      Lisp_Object args;
  372. {
  373.   Lisp_Object val;
  374.   register Lisp_Object args_left;
  375.   struct gcpro gcpro1, gcpro2;
  376.   register int argnum = 0;
  377.  
  378.   if (NILP (args))
  379.     return Qnil;
  380.  
  381.   args_left = args;
  382.   val = Qnil;
  383.   GCPRO2 (args, val);
  384.  
  385.   do
  386.     {
  387.       if (!(argnum++))
  388.         val = Feval (Fcar (args_left));
  389.       else
  390.     Feval (Fcar (args_left));
  391.       args_left = Fcdr (args_left);
  392.     }
  393.   while (!NILP (args_left));
  394.  
  395.   UNGCPRO;
  396.   return val;
  397. }
  398.  
  399. DEFUN ("prog2", Fprog2, Sprog2, 2, UNEVALLED, 0,
  400.   "(prog1 X Y BODY...): eval X, Y and BODY sequentially; value from Y.\n\
  401. The value of Y is saved during the evaluation of the remaining args,\n\
  402. whose values are discarded.")
  403.   (args)
  404.      Lisp_Object args;
  405. {
  406.   Lisp_Object val;
  407.   register Lisp_Object args_left;
  408.   struct gcpro gcpro1, gcpro2;
  409.   register int argnum = -1;
  410.  
  411.   val = Qnil;
  412.  
  413.   if (NILP (args))
  414.     return Qnil;
  415.  
  416.   args_left = args;
  417.   val = Qnil;
  418.   GCPRO2 (args, val);
  419.  
  420.   do
  421.     {
  422.       if (!(argnum++))
  423.         val = Feval (Fcar (args_left));
  424.       else
  425.     Feval (Fcar (args_left));
  426.       args_left = Fcdr (args_left);
  427.     }
  428.   while (!NILP (args_left));
  429.  
  430.   UNGCPRO;
  431.   return val;
  432. }
  433.  
  434. DEFUN ("setq", Fsetq, Ssetq, 0, UNEVALLED, 0,
  435.   "(setq SYM VAL SYM VAL ...): set each SYM to the value of its VAL.\n\
  436. The SYMs are not evaluated.  Thus (setq x y) sets x to the value of y.\n\
  437. Each SYM is set before the next VAL is computed.")
  438.   (args)
  439.      Lisp_Object args;
  440. {
  441.   register Lisp_Object args_left;
  442.   register Lisp_Object val, sym;
  443.   struct gcpro gcpro1;
  444.  
  445.   if (NILP (args))
  446.     return Qnil;
  447.  
  448.   args_left = args;
  449.   GCPRO1 (args);
  450.  
  451.   do
  452.     {
  453.       val = Feval (Fcar (Fcdr (args_left)));
  454.       sym = Fcar (args_left);
  455.       Fset (sym, val);
  456.       args_left = Fcdr (Fcdr (args_left));
  457.     }
  458.   while (!NILP (args_left));
  459.  
  460.   UNGCPRO;
  461.   return val;
  462. }
  463.      
  464. DEFUN ("quote", Fquote, Squote, 1, UNEVALLED, 0,
  465.   "Return the argument, without evaluating it.  `(quote x)' yields `x'.")
  466.   (args)
  467.      Lisp_Object args;
  468. {
  469.   return Fcar (args);
  470. }
  471.      
  472. DEFUN ("function", Ffunction, Sfunction, 1, UNEVALLED, 0,
  473.   "Like `quote', but preferred for objects which are functions.\n\
  474. In byte compilation, `function' causes its argument to be compiled.\n\
  475. `quote' cannot do that.")
  476.   (args)
  477.      Lisp_Object args;
  478. {
  479.   return Fcar (args);
  480. }
  481.  
  482. #ifndef standalone
  483. DEFUN ("interactive-p", Finteractive_p, Sinteractive_p, 0, 0, 0,
  484.   "Return t if function in which this appears was called interactively.\n\
  485. This means that the function was called with call-interactively (which\n\
  486. includes being called as the binding of a key)\n\
  487. and input is currently coming from the keyboard (not in keyboard macro).")
  488.   ()
  489. {
  490.   register struct backtrace *btp;
  491.   register Lisp_Object fun;
  492.  
  493.   if (!INTERACTIVE)
  494.     return Qnil;
  495.  
  496.   /*  Unless the object was compiled, skip the frame of interactive-p itself
  497.       (if interpreted) or the frame of byte-code (if called from
  498.       compiled function).  */
  499.   btp = backtrace_list;
  500.   if (! (COMPILEDP (*btp->function)))
  501.     btp = btp->next;
  502.   for (;
  503.        btp && (btp->nargs == UNEVALLED
  504.            || EQ (*btp->function, Qbytecode));
  505.        btp = btp->next)
  506.     {}
  507.   /* btp now points at the frame of the innermost function
  508.      that DOES eval its args.
  509.      If it is a built-in function (such as load or eval-region)
  510.      return nil.  */
  511.   fun = Findirect_function (*btp->function);
  512.   /* Beats me why this is necessary, but it is */
  513.   if (btp && EQ (*btp->function, Qcall_interactively))
  514.     return Qt;
  515.   if (SUBRP (fun))
  516.     return Qnil;
  517.   /* btp points to the frame of a Lisp function that called interactive-p.
  518.      Return t if that function was called interactively.  */
  519.   if (btp && btp->next && EQ (*btp->next->function, Qcall_interactively))
  520.     return Qt;
  521.   return Qnil;
  522. }
  523. #endif /* not standalone */
  524.  
  525. DEFUN ("defun", Fdefun, Sdefun, 2, UNEVALLED, 0,
  526.   "(defun NAME ARGLIST [DOCSTRING] BODY...): define NAME as a function.\n\
  527. The definition is (lambda ARGLIST [DOCSTRING] BODY...).\n\
  528. See also the function `interactive'.")
  529.   (args)
  530.      Lisp_Object args;
  531. {
  532.   register Lisp_Object fn_name;
  533.   register Lisp_Object defn;
  534.  
  535.   fn_name = Fcar (args);
  536.   defn = Fcons (Qlambda, Fcdr (args));
  537.   if (!NILP (Vpurify_flag))
  538.     defn = Fpurecopy (defn);
  539.   Ffset (fn_name, defn);
  540.   return fn_name;
  541. }
  542.  
  543. DEFUN ("defmacro", Fdefmacro, Sdefmacro, 2, UNEVALLED, 0,
  544.   "(defmacro NAME ARGLIST [DOCSTRING] BODY...): define NAME as a macro.\n\
  545. The definition is (macro lambda ARGLIST [DOCSTRING] BODY...).\n\
  546. When the macro is called, as in (NAME ARGS...),\n\
  547. the function (lambda ARGLIST BODY...) is applied to\n\
  548. the list ARGS... as it appears in the expression,\n\
  549. and the result should be a form to be evaluated instead of the original.")
  550.   (args)
  551.      Lisp_Object args;
  552. {
  553.   register Lisp_Object fn_name;
  554.   register Lisp_Object defn;
  555.  
  556.   fn_name = Fcar (args);
  557.   defn = Fcons (Qmacro, Fcons (Qlambda, Fcdr (args)));
  558.   if (!NILP (Vpurify_flag))
  559.     defn = Fpurecopy (defn);
  560.   Ffset (fn_name, defn);
  561.   return fn_name;
  562. }
  563.  
  564. DEFUN ("defvar", Fdefvar, Sdefvar, 1, UNEVALLED, 0,
  565.   "(defvar SYMBOL INITVALUE DOCSTRING): define SYMBOL as a variable.\n\
  566. You are not required to define a variable in order to use it,\n\
  567. but the definition can supply documentation and an initial value\n\
  568. in a way that tags can recognize.\n\n\
  569. INITVALUE is evaluated, and used to set SYMBOL, only if SYMBOL's value is void.\n\
  570. If SYMBOL is buffer-local, its default value is what is set;\n\
  571.  buffer-local values are not affected.\n\
  572. INITVALUE and DOCSTRING are optional.\n\
  573. If DOCSTRING starts with *, this variable is identified as a user option.\n\
  574.  This means that M-x set-variable and M-x edit-options recognize it.\n\
  575. If INITVALUE is missing, SYMBOL's value is not set.")
  576.   (args)
  577.      Lisp_Object args;
  578. {
  579.   register Lisp_Object sym, tem;
  580.  
  581.   sym = Fcar (args);
  582.   tem = Fcdr (args);
  583.   if (!NILP (tem))
  584.     {
  585.       tem = Fdefault_boundp (sym);
  586.       if (NILP (tem))
  587.     Fset_default (sym, Feval (Fcar (Fcdr (args))));
  588.     }
  589.   tem = Fcar (Fcdr (Fcdr (args)));
  590.   if (!NILP (tem))
  591.     {
  592.       if (!NILP (Vpurify_flag))
  593.     tem = Fpurecopy (tem);
  594.       Fput (sym, Qvariable_documentation, tem);
  595.     }
  596.   return sym;
  597. }
  598.  
  599. DEFUN ("defconst", Fdefconst, Sdefconst, 2, UNEVALLED, 0,
  600.   "(defconst SYMBOL INITVALUE DOCSTRING): define SYMBOL as a constant variable.\n\
  601. The intent is that programs do not change this value, but users may.\n\
  602. Always sets the value of SYMBOL to the result of evalling INITVALUE.\n\
  603. If SYMBOL is buffer-local, its default value is what is set;\n\
  604.  buffer-local values are not affected.\n\
  605. DOCSTRING is optional.\n\
  606. If DOCSTRING starts with *, this variable is identified as a user option.\n\
  607.  This means that M-x set-variable and M-x edit-options recognize it.\n\n\
  608. Note: do not use `defconst' for user options in libraries that are not\n\
  609. normally loaded, since it is useful for users to be able to specify\n\
  610. their own values for such variables before loading the library.\n\
  611. Since `defconst' unconditionally assigns the variable,\n\
  612. it would override the user's choice.")
  613.   (args)
  614.      Lisp_Object args;
  615. {
  616.   register Lisp_Object sym, tem;
  617.  
  618.   sym = Fcar (args);
  619.   Fset_default (sym, Feval (Fcar (Fcdr (args))));
  620.   tem = Fcar (Fcdr (Fcdr (args)));
  621.   if (!NILP (tem))
  622.     {
  623.       if (!NILP (Vpurify_flag))
  624.     tem = Fpurecopy (tem);
  625.       Fput (sym, Qvariable_documentation, tem);
  626.     }
  627.   return sym;
  628. }
  629.  
  630. DEFUN ("user-variable-p", Fuser_variable_p, Suser_variable_p, 1, 1, 0,
  631.   "Returns t if VARIABLE is intended to be set and modified by users.\n\
  632. \(The alternative is a variable used internally in a Lisp program.)\n\
  633. Determined by whether the first character of the documentation\n\
  634. for the variable is \"*\"")
  635.   (variable)
  636.      Lisp_Object variable;
  637. {
  638.   Lisp_Object documentation;
  639.   
  640.   documentation = Fget (variable, Qvariable_documentation);
  641.   if (FIXNUMP (documentation) && XINT (documentation) < 0)
  642.     return Qt;
  643.   if ((STRINGP (documentation)) &&
  644.       ((unsigned char) XSTRING (documentation)->data[0] == '*'))
  645.     return Qt;
  646.   return Qnil;
  647. }  
  648.  
  649. DEFUN ("let*", FletX, SletX, 1, UNEVALLED, 0,
  650.   "(let* VARLIST BODY...): bind variables according to VARLIST then eval BODY.\n\
  651. The value of the last form in BODY is returned.\n\
  652. Each element of VARLIST is a symbol (which is bound to nil)\n\
  653. or a list (SYMBOL VALUEFORM) (which binds SYMBOL to the value of VALUEFORM).\n\
  654. Each VALUEFORM can refer to the symbols already bound by this VARLIST.")
  655.   (args)
  656.      Lisp_Object args;
  657. {
  658.   Lisp_Object varlist, val, elt;
  659.   int count = specpdl_depth;
  660.   struct gcpro gcpro1, gcpro2, gcpro3;
  661.  
  662.   GCPRO3 (args, elt, varlist);
  663.  
  664.   varlist = Fcar (args);
  665.   while (!NILP (varlist))
  666.     {
  667.       QUIT;
  668.       elt = Fcar (varlist);
  669.       if (SYMBOLP (elt))
  670.     specbind (elt, Qnil);
  671.       else if (! NILP (Fcdr (Fcdr (elt))))
  672.     signal_error (Qerror,
  673.                       list2 (build_string (
  674.                  "`let' bindings can have only one value-form"),
  675.                              elt));
  676.       else
  677.     {
  678.       val = Feval (Fcar (Fcdr (elt)));
  679.       specbind (Fcar (elt), val);
  680.     }
  681.       varlist = Fcdr (varlist);
  682.     }
  683.   UNGCPRO;
  684.   val = Fprogn (Fcdr (args));
  685.   return unbind_to (count, val);
  686. }
  687.  
  688. DEFUN ("let", Flet, Slet, 1, UNEVALLED, 0,
  689.   "(let VARLIST BODY...): bind variables according to VARLIST then eval BODY.\n\
  690. The value of the last form in BODY is returned.\n\
  691. Each element of VARLIST is a symbol (which is bound to nil)\n\
  692. or a list (SYMBOL VALUEFORM) (which binds SYMBOL to the value of VALUEFORM).\n\
  693. All the VALUEFORMs are evalled before any symbols are bound.")
  694.   (args)
  695.      Lisp_Object args;
  696. {
  697.   Lisp_Object *temps, tem;
  698.   register Lisp_Object elt, varlist;
  699.   int count = specpdl_depth;
  700.   register int argnum;
  701.   struct gcpro gcpro1, gcpro2;
  702.  
  703.   varlist = Fcar (args);
  704.  
  705.   /* Make space to hold the values to give the bound variables */
  706.   elt = Flength (varlist);
  707.   temps = (Lisp_Object *) alloca (XFASTINT (elt) * sizeof (Lisp_Object));
  708.  
  709.   /* Compute the values and store them in `temps' */
  710.  
  711.   GCPRO2 (args, *temps);
  712.   gcpro2.nvars = 0;
  713.  
  714.   for (argnum = 0; !NILP (varlist); varlist = Fcdr (varlist))
  715.     {
  716.       QUIT;
  717.       elt = Fcar (varlist);
  718.       if (SYMBOLP (elt))
  719.     temps [argnum++] = Qnil;
  720.       else if (! NILP (Fcdr (Fcdr (elt))))
  721.     signal_error (Qerror,
  722.                       list2 (build_string (
  723.                  "`let' bindings can have only one value-form"),
  724.                              elt));
  725.       else
  726.     temps [argnum++] = Feval (Fcar (Fcdr (elt)));
  727.       gcpro2.nvars = argnum;
  728.     }
  729.   UNGCPRO;
  730.  
  731.   varlist = Fcar (args);
  732.   for (argnum = 0; !NILP (varlist); varlist = Fcdr (varlist))
  733.     {
  734.       elt = Fcar (varlist);
  735.       tem = temps[argnum++];
  736.       if (SYMBOLP (elt))
  737.     specbind (elt, tem);
  738.       else
  739.     specbind (Fcar (elt), tem);
  740.     }
  741.  
  742.   elt = Fprogn (Fcdr (args));
  743.   return unbind_to (count, elt);
  744. }
  745.  
  746. DEFUN ("while", Fwhile, Swhile, 1, UNEVALLED, 0,
  747.   "(while TEST BODY...): if TEST yields non-nil, eval BODY... and repeat.\n\
  748. The order of execution is thus TEST, BODY, TEST, BODY and so on\n\
  749. until TEST returns nil.")
  750.   (args)
  751.      Lisp_Object args;
  752. {
  753.   Lisp_Object test, body, tem;
  754.   struct gcpro gcpro1, gcpro2;
  755.  
  756.   GCPRO2 (test, body);
  757.  
  758.   test = Fcar (args);
  759.   body = Fcdr (args);
  760.   while (tem = Feval (test), !NILP (tem))
  761.     {
  762.       QUIT;
  763.       Fprogn (body);
  764.     }
  765.  
  766.   UNGCPRO;
  767.   return Qnil;
  768. }
  769.  
  770. DEFUN ("macroexpand", Fmacroexpand, Smacroexpand, 1, 2, 0,
  771.   "Return result of expanding macros at top level of FORM.\n\
  772. If FORM is not a macro call, it is returned unchanged.\n\
  773. Otherwise, the macro is expanded and the expansion is considered\n\
  774. in place of FORM.  When a non-macro-call results, it is returned.\n\n\
  775. The second optional arg ENVIRONMENT species an environment of macro\n\
  776. definitions to shadow the loaded ones for use in file byte-compilation.")
  777.   (form, env)
  778.      register Lisp_Object form;
  779.      Lisp_Object env;
  780. {
  781.   /* With cleanups from Hallvard Furuseth.  */
  782.   register Lisp_Object expander, sym, def, tem;
  783.  
  784.   while (1)
  785.     {
  786.       /* Come back here each time we expand a macro call,
  787.      in case it expands into another macro call.  */
  788.       if (!CONSP (form))
  789.     break;
  790.       /* Set SYM, give DEF and TEM right values in case SYM is not a symbol. */
  791.       def = sym = XCONS (form)->car;
  792.       tem = Qnil;
  793.       /* Trace symbols aliases to other symbols
  794.      until we get a symbol that is not an alias.  */
  795.       while (SYMBOLP (def))
  796.     {
  797.       QUIT;
  798.       sym = def;
  799.       tem = Fassq (sym, env);
  800.       if (NILP (tem))
  801.         {
  802.           def = XSYMBOL (sym)->function;
  803.           if (!EQ (def, Qunbound))
  804.         continue;
  805.         }
  806.       break;
  807.     }
  808.       /* Right now TEM is the result from SYM in ENV,
  809.      and if TEM is nil then DEF is SYM's function definition.  */
  810.       if (NILP (tem))
  811.     {
  812.       /* SYM is not mentioned in ENV.
  813.          Look at its function definition.  */
  814.       if (EQ (def, Qunbound)
  815.           || !CONSP (def))
  816.         /* Not defined or definition not suitable */
  817.         break;
  818.       if (EQ (XCONS (def)->car, Qautoload))
  819.         {
  820.           /* Autoloading function: will it be a macro when loaded?  */
  821.           tem = Fcar (Fnthcdr (make_number (4), def));
  822.           if (NILP (tem))
  823.         break;
  824.           /* Yes, load it and try again.  */
  825.           do_autoload (def, sym);
  826.           continue;
  827.         }
  828.       else if (!EQ (XCONS (def)->car, Qmacro))
  829.         break;
  830.       else expander = XCONS (def)->cdr;
  831.     }
  832.       else
  833.     {
  834.       expander = XCONS (tem)->cdr;
  835.       if (NILP (expander))
  836.         break;
  837.     }
  838.       form = apply1 (expander, XCONS (form)->cdr);
  839.     }
  840.   return form;
  841. }
  842.  
  843. DEFUN ("catch", Fcatch, Scatch, 1, UNEVALLED, 0,
  844.   "(catch TAG BODY...): eval BODY allowing nonlocal exits using `throw'.\n\
  845. TAG is evalled to get the tag to use.  Then the BODY is executed.\n\
  846. Within BODY, (throw TAG) with same tag exits BODY and exits this `catch'.\n\
  847. If no throw happens, `catch' returns the value of the last BODY form.\n\
  848. If a throw happens, it specifies the value to return from `catch'.")
  849.   (args)
  850.      Lisp_Object args;
  851. {
  852.   register Lisp_Object tag;
  853.   struct gcpro gcpro1;
  854.  
  855.   GCPRO1 (args);
  856.   tag = Feval (Fcar (args));
  857.   UNGCPRO;
  858.   return internal_catch (tag, Fprogn, Fcdr (args));
  859. }
  860.  
  861. /* Set up a catch, then call C function FUNC on argument ARG.
  862.    FUNC should return a Lisp_Object.
  863.    This is how catches are done from within C code. */
  864.  
  865. Lisp_Object
  866. internal_catch (tag, func, arg)
  867.      Lisp_Object tag;
  868.      Lisp_Object (*func) (Lisp_Object);
  869.      Lisp_Object arg;
  870. {
  871.   /* This structure is made part of the chain `catchlist'.  */
  872.   struct catchtag c;
  873.  
  874.   /* Fill in the components of c, and put it on the list.  */
  875.   c.next = catchlist;
  876.   c.tag = tag;
  877.   c.val = Qnil;
  878.   c.backlist = backtrace_list;
  879.   c.handlerlist = handlerlist;
  880.   c.lisp_eval_depth = lisp_eval_depth;
  881.   c.pdlcount = specpdl_depth;
  882.   c.gcpro = gcprolist;
  883.   catchlist = &c;
  884.  
  885.   /* Call FUNC.  */
  886.   if (! _setjmp (c.jmp))
  887.     c.val = (*func) (arg);
  888.  
  889.   /* Throw works by a longjmp that comes right here.  */
  890.   catchlist = c.next;
  891.   return c.val;
  892. }
  893.  
  894. /* Unwind the specbind, catch, and handler stacks back to CATCH, and
  895.    jump to that CATCH, returning VALUE as the value of that catch.
  896.  
  897.    This is the guts Fthrow and Fsignal; they differ only in the way
  898.    they choose the catch tag to throw to.  A catch tag for a
  899.    condition-case form has a TAG of Qnil.
  900.  
  901.    Before each catch is discarded, unbind all special bindings and
  902.    execute all unwind-protect clauses made above that catch.  Unwind
  903.    the handler stack as we go, so that the proper handlers are in
  904.    effect for each unwind-protect clause we run.  At the end, restore
  905.    some static info saved in CATCH, and longjmp to the location
  906.    specified in the
  907.  
  908.    This is used for correct unwinding in Fthrow and Fsignal.  */
  909.  
  910. static void
  911. unwind_to_catch (catch, value)
  912.      struct catchtag *catch;
  913.      Lisp_Object value;
  914. {
  915.   register int last_time;
  916.  
  917.   /* Save the value in the tag.  */
  918.   catch->val = value;
  919.  
  920.   do
  921.     {
  922.       last_time = catchlist == catch;
  923.       /* Unwind the specpdl stack, and then restore the proper set of
  924.          handlers.  */
  925.       unbind_to (catchlist->pdlcount, Qnil);
  926.       handlerlist = catchlist->handlerlist;
  927.       catchlist = catchlist->next;
  928.     }
  929.   while (! last_time);
  930.  
  931.   gcprolist = catch->gcpro;
  932.   backtrace_list = catch->backlist;
  933.   lisp_eval_depth = catch->lisp_eval_depth;
  934.   _longjmp (catch->jmp, 1);
  935. }
  936.  
  937. DEFUN ("throw", Fthrow, Sthrow, 2, 2, 0,
  938.   "(throw TAG VALUE): throw to the catch for TAG and return VALUE from it.\n\
  939. Both TAG and VALUE are evalled.")
  940.   (tag, val)
  941.      register Lisp_Object tag, val;
  942. {
  943.   register struct catchtag *c;
  944.  
  945.   while (1)
  946.     {
  947.       if (!NILP (tag))
  948.     for (c = catchlist; c; c = c->next)
  949.       {
  950.         if (EQ (c->tag, tag))
  951.           unwind_to_catch (c, val);
  952.       }
  953.       tag = Fsignal (Qno_catch, list2 (tag, val));
  954.     }
  955.   /* getting tired of compilation warnings */
  956.   return Qnil;
  957. }
  958.  
  959.  
  960. DEFUN ("unwind-protect", Funwind_protect, Sunwind_protect, 1, UNEVALLED, 0,
  961.   "Do BODYFORM, protecting with UNWINDFORMS.\n\
  962. Usage looks like (unwind-protect BODYFORM UNWINDFORMS...).\n\
  963. If BODYFORM completes normally, its value is returned\n\
  964. after executing the UNWINDFORMS.\n\
  965. If BODYFORM exits nonlocally, the UNWINDFORMS are executed anyway.")
  966.   (args)
  967.      Lisp_Object args;
  968. {
  969.   Lisp_Object val;
  970.   int count = specpdl_depth;
  971.  
  972.   record_unwind_protect (0, Fcdr (args));
  973.   val = Feval (Fcar (args));
  974.   return unbind_to (count, val);  
  975. }
  976.  
  977. /* Chain of condition handlers currently in effect.
  978.    The elements of this chain are contained in the stack frames
  979.    of Fcondition_case and internal_condition_case.
  980.    When an error is signaled (by calling Fsignal, below),
  981.    this chain is searched for an element that applies.  */
  982.  
  983. struct handler *handlerlist;
  984.  
  985. /* Split out from condition_case_3 so that primitive C callers
  986.    don't have to cons up a lisp handler form to be evaluated. */
  987. Lisp_Object
  988. condition_case_1 (Lisp_Object handlers,
  989.                   Lisp_Object (*bfun) (Lisp_Object barg),
  990.                   Lisp_Object barg,
  991.                   Lisp_Object (*hfun) (Lisp_Object val, Lisp_Object harg),
  992.                   Lisp_Object harg)
  993. {
  994.   struct catchtag c;
  995.   struct handler h;
  996.  
  997.   c.tag = Qnil;
  998.   c.val = Qnil;
  999.   c.backlist = backtrace_list;
  1000.   c.handlerlist = handlerlist;
  1001.   c.lisp_eval_depth = lisp_eval_depth;
  1002.   c.pdlcount = specpdl_depth;
  1003.   c.gcpro = gcprolist;
  1004.   if (_setjmp (c.jmp))
  1005.     {
  1006.       return ((*hfun) (c.val, harg));
  1007.     }
  1008.   c.next = catchlist;
  1009.   catchlist = &c;
  1010.   h.handlers = handlers;
  1011.   h.handler_arg = harg;         /* Must record this for GC */
  1012.   
  1013.   h.next = handlerlist;
  1014.   h.tag = &c;
  1015.   handlerlist = &h;
  1016.  
  1017.   barg = ((*bfun) (barg));
  1018.   catchlist = c.next;
  1019.   handlerlist = h.next;
  1020.   return barg;
  1021. }
  1022.  
  1023. static Lisp_Object
  1024. run_condition_case_handlers (Lisp_Object val, Lisp_Object var)
  1025. {
  1026.   int speccount = specpdl_depth;
  1027.  
  1028.   if (!NILP (var))
  1029.     specbind (var, Fcar (val));
  1030.   val = Fprogn (Fcdr (val));
  1031.   return unbind_to (speccount, val);
  1032. }
  1033.  
  1034.  
  1035. /* Here for bytecode to call non-consfully */
  1036. Lisp_Object
  1037. Fcondition_case_3 (Lisp_Object bodyform, 
  1038.                    Lisp_Object var, Lisp_Object handlers)
  1039. {
  1040.   Lisp_Object val;
  1041.  
  1042.   CHECK_SYMBOL (var, 0);
  1043.  
  1044.   for (val = handlers; ! NILP (val); val = Fcdr (val))
  1045.     {
  1046.       Lisp_Object tem;
  1047.       tem = Fcar (val);
  1048.       if ((!NILP (tem)) 
  1049.           && (!CONSP (tem) || (!SYMBOLP (XCONS (tem)->car))))
  1050.     error ("Invalid condition handler", tem);
  1051.     }
  1052.  
  1053.   return condition_case_1 (handlers, 
  1054.                            Feval, bodyform,
  1055.                            run_condition_case_handlers,
  1056.                            var);
  1057. }
  1058.  
  1059.  
  1060.  
  1061. DEFUN ("condition-case", Fcondition_case, Scondition_case, 2, UNEVALLED, 0,
  1062.   "Regain control when an error is signaled.\n\
  1063. Usage looks like (condition-case VAR BODYFORM HANDLERS...).\n\
  1064. executes BODYFORM and returns its value if no error happens.\n\
  1065. Each element of HANDLERS looks like (CONDITION-NAME BODY...)\n\
  1066. where the BODY is made of Lisp expressions.\n\n\
  1067. A handler is applicable to an error\n\
  1068. if CONDITION-NAME is one of the error's condition names.\n\
  1069. If an error happens, the first applicable handler is run.\n\
  1070. \n\
  1071. When a handler handles an error,\n\
  1072. control returns to the condition-case and the handler BODY... is executed\n\
  1073. with VAR bound to (SIGNALED-CONDITIONS . SIGNAL-DATA).\n\
  1074. VAR may be nil; then you do not get access to the signal information.\n\
  1075. \n\
  1076. The value of the last BODY form is returned from the condition-case.\n\
  1077. See also the function `signal' for more info.")
  1078.   (args)
  1079.      Lisp_Object args;
  1080. {
  1081.   return Fcondition_case_3 (Fcar (Fcdr (args)),
  1082.                             Fcar (args),
  1083.                             Fcdr (Fcdr (args)));
  1084.  
  1085.  
  1086. extern int in_display;
  1087.  
  1088. DEFUN ("signal", Fsignal, Ssignal, 2, 2, 0,
  1089.   "Signal an error.  Args are SIGNAL-NAME, and associated DATA.\n\
  1090. A signal name is a symbol with an `error-conditions' property\n\
  1091. that is a list of condition names.\n\
  1092. A handler for any of those names will get to handle this signal.\n\
  1093. The symbol `error' should normally be one of them.\n\
  1094. \n\
  1095. DATA should be a list.  Its elements are printed as part of the error message.\n\
  1096. If the signal is handled, DATA is made available to the handler.\n\
  1097. See also the function `condition-case'.")
  1098.   (sig, data)
  1099.      Lisp_Object sig, data;
  1100. {
  1101.   register struct handler *allhandlers = handlerlist;
  1102.   Lisp_Object conditions;
  1103.   extern int gc_in_progress;
  1104.   extern int waiting_for_input;
  1105.  
  1106.   immediate_quit = 0;
  1107.   if (gc_in_progress || waiting_for_input)
  1108.     abort ();
  1109.  
  1110.   in_display = 0;        /* Otherwise, we are hosed */
  1111.   TOTALLY_UNBLOCK_INPUT;
  1112.  
  1113.   conditions = Fget (sig, Qerror_conditions);
  1114.  
  1115.   for (; handlerlist; handlerlist = handlerlist->next)
  1116.     {
  1117.       register Lisp_Object handlers = handlerlist->handlers;
  1118.  
  1119.       /* t is used by handlers for all conditions, set up by C code. 
  1120.        *  debugger is not called even if debug_on_error */
  1121.       if (EQ (handlers, Qt))
  1122.       {
  1123.         struct handler *h = handlerlist;
  1124.         handlerlist = allhandlers;
  1125.         /* Doesn't return */
  1126.         unwind_to_catch (h->tag, Fcons (sig, data));
  1127.       }
  1128.       /* >>> compatibility kludge for C command-loop in keyboard.c */
  1129.       /* error is used similarly, but means display a backtrace too */
  1130.       else if (EQ (handlers, Qerror))
  1131.       {
  1132.         Lisp_Object tem;
  1133.         tem = signal_call_debugger (conditions, sig, data);
  1134.         if (EQ (tem, Qunbound))
  1135.         {
  1136.           struct handler *h = handlerlist;
  1137.           handlerlist = allhandlers;
  1138.           /* Doesn't return */
  1139.           unwind_to_catch (h->tag, Fcons (sig, data));
  1140.         }
  1141.         else
  1142.           /* Have called debugger; return value to signaller  */
  1143.           return (tem);
  1144.       }
  1145.       else
  1146.       {
  1147.         register Lisp_Object h;
  1148.  
  1149.         for (h = handlers; CONSP (h); h = Fcdr (h))
  1150.         {
  1151.           Lisp_Object clause = Fcar (h);
  1152.           Lisp_Object tem = Fcar (clause);
  1153.           if (!EQ (tem, Qt))
  1154.             /* (condition-case c # (t c)) catches -all- signals
  1155.              *   Use with caution! */
  1156.             tem = Fmemq (tem, conditions);
  1157.           if (!NILP (tem))
  1158.           
  1159.           {
  1160.             Lisp_Object tem;
  1161.             tem = signal_call_debugger (conditions, sig, data);
  1162.             if (EQ (tem, Qunbound))
  1163.             {
  1164.               struct handler *h = handlerlist;
  1165.               handlerlist = allhandlers;
  1166.               /* Doesn't return */
  1167.               unwind_to_catch (h->tag, Fcons (Fcons (sig, data),
  1168.                                               Fcdr (clause)));
  1169.             }
  1170.             else
  1171. #if 1                           /* RMS Claims: */
  1172.               /* Most callers are not prepared to handle gc if this returns.
  1173.                  So, since this feature is not very useful, take it out.  */
  1174.               /* Have called debugger; return value to signaller  */
  1175.               return (tem);
  1176. #else  /* But I (Mly) claim to have fixed all callers -- in Emacs "Lucid+Mlynarik 19.3", that is */
  1177.             error ("Returning a value from an error is no longer supported");
  1178. #endif
  1179.           }
  1180.         }
  1181.       }
  1182.     }
  1183.  
  1184.   handlerlist = allhandlers;
  1185.   /* If no handler is present now, try to run the debugger,
  1186.      and if that fails, throw to top level.  */
  1187.   signal_call_debugger (conditions, sig, data);
  1188.   return Fthrow (Qtop_level, Qt);
  1189. }
  1190.  
  1191. /* Utility function.  Doesn't return. */
  1192. void
  1193. signal_error (Lisp_Object sig, Lisp_Object data)
  1194. {
  1195.   while (1)
  1196.     Fsignal (sig, data);
  1197. }
  1198.  
  1199.  
  1200. /* dump an error message; called like printf */
  1201.  
  1202. /* VARARGS 1 */
  1203. void
  1204. error (m, a1, a2, a3)
  1205.      char *m;
  1206.      void *a1, *a2, *a3;
  1207. {
  1208.   char buf[200];
  1209.   sprintf (buf, m, a1, a2, a3);
  1210.  
  1211.   while (1)
  1212.     Fsignal (Qerror, Fcons (build_string (buf), Qnil));
  1213. }
  1214.  
  1215. #ifndef standalone
  1216. DEFUN ("commandp", Fcommandp, Scommandp, 1, 1, 0,
  1217.   "T if FUNCTION makes provisions for interactive calling.\n\
  1218. This means it contains a description for how to read arguments to give it.\n\
  1219. The value is nil for an invalid function or a symbol with no function\n\
  1220. definition.\n\
  1221. \n\
  1222. Interactively callable functions include strings and vectors (treated\n\
  1223. as keyboard macros), lambda-expressions that contain a top-level call\n\
  1224. to `interactive', autoload definitions made by `autoload' with non-nil\n\
  1225. fourth argument, and some of the built-in functions of Lisp.\n\
  1226. \n\
  1227. Also, a symbol satisfies `commandp' if its function definition does so.")
  1228.   (function)
  1229.      Lisp_Object function;
  1230. {
  1231.   register Lisp_Object fun;
  1232.   register Lisp_Object funcar;
  1233.  
  1234.   fun = function;
  1235.  
  1236.   fun = indirect_function (fun, 0);
  1237.   if (EQ (fun, Qunbound))
  1238.     return Qnil;
  1239.  
  1240.   /* Emacs primitives are interactive if their DEFUN specifies an
  1241.      interactive spec.  */
  1242.   if (SUBRP (fun))
  1243.     {
  1244.       if (XSUBR (fun)->prompt)
  1245.     return Qt;
  1246.       else
  1247.     return Qnil;
  1248.     }
  1249.  
  1250.   /* Bytecode objects are interactive if they are long enough to
  1251.      have an element whose index is COMPILED_INTERACTIVE, which is
  1252.      where the interactive spec is stored.  */
  1253.   else if (COMPILEDP (fun))
  1254.     return (XVECTOR (fun)->size > COMPILED_INTERACTIVE
  1255.         ? Qt : Qnil);
  1256.  
  1257.   /* Strings and vectors are keyboard macros.  */
  1258.   if (VECTORP (fun) || STRINGP (fun))
  1259.     return Qt;
  1260.  
  1261.   /* Lists may represent commands.  */
  1262.   if (!CONSP (fun))
  1263.     return Qnil;
  1264.   funcar = Fcar (fun);
  1265.   if (!SYMBOLP (funcar))
  1266.     return Fsignal (Qinvalid_function, list1 (fun));
  1267.   if (EQ (funcar, Qlambda))
  1268.     return Fassq (Qinteractive, Fcdr (Fcdr (fun)));
  1269.   if (EQ (funcar, Qmocklisp))
  1270.     return Qt;  /* All mocklisp functions can be called interactively */
  1271.   if (EQ (funcar, Qautoload))
  1272.     return Fcar (Fcdr (Fcdr (Fcdr (fun))));
  1273.   else
  1274.     return Qnil;
  1275. }
  1276. #endif /* !standalone */
  1277.  
  1278. /* ARGSUSED */
  1279. DEFUN ("autoload", Fautoload, Sautoload, 2, 5, 0,
  1280.   "Define FUNCTION to autoload from FILE.\n\
  1281. FUNCTION is a symbol; FILE is a file name string to pass to `load'.\n\
  1282. Third arg DOCSTRING is documentation for the function.\n\
  1283. Fourth arg INTERACTIVE if non-nil says function can be called interactively.\n\
  1284. Fifth arg MACRO if non-nil says the function is really a macro.\n\
  1285. Third through fifth args give info about the real definition.\n\
  1286. They default to nil.\n\
  1287. If FUNCTION is already defined other than as an autoload,\n\
  1288. this does nothing and returns nil.")
  1289.   (function, file, docstring, interactive, macro)
  1290.      Lisp_Object function, file, docstring, interactive, macro;
  1291. {
  1292.   CHECK_SYMBOL (function, 0);
  1293.   CHECK_STRING (file, 1);
  1294.  
  1295.   /* If function is defined and not as an autoload, don't override */
  1296.   if (!EQ (XSYMBOL (function)->function, Qunbound)
  1297.       && !(CONSP (XSYMBOL (function)->function)
  1298.        && EQ (XCONS (XSYMBOL (function)->function)->car, Qautoload)))
  1299.     return Qnil;
  1300.  
  1301.   return Ffset (function, Fcons (Qautoload, list4 (file,
  1302.                                                    docstring,
  1303.                                                    interactive,
  1304.                                                    macro)));
  1305. }
  1306.  
  1307. static Lisp_Object
  1308. un_autoload (oldqueue)
  1309.      Lisp_Object oldqueue;
  1310. {
  1311.   register Lisp_Object queue, first, second;
  1312.  
  1313.   /* Queue to unwind is current value of Vautoload_queue.
  1314.      oldqueue is the shadowed value to leave in Vautoload_queue.  */
  1315.   queue = Vautoload_queue;
  1316.   Vautoload_queue = oldqueue;
  1317.   while (CONSP (queue))
  1318.     {
  1319.       first = Fcar (queue);
  1320.       second = Fcdr (first);
  1321.       first = Fcar (first);
  1322.       if (EQ (second, Qnil))
  1323.     Vfeatures = first;
  1324.       else
  1325.     Ffset (first, second);
  1326.       queue = Fcdr (queue);
  1327.     }
  1328.   return Qnil;
  1329. }
  1330.  
  1331. void
  1332. do_autoload (fundef, funname)
  1333.      Lisp_Object fundef, funname;
  1334. {
  1335.   int count = specpdl_depth;
  1336.   Lisp_Object fun;
  1337.  
  1338.   fun = funname;
  1339.   CHECK_SYMBOL (funname, 0);
  1340.  
  1341.   /* Value saved here is to be restored into Vautoload_queue */
  1342.   record_unwind_protect (un_autoload, Vautoload_queue);
  1343.   Vautoload_queue = Qt;
  1344.   Fload (Fcar (Fcdr (fundef)), Qnil, noninteractive ? Qt : Qnil, Qnil);
  1345.   /* Once loading finishes, don't undo it.  */
  1346.   Vautoload_queue = Qt;
  1347.   unbind_to (count, Qnil);
  1348.  
  1349.   fun = indirect_function (fun, 0);
  1350.  
  1351.   if (EQ (fun, Qunbound)
  1352.       || (CONSP (fun)
  1353.           && EQ (XCONS (fun)->car, Qautoload)))
  1354.     error ("Autoloading failed to define function %s",
  1355.        XSYMBOL (funname)->name->data);
  1356. }
  1357.  
  1358. DEFUN ("eval", Feval, Seval, 1, 1, 0,
  1359.   "Evaluate FORM and return its value.")
  1360.   (form)
  1361.      Lisp_Object form;
  1362. {
  1363.   Lisp_Object fun, val, original_fun, original_args;
  1364.   Lisp_Object funcar;
  1365.   struct backtrace backtrace;
  1366.   struct gcpro gcpro1, gcpro2, gcpro3;
  1367.  
  1368.   if (!CONSP (form))
  1369.   {
  1370.     if (!SYMBOLP (form))
  1371.       return form;
  1372.     if (EQ (Vmocklisp_arguments, Qt))
  1373.       return Fsymbol_value (form);
  1374.     val = Fsymbol_value (form);
  1375.     if (NILP (val))
  1376.       XFASTINT (val) = 0;
  1377.     else if (EQ (val, Qt))
  1378.       XFASTINT (val) = 1;
  1379.     return val;
  1380.   }
  1381.  
  1382.   QUIT;
  1383.   if ((consing_since_gc > gc_cons_threshold) || always_gc)
  1384.     {
  1385.       GCPRO1 (form);
  1386.       Fgarbage_collect ();
  1387.       UNGCPRO;
  1388.     }
  1389.  
  1390.   if (++lisp_eval_depth > max_lisp_eval_depth)
  1391.     {
  1392.       if (max_lisp_eval_depth < 100)
  1393.     max_lisp_eval_depth = 100;
  1394.       if (lisp_eval_depth > max_lisp_eval_depth)
  1395.     error ("Lisp nesting exceeds max-lisp-eval-depth", 0, 0, 0);
  1396.     }
  1397.  
  1398.   original_fun = Fcar (form);
  1399.   original_args = Fcdr (form);
  1400.  
  1401. #ifdef EMACS_BTL
  1402.   backtrace.id_number = 0;
  1403. #endif
  1404.   backtrace.next = backtrace_list;
  1405.   backtrace_list = &backtrace;
  1406.   backtrace.function = &original_fun; /* This also protects them from gc */
  1407.   backtrace.args = &original_args;
  1408.   backtrace.nargs = UNEVALLED;
  1409.   backtrace.evalargs = 1;
  1410.   backtrace.debug_on_exit = 0;
  1411.  
  1412.   if (debug_on_next_call)
  1413.     do_debug_on_call (Qt);
  1414.  
  1415.   /* At this point, only original_fun and original_args
  1416.      have values that will be used below */
  1417.  retry:
  1418.   fun = indirect_function (original_fun, 1);
  1419.  
  1420.   if (SUBRP (fun))
  1421.     {
  1422.       struct Lisp_Subr *subr = XSUBR (fun);
  1423.       int max_args = subr->max_args;
  1424.       Lisp_Object (*fn) () = subr_function (subr);
  1425.       Lisp_Object argvals[SUBR_MAX_ARGS];
  1426.       Lisp_Object args_left;
  1427.       Lisp_Object nargs = XINT (Flength (original_args));
  1428.       register int i;
  1429.  
  1430.       args_left = original_args;
  1431.  
  1432.       if (nargs < subr->min_args ||
  1433.       (max_args >= 0 && max_args < nargs))
  1434.     return Fsignal (Qwrong_number_of_arguments, 
  1435.                         list2 (fun, make_number (nargs)));
  1436.  
  1437.       if (max_args == UNEVALLED)
  1438.     {
  1439.       backtrace.evalargs = 0;
  1440.       val = ((*fn) (args_left));
  1441.       goto done;
  1442.     }
  1443.  
  1444.       if (max_args == MANY)
  1445.     {
  1446.       /* Pass a vector of evaluated arguments */
  1447.       Lisp_Object *vals;
  1448.       register int argnum = 0;
  1449.  
  1450.       vals = (Lisp_Object *) alloca (nargs * sizeof (Lisp_Object));
  1451.  
  1452.       GCPRO3 (args_left, fun, fun);
  1453.       gcpro3.var = vals;
  1454.       gcpro3.nvars = 0;
  1455.  
  1456.       while (!NILP (args_left))
  1457.         {
  1458.           vals[argnum++] = Feval (Fcar (args_left));
  1459.           args_left = Fcdr (args_left);
  1460.           gcpro3.nvars = argnum;
  1461.         }
  1462.       backtrace.args = vals;
  1463.       backtrace.nargs = nargs;
  1464.  
  1465.       val = ((*fn) (nargs, vals));
  1466.           UNGCPRO;
  1467.       goto done;
  1468.     }
  1469.  
  1470.       GCPRO3 (args_left, fun, fun);
  1471.       gcpro3.var = argvals;
  1472.       gcpro3.nvars = 0;
  1473.  
  1474.       for (i = 0; i < max_args; args_left = Fcdr (args_left))
  1475.     {
  1476.       argvals[i] = Feval (Fcar (args_left));
  1477.       gcpro3.nvars = ++i;
  1478.     }
  1479.  
  1480.       UNGCPRO;
  1481.  
  1482.       backtrace.args = argvals;
  1483.       backtrace.nargs = nargs;
  1484.  
  1485.       switch (max_args)
  1486.     {
  1487.     case 0:
  1488.       val = ((*fn) ());
  1489.       goto done;
  1490.     case 1:
  1491.       val = ((*fn) (argvals[0]));
  1492.       goto done;
  1493.     case 2:
  1494.       val = ((*fn) (argvals[0], argvals[1]));
  1495.       goto done;
  1496.     case 3:
  1497.       val = ((*fn) (argvals[0], argvals[1], argvals[2]));
  1498.       goto done;
  1499.     case 4:
  1500.       val = ((*fn) (argvals[0], argvals[1], argvals[2], argvals[3]));
  1501.       goto done;
  1502.     case 5:
  1503.       val = ((*fn) (argvals[0], argvals[1], argvals[2],
  1504.                         argvals[3], argvals[4]));
  1505.       goto done;
  1506.     case 6:
  1507.       val = ((*fn) (argvals[0], argvals[1], argvals[2],
  1508.                         argvals[3], argvals[4], argvals[5]));
  1509.       goto done;
  1510.     case 7:
  1511.       val = ((*fn) (argvals[0], argvals[1], argvals[2],
  1512.                         argvals[3], argvals[4], argvals[5],
  1513.                         argvals[6]));
  1514.       goto done;
  1515.  
  1516.     default:
  1517.       /* Someone has created a subr that takes more arguments than
  1518.          is supported by this code.  We need to either rewrite the
  1519.          subr to use a different argument protocol, or add more
  1520.          cases to this switch.  */
  1521.       abort ();
  1522.     }
  1523.     }
  1524.   if (COMPILEDP (fun))
  1525.     val = apply_lambda (fun, original_args, 1);
  1526.   else
  1527.     {
  1528.       if (!CONSP (fun))
  1529.     return Fsignal (Qinvalid_function, list1 (fun));
  1530.       funcar = Fcar (fun);
  1531.       if (!SYMBOLP (funcar))
  1532.     return Fsignal (Qinvalid_function, list1 (fun));
  1533.       if (EQ (funcar, Qautoload))
  1534.     {
  1535.       do_autoload (fun, original_fun);
  1536.       goto retry;
  1537.     }
  1538.       if (EQ (funcar, Qmacro))
  1539.     val = Feval (apply1 (Fcdr (fun), original_args));
  1540.       else if (EQ (funcar, Qlambda))
  1541.     val = apply_lambda (fun, original_args, 1);
  1542.       else if (EQ (funcar, Qmocklisp))
  1543.     val = ml_apply (fun, original_args);
  1544.       else
  1545.     return Fsignal (Qinvalid_function, list1 (fun));
  1546.     }
  1547.  done:
  1548.   if (!EQ (Vmocklisp_arguments, Qt))
  1549.     {
  1550.       if (NILP (val))
  1551.     XFASTINT (val) = 0;
  1552.       else if (EQ (val, Qt))
  1553.     XFASTINT (val) = 1;
  1554.     }
  1555.   lisp_eval_depth--;
  1556.   if (backtrace.debug_on_exit)
  1557.     val = call_debugger (list2 (Qexit, val));
  1558.   backtrace_list = backtrace.next;
  1559.   return val;
  1560. }
  1561.  
  1562. DEFUN ("apply", Fapply, Sapply, 2, MANY, 0,
  1563.   "Call FUNCTION with our remaining args, using our last arg as list of args.\n\
  1564. Thus, (apply '+ 1 2 '(3 4)) returns 10.")
  1565.   (nargs, args)
  1566.      int nargs;
  1567.      Lisp_Object *args;
  1568. {
  1569.   register int i, numargs;
  1570.   register Lisp_Object spread_arg;
  1571.   register Lisp_Object *funcall_args;
  1572.   Lisp_Object fun;
  1573.   struct gcpro gcpro1;
  1574.  
  1575.   fun = args [0];
  1576.   funcall_args = 0;
  1577.   spread_arg = args [nargs - 1];
  1578.   CHECK_LIST (spread_arg, nargs);
  1579.   
  1580.   numargs = XINT (Flength (spread_arg));
  1581.  
  1582.   if (numargs == 0)
  1583.     return Ffuncall (nargs - 1, args);
  1584.   else if (numargs == 1)
  1585.     {
  1586.       args [nargs - 1] = XCONS (spread_arg)->car;
  1587.       return Ffuncall (nargs, args);
  1588.     }
  1589.  
  1590.   numargs += nargs - 2;
  1591.  
  1592.   fun = indirect_function (fun, 0);
  1593.   if (EQ (fun, Qunbound))
  1594.     {
  1595.       /* Let funcall get the error */
  1596.       fun = args[0];
  1597.     }
  1598.   else if (SUBRP (fun))
  1599.     {
  1600.       struct Lisp_Subr *subr = XSUBR (fun);
  1601.       int max_args = subr->max_args;
  1602.  
  1603.       if (numargs < subr->min_args
  1604.       || (max_args >= 0 && max_args < numargs))
  1605.         {
  1606.           /* Let funcall get the error */
  1607.         }
  1608.       else if (max_args > numargs)
  1609.     {
  1610.       /* Avoid making funcall cons up yet another new vector of arguments
  1611.              by explicitly supplying nil's for optional values */
  1612.           funcall_args = (Lisp_Object *) alloca ((1 + max_args)
  1613.                                                  * sizeof (Lisp_Object));
  1614.           for (i = numargs; i < max_args;)
  1615.             funcall_args[++i] = Qnil;
  1616.       GCPRO1 (*funcall_args);
  1617.       gcpro1.nvars = 1 + max_args;
  1618.         }
  1619.     }
  1620.   /* We add 1 to numargs because funcall_args includes the
  1621.      function itself as well as its arguments.  */
  1622.   if (!funcall_args)
  1623.     {
  1624.       funcall_args = (Lisp_Object *) alloca ((1 + numargs)
  1625.                          * sizeof (Lisp_Object));
  1626.       GCPRO1 (*funcall_args);
  1627.       gcpro1.nvars = 1 + numargs;
  1628.     }
  1629.  
  1630.   memcpy ((char *)funcall_args, (char *)args, nargs * sizeof (Lisp_Object));
  1631.   /* Spread the last arg we got.  Its first element goes in
  1632.      the slot that it used to occupy, hence this value of I.  */
  1633.   i = nargs - 1;
  1634.   while (!NILP (spread_arg))
  1635.     {
  1636.       funcall_args [i++] = XCONS (spread_arg)->car;
  1637.       spread_arg = XCONS (spread_arg)->cdr;
  1638.     }
  1639.   RETURN_UNGCPRO (Ffuncall (gcpro1.nvars, funcall_args));
  1640. }
  1641.  
  1642. /* Apply fn to arg */
  1643. Lisp_Object
  1644. apply1 (fn, arg)
  1645.      Lisp_Object fn, arg;
  1646. {
  1647.   struct gcpro gcpro1;
  1648.  
  1649.   GCPRO1 (fn);
  1650.   if (NILP (arg))
  1651.     RETURN_UNGCPRO (Ffuncall (1, &fn));
  1652.   gcpro1.nvars = 2;
  1653.  
  1654. #ifdef NO_ARG_ARRAY
  1655.   {
  1656.     Lisp_Object args[2];
  1657.     args[0] = fn;
  1658.     args[1] = arg;
  1659.     gcpro1.var = args;
  1660.     RETURN_UNGCPRO (Fapply (2, args));
  1661.   }
  1662. #else /* not NO_ARG_ARRAY */
  1663.   RETURN_UNGCPRO (Fapply (2, &fn));
  1664. #endif /* not NO_ARG_ARRAY */
  1665. }
  1666.  
  1667. /* Call function fn on no arguments */
  1668. Lisp_Object
  1669. call0 (fn)
  1670.      Lisp_Object fn;
  1671. {
  1672.   struct gcpro gcpro1;
  1673.  
  1674.   GCPRO1 (fn);
  1675.   RETURN_UNGCPRO (Ffuncall (1, &fn));
  1676. }
  1677.  
  1678.  
  1679. /* Call function fn with argument arg */
  1680. /* ARGSUSED */
  1681. Lisp_Object
  1682. call1 (fn, arg)
  1683.      Lisp_Object fn, arg;
  1684. {
  1685.   struct gcpro gcpro1;
  1686. #ifdef NO_ARG_ARRAY
  1687.   Lisp_Object args[2];  
  1688.  
  1689.   args[0] = fn;
  1690.   args[1] = arg;
  1691.   GCPRO1 (args[0]);
  1692.   gcpro1.nvars = 2;
  1693.   RETURN_UNGCPRO (Ffuncall (2, args));
  1694. #else /* not NO_ARG_ARRAY */
  1695.   GCPRO1 (fn);
  1696.   gcpro1.nvars = 2;
  1697.   RETURN_UNGCPRO (Ffuncall (2, &fn));
  1698. #endif /* not NO_ARG_ARRAY */
  1699. }
  1700.  
  1701. /* Call function fn with arguments arg, arg1 */
  1702. /* ARGSUSED */
  1703. Lisp_Object
  1704. call2 (fn, arg, arg1)
  1705.      Lisp_Object fn, arg, arg1;
  1706. {
  1707.   struct gcpro gcpro1;
  1708. #ifdef NO_ARG_ARRAY
  1709.   Lisp_Object args[3];
  1710.   args[0] = fn;
  1711.   args[1] = arg;
  1712.   args[2] = arg1;
  1713.   GCPRO1 (args[0]);
  1714.   gcpro1.nvars = 3;
  1715.   RETURN_UNGCPRO (Ffuncall (3, args));
  1716. #else /* not NO_ARG_ARRAY */
  1717.   GCPRO1 (fn);
  1718.   gcpro1.nvars = 3;
  1719.   RETURN_UNGCPRO (Ffuncall (3, &fn));
  1720. #endif /* not NO_ARG_ARRAY */
  1721. }
  1722.  
  1723. /* Call function fn with arguments arg, arg1, arg2 */
  1724. /* ARGSUSED */
  1725. Lisp_Object
  1726. call3 (fn, arg, arg1, arg2)
  1727.      Lisp_Object fn, arg, arg1, arg2;
  1728. {
  1729.   struct gcpro gcpro1;
  1730. #ifdef NO_ARG_ARRAY
  1731.   Lisp_Object args[4];
  1732.   args[0] = fn;
  1733.   args[1] = arg;
  1734.   args[2] = arg1;
  1735.   args[3] = arg2;
  1736.   GCPRO1 (args[0]);
  1737.   gcpro1.nvars = 4;
  1738.   RETURN_UNGCPRO (Ffuncall (4, args));
  1739. #else /* not NO_ARG_ARRAY */
  1740.   GCPRO1 (fn);
  1741.   gcpro1.nvars = 4;
  1742.   RETURN_UNGCPRO (Ffuncall (4, &fn));
  1743. #endif /* not NO_ARG_ARRAY */
  1744. }
  1745.  
  1746. /* Call function fn with arguments arg0, arg1, arg2, arg3 */
  1747. Lisp_Object
  1748. call4 (Lisp_Object fn,
  1749.        Lisp_Object arg0, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3)
  1750. {
  1751.   struct gcpro gcpro1;
  1752.   Lisp_Object args[5];
  1753.   args[0] = fn;
  1754.   args[1] = arg0;
  1755.   args[2] = arg1;
  1756.   args[3] = arg2;
  1757.   args[4] = arg3;
  1758.   GCPRO1 (args[0]);
  1759.   gcpro1.nvars = 5;
  1760.   RETURN_UNGCPRO (Ffuncall (5, args));
  1761. }
  1762.  
  1763. /* Call function fn with arguments arg0, arg1, arg2, arg3, arg4 */
  1764. Lisp_Object
  1765. call5 (Lisp_Object fn,
  1766.        Lisp_Object arg0, Lisp_Object arg1, Lisp_Object arg2, 
  1767.        Lisp_Object arg3, Lisp_Object arg4)
  1768. {
  1769.   struct gcpro gcpro1;
  1770.   Lisp_Object args[6];
  1771.   args[0] = fn;
  1772.   args[1] = arg0;
  1773.   args[2] = arg1;
  1774.   args[3] = arg2;
  1775.   args[4] = arg3;
  1776.   args[5] = arg4;
  1777.   GCPRO1 (args[0]);
  1778.   gcpro1.nvars = 6;
  1779.   RETURN_UNGCPRO (Ffuncall (6, args));
  1780. }
  1781.  
  1782. #ifdef EMACS_BTL
  1783. #include "btl-get.h"
  1784. int
  1785. btl_symbol_id_number (sym)
  1786.      Lisp_Object sym;
  1787. {
  1788.   if (SYMBOLP (sym))
  1789.     {
  1790.       extern Lisp_Object VBTL_id_tag;
  1791.       register Lisp_Object tag = VBTL_id_tag;
  1792.       Lisp_Object id;
  1793.       int foundp = 0;
  1794.     
  1795.       BTL_GET (sym, tag, id, foundp);
  1796.       if (foundp && (FIXNUMP (id)))
  1797.         {
  1798.           int id_number = XINT(id);
  1799.           if (id_number > 0)
  1800.             return id_number;
  1801.         }
  1802.     }
  1803.  
  1804.   return 0;
  1805. }
  1806. #endif
  1807.  
  1808. DEFUN ("funcall", Ffuncall, Sfuncall, 1, MANY, 0,
  1809.   "Call first argument as a function, passing remaining arguments to it.\n\
  1810. Thus,  (funcall 'cons 'x 'y)  returns  (x . y).")
  1811.   (nargs, args)
  1812.      int nargs;
  1813.      Lisp_Object *args;
  1814. {
  1815.   Lisp_Object fun;
  1816.   Lisp_Object funcar;
  1817.   int numargs = nargs - 1;
  1818.   Lisp_Object val;
  1819.   struct backtrace backtrace;
  1820.   register int i;
  1821.  
  1822.   QUIT;
  1823.   if ((consing_since_gc > gc_cons_threshold) || always_gc)
  1824.     Fgarbage_collect ();
  1825.  
  1826.   if (++lisp_eval_depth > max_lisp_eval_depth)
  1827.     {
  1828.       if (max_lisp_eval_depth < 100)
  1829.     max_lisp_eval_depth = 100;
  1830.       if (lisp_eval_depth > max_lisp_eval_depth)
  1831.     error ("Lisp nesting exceeds max-lisp-eval-depth", 0, 0, 0);
  1832.     }
  1833.  
  1834. #ifdef EMACS_BTL
  1835.   backtrace.id_number = 0;
  1836. #endif
  1837.   backtrace.next = backtrace_list;
  1838.   backtrace_list = &backtrace;
  1839.   backtrace.function = &args[0];
  1840.   backtrace.args = &args[1];
  1841.   backtrace.nargs = nargs - 1;
  1842.   backtrace.evalargs = 0;
  1843.   backtrace.debug_on_exit = 0;
  1844.  
  1845.   if (debug_on_next_call)
  1846.     do_debug_on_call (Qlambda);
  1847.  
  1848.  retry:
  1849.  
  1850.   fun = args[0];
  1851.  
  1852. #ifdef EMACS_BTL
  1853.   {
  1854.     extern int emacs_btl_elisp_only_p;
  1855.     extern int btl_symbol_id_number ();
  1856.     if (emacs_btl_elisp_only_p)
  1857.       backtrace.id_number = btl_symbol_id_number (fun);
  1858.   }
  1859. #endif
  1860.  
  1861.   fun = indirect_function (fun, 1);
  1862.  
  1863.   if (SUBRP (fun))
  1864.     {
  1865.       struct Lisp_Subr *subr = XSUBR (fun);
  1866.       int max_args = subr->max_args;
  1867.       Lisp_Object (*fn) () = subr_function (subr);
  1868.       Lisp_Object argvals[SUBR_MAX_ARGS];
  1869.       register Lisp_Object *internal_args;
  1870.  
  1871.       if (numargs < subr->min_args
  1872.       || (max_args >= 0 && max_args < numargs))
  1873.     {
  1874.       return Fsignal (Qwrong_number_of_arguments, 
  1875.                           list2 (fun, make_number (numargs)));
  1876.     }
  1877.  
  1878.       if (max_args == UNEVALLED)
  1879.     return Fsignal (Qinvalid_function, list1 (fun));
  1880.  
  1881.       if (max_args == MANY)
  1882.     {
  1883.       val = ((*fn) (numargs, args + 1));
  1884.       goto done;
  1885.     }
  1886.  
  1887.       if (max_args > numargs)
  1888.     {
  1889.           for (i = 0; i < numargs; i++)
  1890.             argvals[i] = args[i + 1];
  1891.       for (i = numargs; i < max_args; i++)
  1892.         argvals[i] = Qnil;
  1893.           internal_args = argvals;
  1894.     }
  1895.       else
  1896.     internal_args = args + 1;
  1897.       switch (max_args)
  1898.     {
  1899.     case 0:
  1900.       val = ((*fn) ());
  1901.       goto done;
  1902.     case 1:
  1903.       val = ((*fn) (internal_args[0]));
  1904.       goto done;
  1905.     case 2:
  1906.       val = ((*fn) (internal_args[0], internal_args[1]));
  1907.       goto done;
  1908.     case 3:
  1909.       val = ((*fn) (internal_args[0], internal_args[1],
  1910.                         internal_args[2]));
  1911.       goto done;
  1912.     case 4:
  1913.       val = ((*fn) (internal_args[0], internal_args[1],
  1914.                         internal_args[2], internal_args[3]));
  1915.       goto done;
  1916.     case 5:
  1917.       val = ((*fn) (internal_args[0], internal_args[1],
  1918.                         internal_args[2], internal_args[3],
  1919.                         internal_args[4]));
  1920.       goto done;
  1921.     case 6:
  1922.       val = ((*fn) (internal_args[0], internal_args[1],
  1923.                         internal_args[2], internal_args[3],
  1924.                         internal_args[4], internal_args[5]));
  1925.       goto done;
  1926.     case 7:
  1927.       val = ((*fn) (internal_args[0], internal_args[1],
  1928.                         internal_args[2], internal_args[3],
  1929.                         internal_args[4], internal_args[5],
  1930.                         internal_args[6]));
  1931.       goto done;
  1932.  
  1933.     default:
  1934.  
  1935.       /* If a subr takes more than 6 arguments without using MANY
  1936.          or UNEVALLED, we need to extend this function to support it. 
  1937.          Until this is done, there is no way to call the function.  */
  1938.       abort ();
  1939.     }
  1940.     }
  1941.   if (COMPILEDP (fun))
  1942.     val = funcall_lambda (fun, numargs, args + 1);
  1943.   else
  1944.     {
  1945.       if (!CONSP (fun))
  1946.     return Fsignal (Qinvalid_function, list1 (fun));
  1947.       funcar = Fcar (fun);
  1948.       if (!SYMBOLP (funcar))
  1949.     return Fsignal (Qinvalid_function, list1 (fun));
  1950.       if (EQ (funcar, Qlambda))
  1951.     val = funcall_lambda (fun, numargs, args + 1);
  1952.       else if (EQ (funcar, Qmocklisp))
  1953.     val = ml_apply (fun, Flist (numargs, args + 1));
  1954.       else if (EQ (funcar, Qautoload))
  1955.     {
  1956.       do_autoload (fun, args[0]);
  1957.       goto retry;
  1958.     }
  1959.       else
  1960.     return Fsignal (Qinvalid_function, list1 (fun));
  1961.     }
  1962.  done:
  1963.   lisp_eval_depth--;
  1964.   if (backtrace.debug_on_exit)
  1965.     val = call_debugger (list2 (Qexit, val));
  1966.   backtrace_list = backtrace.next;
  1967.   return val;
  1968. }
  1969.  
  1970.  
  1971. static Lisp_Object
  1972. apply_lambda (fun, args, eval_flag)
  1973.      Lisp_Object fun, args;
  1974.      int eval_flag;
  1975. {
  1976.   Lisp_Object args_left;
  1977.   int numargs = XINT (Flength (args));
  1978.   register Lisp_Object *arg_vector;
  1979.   struct gcpro gcpro1, gcpro2, gcpro3;
  1980.   register int i;
  1981.   register Lisp_Object tem;
  1982.  
  1983.   arg_vector = (Lisp_Object *) alloca (numargs * sizeof (Lisp_Object));
  1984.   args_left = args;
  1985.  
  1986.   GCPRO3 (*arg_vector, args_left, fun);
  1987.   gcpro1.nvars = 0;
  1988.  
  1989.   for (i = 0; i < numargs;)
  1990.     {
  1991.       tem = Fcar (args_left), args_left = Fcdr (args_left);
  1992.       if (eval_flag) tem = Feval (tem);
  1993.       arg_vector[i++] = tem;
  1994.       gcpro1.nvars = i;
  1995.     }
  1996.  
  1997.   UNGCPRO;
  1998.  
  1999.   if (eval_flag)
  2000.     {
  2001.       backtrace_list->args = arg_vector;
  2002.       backtrace_list->nargs = i;
  2003.     }
  2004.   backtrace_list->evalargs = 0;
  2005.   tem = funcall_lambda (fun, numargs, arg_vector);
  2006.  
  2007.   /* Do the debug-on-exit now, while arg_vector still exists.  */
  2008.   if (backtrace_list->debug_on_exit)
  2009.     tem = call_debugger (list2 (Qexit, tem));
  2010.   /* Don't do it again when we return to eval.  */
  2011.   backtrace_list->debug_on_exit = 0;
  2012.   return tem;
  2013. }
  2014.  
  2015. /* Apply a Lisp function FUN to the NARGS evaluated arguments in ARG_VECTOR
  2016.    and return the result of evaluation.
  2017.    FUN must be either a lambda-expression or a compiled-code object.  */
  2018.  
  2019. static Lisp_Object
  2020. funcall_lambda (fun, nargs, arg_vector)
  2021.      Lisp_Object fun;
  2022.      int nargs;
  2023.      register Lisp_Object *arg_vector;
  2024. {
  2025.   Lisp_Object val, tem;
  2026.   register Lisp_Object syms_left;
  2027.   register Lisp_Object next;
  2028.   int count = specpdl_depth;
  2029.   register int i;
  2030.   int optional = 0, rest = 0;
  2031.  
  2032.   specbind (Qmocklisp_arguments, Qt);   /* t means NOT mocklisp! */
  2033.  
  2034.   if (CONSP (fun))
  2035.     syms_left = Fcar (Fcdr (fun));
  2036.   else if (COMPILEDP (fun))
  2037.     syms_left = XVECTOR (fun)->contents[COMPILED_ARGLIST];
  2038.   else abort ();
  2039.  
  2040.   i = 0;
  2041.   for (; !NILP (syms_left); syms_left = Fcdr (syms_left))
  2042.     {
  2043.       QUIT;
  2044.       next = Fcar (syms_left);
  2045.       if (!SYMBOLP (next))
  2046.     signal_error (Qinvalid_function, list1 (fun));
  2047.       if (EQ (next, Qand_rest))
  2048.     rest = 1;
  2049.       else if (EQ (next, Qand_optional))
  2050.     optional = 1;
  2051.       else if (rest)
  2052.     {
  2053.       specbind (next, Flist (nargs - i, &arg_vector[i]));
  2054.       i = nargs;
  2055.     }
  2056.       else if (i < nargs)
  2057.     {
  2058.       tem = arg_vector[i++];
  2059.       specbind (next, tem);
  2060.     }
  2061.       else if (!optional)
  2062.     return Fsignal (Qwrong_number_of_arguments,
  2063.                         list2 (fun, make_number (nargs)));
  2064.       else
  2065.     specbind (next, Qnil);
  2066.     }
  2067.  
  2068.   if (i < nargs)
  2069.     return Fsignal (Qwrong_number_of_arguments, 
  2070.                     list2 (fun, make_number (nargs)));
  2071.  
  2072.   if (CONSP (fun))
  2073.     val = Fprogn (Fcdr (Fcdr (fun)));
  2074.   else
  2075.     val = Fbyte_code (XVECTOR (fun)->contents[COMPILED_BYTECODE],
  2076.               XVECTOR (fun)->contents[COMPILED_CONSTANTS],
  2077.               XVECTOR (fun)->contents[COMPILED_STACK_DEPTH]);
  2078.   return unbind_to (count, val);
  2079. }
  2080.  
  2081. static void
  2082. grow_specpdl ()
  2083. {
  2084.   if (specpdl_size >= max_specpdl_size)
  2085.     {
  2086.       if (max_specpdl_size < 400)
  2087.     max_specpdl_size = 400;
  2088.       if (specpdl_size >= max_specpdl_size)
  2089.     {
  2090.       if (!NILP (Vdebug_on_error))
  2091.         /* Leave room for some specpdl in the debugger.  */
  2092.         max_specpdl_size = specpdl_size + 100;
  2093.       Fsignal (Qerror,
  2094.            list1 (build_string ("Variable binding depth exceeds max-specpdl-size")));
  2095.     }
  2096.     }
  2097.   specpdl_size *= 2;
  2098.   if (specpdl_size > max_specpdl_size)
  2099.     specpdl_size = max_specpdl_size;
  2100.   specpdl = (struct specbinding *) xrealloc (specpdl, specpdl_size * sizeof (struct specbinding));
  2101.   specpdl_ptr = specpdl + specpdl_depth;
  2102. }
  2103.  
  2104. void
  2105. specbind (symbol, value)
  2106.      Lisp_Object symbol, value;
  2107. {
  2108.   Lisp_Object ovalue;
  2109.  
  2110.   CHECK_SYMBOL (symbol, 0);
  2111.  
  2112.   if (specpdl_depth >= specpdl_size)
  2113.     grow_specpdl ();
  2114.   specpdl_ptr->symbol = symbol;
  2115.   specpdl_ptr->func = 0;
  2116.   ovalue = XSYMBOL (symbol)->value;
  2117.   specpdl_ptr->old_value = (EQ (ovalue, Qunbound)
  2118.                 ? Qunbound : Fsymbol_value (symbol));
  2119.   specpdl_ptr++;
  2120.   specpdl_depth++;
  2121.   if (XTYPE (ovalue) == Lisp_Buffer_Objfwd)
  2122.     store_symval_forwarding (symbol, ovalue, value);
  2123.   else
  2124.     Fset (symbol, value);
  2125. }
  2126.  
  2127. void
  2128. record_unwind_protect (function, arg)
  2129.      Lisp_Object (*function)();
  2130.      Lisp_Object arg;
  2131. {
  2132.   if (specpdl_depth >= specpdl_size)
  2133.     grow_specpdl ();
  2134.   specpdl_ptr->func = function;
  2135.   specpdl_ptr->symbol = Qnil;
  2136.   specpdl_ptr->old_value = arg;
  2137.   specpdl_ptr++;
  2138.   specpdl_depth++;
  2139. }
  2140.  
  2141. Lisp_Object
  2142. unbind_to (int count, Lisp_Object value)
  2143. {
  2144.   int quitf = !NILP (Vquit_flag);
  2145.   struct gcpro gcpro1;
  2146.  
  2147.   GCPRO1 (value);
  2148.  
  2149.   Vquit_flag = Qnil;
  2150.  
  2151.   while (specpdl_depth != count)
  2152.     {
  2153.       --specpdl_ptr;
  2154.       --specpdl_depth;
  2155.       if (specpdl_ptr->func != 0)
  2156.     (*specpdl_ptr->func) (specpdl_ptr->old_value);
  2157.       /* Note that a "binding" of nil is really an unwind protect,
  2158.     so in that case the "old value" is a list of forms to evaluate.  */
  2159.       else if (NILP (specpdl_ptr->symbol))
  2160.     Fprogn (specpdl_ptr->old_value);
  2161.       else
  2162.         Fset (specpdl_ptr->symbol, specpdl_ptr->old_value);
  2163.     }
  2164.   if (NILP (Vquit_flag) && quitf) Vquit_flag = Qt;
  2165.  
  2166.   UNGCPRO;
  2167.  
  2168.   return value;
  2169. }
  2170.  
  2171. #if 0
  2172.  
  2173. /* Get the value of symbol's global binding, even if that binding
  2174.  is not now dynamically visible.  */
  2175.  
  2176. Lisp_Object
  2177. top_level_value (symbol)
  2178.      Lisp_Object symbol;
  2179. {
  2180.   register struct specbinding *ptr = specpdl;
  2181.  
  2182.   CHECK_SYMBOL (symbol, 0);
  2183.   for (; ptr != specpdl_ptr; ptr++)
  2184.     {
  2185.       if (EQ (ptr->symbol, symbol))
  2186.     return ptr->old_value;
  2187.     }
  2188.   return Fsymbol_value (symbol);
  2189. }
  2190.  
  2191. Lisp_Object
  2192. top_level_set (symbol, newval)
  2193.      Lisp_Object symbol, newval;
  2194. {
  2195.   register struct specbinding *ptr = specpdl;
  2196.  
  2197.   CHECK_SYMBOL (symbol, 0);
  2198.   for (; ptr != specpdl_ptr; ptr++)
  2199.     {
  2200.       if (EQ (ptr->symbol, symbol))
  2201.     {
  2202.       ptr->old_value = newval;
  2203.       return newval;
  2204.     }
  2205.     }
  2206.   return Fset (symbol, newval);
  2207. }  
  2208.  
  2209. #endif /* 0 */
  2210.  
  2211. DEFUN ("backtrace-debug", Fbacktrace_debug, Sbacktrace_debug, 2, 2, 0,
  2212.   "Set the debug-on-exit flag of eval frame LEVEL levels down to FLAG.\n\
  2213. The debugger is entered when that frame exits, if the flag is non-nil.")
  2214.   (level, flag)
  2215.      Lisp_Object level, flag;
  2216. {
  2217.   register struct backtrace *backlist = backtrace_list;
  2218.   register int i;
  2219.  
  2220.   CHECK_FIXNUM (level, 0);
  2221.  
  2222.   for (i = 0; backlist && i < XINT (level); i++)
  2223.     {
  2224.       backlist = backlist->next;
  2225.     }
  2226.  
  2227.   if (backlist)
  2228.     backlist->debug_on_exit = !NILP (flag);
  2229.  
  2230.   return flag;
  2231. }
  2232.  
  2233. DEFUN ("backtrace", Fbacktrace, Sbacktrace, 0, 1, "",
  2234.   "Print a trace of Lisp function calls currently active.\n\
  2235. Output stream used is value of `standard-output'.")
  2236.   (stream)
  2237.   Lisp_Object stream;
  2238. {
  2239.   register struct backtrace *backlist = backtrace_list;
  2240.   register int i;
  2241.   Lisp_Object tail;
  2242.   Lisp_Object tem;
  2243.   int old_pr = print_readably;
  2244.   int old_level = Vprint_level;
  2245.   struct gcpro gcpro1, gcpro2;
  2246.  
  2247.   entering_debugger = 0;
  2248.  
  2249.   XFASTINT (Vprint_level) = 3;
  2250.   print_readably = 0;
  2251.   tail = Qnil;
  2252.  
  2253.   GCPRO2 (tail, stream);
  2254.  
  2255.   if (NILP (stream)) stream = Vstandard_output;
  2256.  
  2257.   while (backlist)
  2258.     {
  2259.       write_string_1 (((backlist->debug_on_exit) ? "* " : "  "), 2,
  2260.                       stream);
  2261.       if (backlist->nargs == UNEVALLED)
  2262.     {
  2263.       Fprin1 (Fcons (*backlist->function, *backlist->args), Qnil);
  2264.     }
  2265.       else
  2266.     {
  2267.       tem = *backlist->function;
  2268.       Fprin1 (tem, Qnil);    /* This can QUIT */
  2269.       write_string ("(", 1);
  2270.       if (backlist->nargs == MANY)
  2271.         {
  2272.           for (tail = *backlist->args, i = 0;
  2273.            !NILP (tail);
  2274.            tail = Fcdr (tail), i++)
  2275.         {
  2276.           if (i) write_string (" ", 1);
  2277.           Fprin1 (Fcar (tail), Qnil);
  2278.         }
  2279.         }
  2280.       else
  2281.         {
  2282.           for (i = 0; i < backlist->nargs; i++)
  2283.         {
  2284.           if (i != 0) write_string (" ", 1);
  2285.           Fprin1 (backlist->args[i], Qnil);
  2286.         }
  2287.         }
  2288.     }
  2289.       write_string (")\n", 2);
  2290.       backlist = backlist->next;
  2291.     }
  2292.  
  2293.   Vprint_level = old_level;
  2294.   print_readably = old_pr;
  2295.   UNGCPRO;
  2296.   return Qnil;
  2297. }
  2298.  
  2299. DEFUN ("backtrace-frame", Fbacktrace_frame, Sbacktrace_frame, 1, 1, "",
  2300.   "Return the function and arguments N frames up from current execution point.\n\
  2301. If that frame has not evaluated the arguments yet (or is a special form),\n\
  2302. the value is (nil FUNCTION ARG-FORMS...).\n\
  2303. If that frame has evaluated its arguments and called its function already,\n\
  2304. the value is (t FUNCTION ARG-VALUES...).\n\
  2305. A &rest arg is represented as the tail of the list ARG-VALUES.\n\
  2306. FUNCTION is whatever was supplied as car of evaluated list,\n\
  2307. or a lambda expression for macro calls.\n\
  2308. If N is more than the number of frames, the value is nil.")
  2309.   (nframes)
  2310.      Lisp_Object nframes;
  2311. {
  2312.   register struct backtrace *backlist = backtrace_list;
  2313.   register int i;
  2314.   Lisp_Object tem;
  2315.  
  2316.   CHECK_NATNUM (nframes, 0);
  2317.  
  2318.   /* Find the frame requested.  */
  2319.   for (i = 0; i < XFASTINT (nframes); i++)
  2320.     backlist = backlist->next;
  2321.  
  2322.   if (!backlist)
  2323.     return Qnil;
  2324.   if (backlist->nargs == UNEVALLED)
  2325.     return Fcons (Qnil, Fcons (*backlist->function, *backlist->args));
  2326.   else
  2327.     {
  2328.       if (backlist->nargs == MANY)
  2329.     tem = *backlist->args;
  2330.       else
  2331.     tem = Flist (backlist->nargs, backlist->args);
  2332.  
  2333.       return Fcons (Qt, Fcons (*backlist->function, tem));
  2334.     }
  2335. }
  2336.  
  2337. void
  2338. syms_of_eval ()
  2339. {
  2340.   DEFVAR_INT ("max-specpdl-size", &max_specpdl_size,
  2341.     "Limit on number of Lisp variable bindings & unwind-protects before error.");
  2342.  
  2343.   DEFVAR_INT ("max-lisp-eval-depth", &max_lisp_eval_depth,
  2344.     "Limit on depth in `eval', `apply' and `funcall' before error.\n\
  2345. This limit is to catch infinite recursions for you before they cause\n\
  2346. actual stack overflow in C, which would be fatal for Emacs.\n\
  2347. You can safely make it considerably larger than its default value,\n\
  2348. if that proves inconveniently small.");
  2349.  
  2350.   DEFVAR_LISP ("quit-flag", &Vquit_flag,
  2351.     "Non-nil causes `eval' to abort, unless `inhibit-quit' is non-nil.\n\
  2352. Typing C-G sets `quit-flag' non-nil, regardless of `inhibit-quit'.");
  2353.   Vquit_flag = Qnil;
  2354.  
  2355.   DEFVAR_LISP ("inhibit-quit", &Vinhibit_quit,
  2356.     "Non-nil inhibits C-g quitting from happening immediately.\n\
  2357. Note that `quit-flag' will still be set by typing C-g,\n\
  2358. so a quit will be signalled as soon as `inhibit-quit' is nil.\n\
  2359. To prevent this happening, set `quit-flag' to nil\n\
  2360. before making `inhibit-quit' nil.");
  2361.   Vinhibit_quit = Qnil;
  2362.  
  2363.   defsymbol (&Qinhibit_quit, "inhibit-quit");
  2364.  
  2365.   defsymbol (&Qautoload, "autoload");
  2366.  
  2367.   defsymbol (&Qdebug_on_error, "debug-on-error");
  2368.  
  2369.   defsymbol (&Qmacro, "macro");
  2370.  
  2371.   /* Note that the process handling also uses Qexit, but we don't want
  2372.      to staticpro it twice, so we just do it here.  */
  2373.   defsymbol (&Qexit, "exit");
  2374.  
  2375.   defsymbol (&Qinteractive, "interactive");
  2376.  
  2377.   defsymbol (&Qcommandp, "commandp");
  2378.  
  2379.   defsymbol (&Qdefun, "defun");
  2380.  
  2381.   defsymbol (&Qand_rest, "&rest");
  2382.  
  2383.   defsymbol (&Qand_optional, "&optional");
  2384.  
  2385.   defsymbol (&Qeval, "eval");
  2386.  
  2387.   DEFVAR_LISP ("stack-trace-on-error", &Vstack_trace_on_error,
  2388.     "*Non-nil means automatically display a backtrace buffer\n\
  2389. after any error that is handled by the editor command loop.\n\
  2390. If the value is a list, an error only means to display a backtrace\n\
  2391. if one of its condition symbols appears in the list.");
  2392.   Vstack_trace_on_error = Qnil;
  2393.  
  2394.   DEFVAR_LISP ("debug-on-error", &Vdebug_on_error,
  2395.     "*Non-nil means enter debugger if an error is signalled.\n\
  2396. Does not apply to errors handled by `condition-case'.\n\
  2397. If the value is a list, an error only means to enter the debugger\n\
  2398. if one of its condition symbols appears in the list.\n\
  2399. See also variable `debug-on-quit'.");
  2400.   Vdebug_on_error = Qnil;
  2401.  
  2402.   DEFVAR_BOOL ("debug-on-quit", &debug_on_quit,
  2403.     "*Non-nil means enter debugger if quit is signalled (C-G, for example).\n\
  2404. Does not apply if quit is handled by a `condition-case'.");
  2405.   debug_on_quit = 0;
  2406.  
  2407.   DEFVAR_BOOL ("debug-on-next-call", &debug_on_next_call,
  2408.     "Non-nil means enter debugger before next `eval', `apply' or `funcall'.");
  2409.  
  2410.   DEFVAR_LISP ("debugger", &Vdebugger,
  2411.     "Function to call to invoke debugger.\n\
  2412. If due to frame exit, args are `exit' and the value being returned;\n\
  2413.  this function's value will be returned instead of that.\n\
  2414. If due to error, args are `error' and a list of the args to `signal'.\n\
  2415. If due to `apply' or `funcall' entry, one arg, `lambda'.\n\
  2416. If due to `eval' entry, one arg, t.");
  2417.   Vdebugger = Qnil;
  2418.  
  2419.   defsymbol (&Qmocklisp_arguments, "mocklisp-arguments");
  2420.  
  2421.   DEFVAR_LISP ("mocklisp-arguments", &Vmocklisp_arguments,
  2422.     "While in a mocklisp function, the list of its unevaluated args.");
  2423.   Vmocklisp_arguments = Qt;
  2424.  
  2425.   DEFVAR_LISP ("run-hooks", &Vrun_hooks,
  2426.     "Set to the function `run-hooks', if that function has been defined.\n\
  2427. Otherwise, nil (in a bare Emacs without preloaded Lisp code).");
  2428.   Vrun_hooks = Qnil;
  2429.  
  2430.   staticpro (&Vautoload_queue);
  2431.   Vautoload_queue = Qnil;
  2432.  
  2433.   defsubr (&Sor);
  2434.   defsubr (&Sand);
  2435.   defsubr (&Sif);
  2436.   defsubr (&Scond);
  2437.   defsubr (&Sprogn);
  2438.   defsubr (&Sprog1);
  2439.   defsubr (&Sprog2);
  2440.   defsubr (&Ssetq);
  2441.   defsubr (&Squote);
  2442.   defsubr (&Sfunction);
  2443.   defsubr (&Sdefun);
  2444.   defsubr (&Sdefmacro);
  2445.   defsubr (&Sdefvar);
  2446.   defsubr (&Sdefconst);
  2447.   defsubr (&Suser_variable_p);
  2448.   defsubr (&Slet);
  2449.   defsubr (&SletX);
  2450.   defsubr (&Swhile);
  2451.   defsubr (&Smacroexpand);
  2452.   defsubr (&Scatch);
  2453.   defsubr (&Sthrow);
  2454.   defsubr (&Sunwind_protect);
  2455.   defsubr (&Scondition_case);
  2456.   defsubr (&Ssignal);
  2457.   defsubr (&Sinteractive_p);
  2458.   defsubr (&Scommandp);
  2459.   defsubr (&Sautoload);
  2460.   defsubr (&Seval);
  2461.   defsubr (&Sapply);
  2462.   defsubr (&Sfuncall);
  2463.   defsubr (&Sbacktrace_debug);
  2464.   defsubr (&Sbacktrace);
  2465.   defsubr (&Sbacktrace_frame);
  2466. }
  2467.