(Fdefvar, Fdefconst, Fdefvaralias):
[bpt/emacs.git] / src / eval.c
index 2d15fa8..b48fbd5 100644 (file)
@@ -87,11 +87,11 @@ struct catchtag *catchlist;
 int gcpro_level;
 #endif
 
-Lisp_Object Qautoload, Qmacro, Qexit, Qinteractive, Qcommandp, Qdefun;
+Lisp_Object Qautoload, Qmacro, Qexit, Qinteractive, Qcommandp, Qdefun, Qdefvar;
 Lisp_Object Qinhibit_quit, Vinhibit_quit, Vquit_flag;
-Lisp_Object Qmocklisp_arguments, Vmocklisp_arguments, Qmocklisp;
 Lisp_Object Qand_rest, Qand_optional;
 Lisp_Object Qdebug_on_error;
+Lisp_Object Qdeclare;
 
 /* This holds either the symbol `run-hooks' or nil.
    It is nil at an early stage of startup, and when Emacs
@@ -120,7 +120,7 @@ struct specbinding *specpdl_ptr;
 
 /* Maximum size allowed for specpdl allocation */
 
-int max_specpdl_size;
+EMACS_INT max_specpdl_size;
 
 /* Depth in Lisp evaluations and function calls.  */
 
@@ -128,7 +128,7 @@ int lisp_eval_depth;
 
 /* Maximum allowed depth in Lisp evaluations and function calls.  */
 
-int max_lisp_eval_depth;
+EMACS_INT max_lisp_eval_depth;
 
 /* Nonzero means enter debugger before next function call */
 
@@ -190,12 +190,12 @@ Lisp_Object Vsignaling_function;
 
 int handling_signal;
 
-void specbind (), record_unwind_protect ();
+/* Function to process declarations in defmacro forms.  */
 
-Lisp_Object run_hook_with_args ();
+Lisp_Object Vmacro_declaration_function;
 
-Lisp_Object funcall_lambda ();
-extern Lisp_Object ml_apply (); /* Apply a mocklisp function to unevaluated argument list */
+
+static Lisp_Object funcall_lambda P_ ((Lisp_Object, int, Lisp_Object*));
 
 void
 init_eval_once ()
@@ -231,7 +231,7 @@ call_debugger (arg)
      Lisp_Object arg;
 {
   int debug_while_redisplaying;
-  int count = specpdl_ptr - specpdl;
+  int count = SPECPDL_INDEX ();
   Lisp_Object val;
   
   if (lisp_eval_depth + 20 > max_lisp_eval_depth)
@@ -409,22 +409,10 @@ usage: (progn BODY ...)  */)
      (args)
      Lisp_Object args;
 {
-  register Lisp_Object val, tem;
+  register Lisp_Object val;
   Lisp_Object args_left;
   struct gcpro gcpro1;
 
-  /* In Mocklisp code, symbols at the front of the progn arglist
-   are to be bound to zero. */
-  if (!EQ (Vmocklisp_arguments, Qt))
-    {
-      val = make_number (0);
-      while (!NILP (args) && (tem = Fcar (args), SYMBOLP (tem)))
-       {
-         QUIT;
-         specbind (tem, val), args = Fcdr (args);
-       }
-    }
-
   if (NILP(args))
     return Qnil;
 
@@ -658,20 +646,62 @@ usage: (defun NAME ARGLIST [DOCSTRING] BODY...)  */)
 
 DEFUN ("defmacro", Fdefmacro, Sdefmacro, 2, UNEVALLED, 0,
        doc: /* Define NAME as a macro.
-The definition is (macro lambda ARGLIST [DOCSTRING] BODY...).
+The actual definition looks like
+ (macro lambda ARGLIST [DOCSTRING] [DECL] BODY...).
 When the macro is called, as in (NAME ARGS...),
 the function (lambda ARGLIST BODY...) is applied to
 the list ARGS... as it appears in the expression,
 and the result should be a form to be evaluated instead of the original.
-usage: (defmacro NAME ARGLIST [DOCSTRING] BODY...)  */)
+
+DECL is a declaration, optional, which can specify how to indent
+calls to this macro and how Edebug should handle it.  It looks like this:
+  (declare SPECS...)
+The elements can look like this:
+  (indent INDENT)
+       Set NAME's `lisp-indent-function' property to INDENT.
+
+  (edebug DEBUG)
+       Set NAME's `edebug-form-spec' property to DEBUG.  (This is
+       equivalent to writing a `def-edebug-spec' for the macro.
+usage: (defmacro NAME ARGLIST [DOCSTRING] [DECL] BODY...)  */)
      (args)
      Lisp_Object args;
 {
   register Lisp_Object fn_name;
   register Lisp_Object defn;
+  Lisp_Object lambda_list, doc, tail;
 
   fn_name = Fcar (args);
-  defn = Fcons (Qmacro, Fcons (Qlambda, Fcdr (args)));
+  lambda_list = Fcar (Fcdr (args));
+  tail = Fcdr (Fcdr (args));
+
+  doc = Qnil;
+  if (STRINGP (Fcar (tail)))
+    {
+      doc = Fcar (tail);
+      tail = Fcdr (tail);
+    }
+
+  while (CONSP (Fcar (tail))
+        && EQ (Fcar (Fcar (tail)), Qdeclare))
+    {
+      if (!NILP (Vmacro_declaration_function))
+       {
+         struct gcpro gcpro1;
+         GCPRO1 (args);
+         call2 (Vmacro_declaration_function, fn_name, Fcar (tail));
+         UNGCPRO;
+       }
+      
+      tail = Fcdr (tail);
+    }
+
+  if (NILP (doc))
+    tail = Fcons (lambda_list, tail);
+  else
+    tail = Fcons (lambda_list, Fcons (doc, tail));
+  defn = Fcons (Qmacro, Fcons (Qlambda, tail));
+  
   if (!NILP (Vpurify_flag))
     defn = Fpurecopy (defn);
   Ffset (fn_name, defn);
@@ -680,16 +710,17 @@ usage: (defmacro NAME ARGLIST [DOCSTRING] BODY...)  */)
 }
 
 
-DEFUN ("defvaralias", Fdefvaralias, Sdefvaralias, 2, 2, 0,
+DEFUN ("defvaralias", Fdefvaralias, Sdefvaralias, 2, 3, 0,
        doc: /* Make SYMBOL a variable alias for symbol ALIASED.
 Setting the value of SYMBOL will subsequently set the value of ALIASED,
 and getting the value of SYMBOL will return the value ALIASED has.
-ALIASED nil means remove the alias; SYMBOL is unbound after that.  */)
-     (symbol, aliased)
-     Lisp_Object symbol, aliased;
+ALIASED nil means remove the alias; SYMBOL is unbound after that.
+Third arg DOCSTRING, if non-nil, is documentation for SYMBOL.  */)
+     (symbol, aliased, docstring)
+     Lisp_Object symbol, aliased, docstring;
 {
   struct Lisp_Symbol *sym;
-  
+
   CHECK_SYMBOL (symbol);
   CHECK_SYMBOL (aliased);
 
@@ -700,8 +731,10 @@ ALIASED nil means remove the alias; SYMBOL is unbound after that.  */)
   sym->indirect_variable = 1;
   sym->value = aliased;
   sym->constant = SYMBOL_CONSTANT_P (aliased);
-  LOADHIST_ATTACH (symbol);
-  
+  LOADHIST_ATTACH (Fcons (Qdefvar, symbol));
+  if (!NILP (docstring))
+    Fput (symbol, Qvariable_documentation, docstring);
+
   return aliased;
 }
 
@@ -744,14 +777,12 @@ usage: (defvar SYMBOL &optional INITVALUE DOCSTRING)  */)
            tem = Fpurecopy (tem);
          Fput (sym, Qvariable_documentation, tem);
        }
-      LOADHIST_ATTACH (sym);
+      LOADHIST_ATTACH (Fcons (Qdefvar, sym));
     }
   else
-    /* A (defvar <var>) should not take precedence in the load-history over
-       an earlier (defvar <var> <val>), so only add to history if the default
-       value is still unbound.  */
-    if (NILP (tem))
-      LOADHIST_ATTACH (sym);
+    /* Simple (defvar <var>) should not count as a definition at all.
+       It could get in the way of other definitions, and unloading this
+       package could try to make the variable unbound.  */
     
   return sym;
 }
@@ -784,7 +815,7 @@ usage: (defconst SYMBOL INITVALUE [DOCSTRING])  */)
        tem = Fpurecopy (tem);
       Fput (sym, Qvariable_documentation, tem);
     }
-  LOADHIST_ATTACH (sym);
+  LOADHIST_ATTACH (Fcons (Qdefvar, sym));
   return sym;
 }
 
@@ -807,7 +838,7 @@ on its property list).  */)
   if (INTEGERP (documentation) && XINT (documentation) < 0)
     return Qt;
   if (STRINGP (documentation)
-      && ((unsigned char) XSTRING (documentation)->data[0] == '*'))
+      && ((unsigned char) SREF (documentation, 0) == '*'))
     return Qt;
   /* If it is (STRING . INTEGER), a negative integer means a user variable.  */
   if (CONSP (documentation)
@@ -834,7 +865,7 @@ usage: (let* VARLIST BODY...)  */)
      Lisp_Object args;
 {
   Lisp_Object varlist, val, elt;
-  int count = specpdl_ptr - specpdl;
+  int count = SPECPDL_INDEX ();
   struct gcpro gcpro1, gcpro2, gcpro3;
 
   GCPRO3 (args, elt, varlist);
@@ -874,7 +905,7 @@ usage: (let VARLIST BODY...)  */)
 {
   Lisp_Object *temps, tem;
   register Lisp_Object elt, varlist;
-  int count = specpdl_ptr - specpdl;
+  int count = SPECPDL_INDEX ();
   register int argnum;
   struct gcpro gcpro1, gcpro2;
 
@@ -928,15 +959,14 @@ usage: (while TEST BODY...)  */)
      (args)
      Lisp_Object args;
 {
-  Lisp_Object test, body, tem;
+  Lisp_Object test, body;
   struct gcpro gcpro1, gcpro2;
 
   GCPRO2 (test, body);
 
   test = Fcar (args);
   body = Fcdr (args);
-  while (tem = Feval (test),
-        (!EQ (Vmocklisp_arguments, Qt) ? XINT (tem) : !NILP (tem)))
+  while (!NILP (Feval (test)))
     {
       QUIT;
       Fprogn (body);
@@ -1066,7 +1096,7 @@ internal_catch (tag, func, arg)
   c.backlist = backtrace_list;
   c.handlerlist = handlerlist;
   c.lisp_eval_depth = lisp_eval_depth;
-  c.pdlcount = specpdl_ptr - specpdl;
+  c.pdlcount = SPECPDL_INDEX ();
   c.poll_suppress_count = poll_suppress_count;
   c.gcpro = gcprolist;
   c.byte_stack = byte_stack_list;
@@ -1167,7 +1197,7 @@ usage: (unwind-protect BODYFORM UNWINDFORMS...)  */)
      Lisp_Object args;
 {
   Lisp_Object val;
-  int count = specpdl_ptr - specpdl;
+  int count = SPECPDL_INDEX ();
 
   record_unwind_protect (0, Fcdr (args));
   val = Feval (Fcar (args));
@@ -1233,7 +1263,7 @@ usage: (condition-case VAR BODYFORM HANDLERS...)  */)
   c.backlist = backtrace_list;
   c.handlerlist = handlerlist;
   c.lisp_eval_depth = lisp_eval_depth;
-  c.pdlcount = specpdl_ptr - specpdl;
+  c.pdlcount = SPECPDL_INDEX ();
   c.poll_suppress_count = poll_suppress_count;
   c.gcpro = gcprolist;
   c.byte_stack = byte_stack_list;
@@ -1298,7 +1328,7 @@ internal_condition_case (bfun, handlers, hfun)
   c.backlist = backtrace_list;
   c.handlerlist = handlerlist;
   c.lisp_eval_depth = lisp_eval_depth;
-  c.pdlcount = specpdl_ptr - specpdl;
+  c.pdlcount = SPECPDL_INDEX ();
   c.poll_suppress_count = poll_suppress_count;
   c.gcpro = gcprolist;
   c.byte_stack = byte_stack_list;
@@ -1338,7 +1368,7 @@ internal_condition_case_1 (bfun, arg, handlers, hfun)
   c.backlist = backtrace_list;
   c.handlerlist = handlerlist;
   c.lisp_eval_depth = lisp_eval_depth;
-  c.pdlcount = specpdl_ptr - specpdl;
+  c.pdlcount = SPECPDL_INDEX ();
   c.poll_suppress_count = poll_suppress_count;
   c.gcpro = gcprolist;
   c.byte_stack = byte_stack_list;
@@ -1381,7 +1411,7 @@ internal_condition_case_2 (bfun, nargs, args, handlers, hfun)
   c.backlist = backtrace_list;
   c.handlerlist = handlerlist;
   c.lisp_eval_depth = lisp_eval_depth;
-  c.pdlcount = specpdl_ptr - specpdl;
+  c.pdlcount = SPECPDL_INDEX ();
   c.poll_suppress_count = poll_suppress_count;
   c.gcpro = gcprolist;
   c.byte_stack = byte_stack_list;
@@ -1404,7 +1434,9 @@ internal_condition_case_2 (bfun, nargs, args, handlers, hfun)
 }
 
 \f
-static Lisp_Object find_handler_clause ();
+static Lisp_Object find_handler_clause P_ ((Lisp_Object, Lisp_Object,
+                                           Lisp_Object, Lisp_Object,
+                                           Lisp_Object *));
 
 DEFUN ("signal", Fsignal, Ssignal, 2, 2, 0,
        doc: /* Signal an error.  Args are ERROR-SYMBOL and associated DATA.
@@ -1422,7 +1454,8 @@ See also the function `condition-case'.  */)
      Lisp_Object error_symbol, data;
 {
   /* When memory is full, ERROR-SYMBOL is nil,
-     and DATA is (REAL-ERROR-SYMBOL . REAL-DATA).  */
+     and DATA is (REAL-ERROR-SYMBOL . REAL-DATA).
+     That is a special case--don't do this in other situations.  */
   register struct handler *allhandlers = handlerlist;
   Lisp_Object conditions;
   extern int gc_in_progress;
@@ -1430,7 +1463,6 @@ See also the function `condition-case'.  */)
   Lisp_Object debugger_value;
   Lisp_Object string;
   Lisp_Object real_error_symbol;
-  extern int display_hourglass_p;
   struct backtrace *bp;
 
   immediate_quit = handling_signal = 0;
@@ -1444,22 +1476,27 @@ See also the function `condition-case'.  */)
   else
     real_error_symbol = error_symbol;
 
+#if 0 /* rms: I don't know why this was here,
+        but it is surely wrong for an error that is handled.  */
 #ifdef HAVE_X_WINDOWS
   if (display_hourglass_p)
     cancel_hourglass ();
 #endif
+#endif 
 
   /* This hook is used by edebug.  */
-  if (! NILP (Vsignal_hook_function))
+  if (! NILP (Vsignal_hook_function)
+      && ! NILP (error_symbol))
     call2 (Vsignal_hook_function, error_symbol, data);
 
   conditions = Fget (real_error_symbol, Qerror_conditions);
 
   /* Remember from where signal was called.  Skip over the frame for
      `signal' itself.  If a frame for `error' follows, skip that,
-     too.  */
+     too.  Don't do this when ERROR_SYMBOL is nil, because that
+     is a memory-full error.  */
   Vsignaling_function = Qnil;
-  if (backtrace_list)
+  if (backtrace_list && !NILP (error_symbol))
     {
       bp = backtrace_list->next;
       if (bp && bp->function && EQ (*bp->function, Qerror))
@@ -1481,13 +1518,6 @@ See also the function `condition-case'.  */)
       clause = find_handler_clause (handlerlist->handler, conditions,
                                    error_symbol, data, &debugger_value);
 
-#if 0 /* Most callers are not prepared to handle gc if this returns.
-        So, since this feature is not very useful, take it out.  */
-      /* If have called debugger and user wants to continue,
-        just return nil.  */
-      if (EQ (clause, Qlambda))
-       return debugger_value;
-#else
       if (EQ (clause, Qlambda))
        {
          /* We can't return values to code which signaled an error, but we
@@ -1497,7 +1527,6 @@ See also the function `condition-case'.  */)
          else
            error ("Cannot return from the debugger in an error");
        }
-#endif
 
       if (!NILP (clause))
        {
@@ -1526,7 +1555,7 @@ See also the function `condition-case'.  */)
     data = Fcons (error_symbol, data);
 
   string = Ferror_message_string (data);
-  fatal ("%s", XSTRING (string)->data, 0);
+  fatal ("%s", SDATA (string), 0);
 }
 
 /* Return nonzero iff LIST is a non-nil atom or
@@ -1616,7 +1645,7 @@ find_handler_clause (handlers, conditions, sig, data, debugger_value_ptr)
       || !NILP (Vdebug_on_signal)) /* This says call debugger even if
                                      there is a handler.  */
     {
-      int count = specpdl_ptr - specpdl;
+      int count = SPECPDL_INDEX ();
       int debugger_called = 0;
       Lisp_Object sig_symbol, combined_data;
       /* This is set to 1 if we are handling a memory-full error,
@@ -1743,7 +1772,7 @@ error (m, a1, a2, a3)
   abort ();
 }
 \f
-DEFUN ("commandp", Fcommandp, Scommandp, 1, 1, 0,
+DEFUN ("commandp", Fcommandp, Scommandp, 1, 2, 0,
        doc: /* Non-nil if FUNCTION makes provisions for interactive calling.
 This means it contains a description for how to read arguments to give it.
 The value is nil for an invalid function or a symbol with no function
@@ -1754,9 +1783,12 @@ as keyboard macros), lambda-expressions that contain a top-level call
 to `interactive', autoload definitions made by `autoload' with non-nil
 fourth argument, and some of the built-in functions of Lisp.
 
-Also, a symbol satisfies `commandp' if its function definition does so.  */)
-     (function)
-     Lisp_Object function;
+Also, a symbol satisfies `commandp' if its function definition does so.
+
+If the optional argument FOR-CALL-INTERACTIVELY is non-nil,
+then strings and vectors are not accepted.  */)
+     (function, for_call_interactively)
+     Lisp_Object function, for_call_interactively;
 {
   register Lisp_Object fun;
   register Lisp_Object funcar;
@@ -1781,11 +1813,11 @@ Also, a symbol satisfies `commandp' if its function definition does so.  */)
      have an element whose index is COMPILED_INTERACTIVE, which is
      where the interactive spec is stored.  */
   else if (COMPILEDP (fun))
-    return ((XVECTOR (fun)->size & PSEUDOVECTOR_SIZE_MASK) > COMPILED_INTERACTIVE
+    return ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) > COMPILED_INTERACTIVE
            ? Qt : Qnil);
 
   /* Strings and vectors are keyboard macros.  */
-  if (STRINGP (fun) || VECTORP (fun))
+  if (NILP (for_call_interactively) && (STRINGP (fun) || VECTORP (fun)))
     return Qt;
 
   /* Lists may represent commands.  */
@@ -1796,8 +1828,6 @@ Also, a symbol satisfies `commandp' if its function definition does so.  */)
     return Fsignal (Qinvalid_function, Fcons (fun, Qnil));
   if (EQ (funcar, Qlambda))
     return Fassq (Qinteractive, Fcdr (Fcdr (fun)));
-  if (EQ (funcar, Qmocklisp))
-    return Qt;  /* All mocklisp functions can be called interactively */
   if (EQ (funcar, Qautoload))
     return Fcar (Fcdr (Fcdr (Fcdr (fun))));
   else
@@ -1883,10 +1913,16 @@ void
 do_autoload (fundef, funname)
      Lisp_Object fundef, funname;
 {
-  int count = specpdl_ptr - specpdl;
+  int count = SPECPDL_INDEX ();
   Lisp_Object fun, queue, first, second;
   struct gcpro gcpro1, gcpro2, gcpro3;
 
+  /* This is to make sure that loadup.el gives a clear picture
+     of what files are preloaded and when.  */
+  if (! NILP (Vpurify_flag))
+    error ("Attempt to autoload %s while preparing to dump",
+          SDATA (SYMBOL_NAME (funname)));
+
   fun = funname;
   CHECK_SYMBOL (funname);
   GCPRO3 (fun, funname, fundef);
@@ -1924,7 +1960,7 @@ do_autoload (fundef, funname)
 
   if (!NILP (Fequal (fun, fundef)))
     error ("Autoloading failed to define function %s",
-          XSYMBOL (funname)->name->data);
+          SDATA (SYMBOL_NAME (funname)));
   UNGCPRO;
 }
 
@@ -1943,16 +1979,7 @@ DEFUN ("eval", Feval, Seval, 1, 1, 0,
     abort ();
   
   if (SYMBOLP (form))
-    {
-      if (EQ (Vmocklisp_arguments, Qt))
-        return Fsymbol_value (form);
-      val = Fsymbol_value (form);
-      if (NILP (val))
-       XSETFASTINT (val, 0);
-      else if (EQ (val, Qt))
-       XSETFASTINT (val, 1);
-      return val;
-    }
+    return Fsymbol_value (form);
   if (!CONSP (form))
     return form;
 
@@ -2120,19 +2147,10 @@ DEFUN ("eval", Feval, Seval, 1, 1, 0,
        val = Feval (apply1 (Fcdr (fun), original_args));
       else if (EQ (funcar, Qlambda))
        val = apply_lambda (fun, original_args, 1);
-      else if (EQ (funcar, Qmocklisp))
-       val = ml_apply (fun, original_args);
       else
        return Fsignal (Qinvalid_function, Fcons (fun, Qnil));
     }
  done:
-  if (!EQ (Vmocklisp_arguments, Qt))
-    {
-      if (NILP (val))
-       XSETFASTINT (val, 0);
-      else if (EQ (val, Qt))
-       XSETFASTINT (val, 1);
-    }
   lisp_eval_depth--;
   if (backtrace.debug_on_exit)
     val = call_debugger (Fcons (Qexit, Fcons (val, Qnil)));
@@ -2224,6 +2242,8 @@ usage: (apply FUNCTION &rest ARGUMENTS)  */)
 /* Run hook variables in various ways.  */
 
 enum run_hooks_condition {to_completion, until_success, until_failure};
+static Lisp_Object run_hook_with_args P_ ((int, Lisp_Object *,
+                                          enum run_hooks_condition));
 
 DEFUN ("run-hooks", Frun_hooks, Srun_hooks, 0, MANY, 0,
        doc: /* Run each hook in HOOKS.  Major mode functions use this.
@@ -2321,7 +2341,7 @@ usage: (run-hook-with-args-until-failure HOOK &rest ARGS)  */)
    The caller (or its caller, etc) must gcpro all of ARGS,
    except that it isn't necessary to gcpro ARGS[0].  */
 
-Lisp_Object
+static Lisp_Object
 run_hook_with_args (nargs, args, cond)
      int nargs;
      Lisp_Object *args;
@@ -2767,8 +2787,6 @@ usage: (funcall FUNCTION &rest ARGUMENTS)  */)
        return Fsignal (Qinvalid_function, Fcons (fun, Qnil));
       if (EQ (funcar, Qlambda))
        val = funcall_lambda (fun, numargs, args + 1);
-      else if (EQ (funcar, Qmocklisp))
-       val = ml_apply (fun, Flist (numargs, args + 1));
       else if (EQ (funcar, Qautoload))
        {
          do_autoload (fun, args[0]);
@@ -2834,19 +2852,16 @@ apply_lambda (fun, args, eval_flag)
    and return the result of evaluation.
    FUN must be either a lambda-expression or a compiled-code object.  */
 
-Lisp_Object
+static Lisp_Object
 funcall_lambda (fun, nargs, arg_vector)
      Lisp_Object fun;
      int nargs;
      register Lisp_Object *arg_vector;
 {
   Lisp_Object val, syms_left, next;
-  int count = specpdl_ptr - specpdl;
+  int count = SPECPDL_INDEX ();
   int i, optional, rest;
 
-  if (NILP (Vmocklisp_arguments))
-    specbind (Qmocklisp_arguments, Qt);   /* t means NOT mocklisp! */
-
   if (CONSP (fun))
     {
       syms_left = XCDR (fun);
@@ -2856,7 +2871,7 @@ funcall_lambda (fun, nargs, arg_vector)
        return Fsignal (Qinvalid_function, Fcons (fun, Qnil));
     }
   else if (COMPILEDP (fun))
-    syms_left = XVECTOR (fun)->contents[COMPILED_ARGLIST];
+    syms_left = AREF (fun, COMPILED_ARGLIST);
   else
     abort ();
 
@@ -2899,11 +2914,11 @@ funcall_lambda (fun, nargs, arg_vector)
     {
       /* If we have not actually read the bytecode string
         and constants vector yet, fetch them from the file.  */
-      if (CONSP (XVECTOR (fun)->contents[COMPILED_BYTECODE]))
+      if (CONSP (AREF (fun, COMPILED_BYTECODE)))
        Ffetch_bytecode (fun);
-      val = Fbyte_code (XVECTOR (fun)->contents[COMPILED_BYTECODE],
-                       XVECTOR (fun)->contents[COMPILED_CONSTANTS],
-                       XVECTOR (fun)->contents[COMPILED_STACK_DEPTH]);
+      val = Fbyte_code (AREF (fun, COMPILED_BYTECODE),
+                       AREF (fun, COMPILED_CONSTANTS),
+                       AREF (fun, COMPILED_STACK_DEPTH));
     }
   
   return unbind_to (count, val);
@@ -2917,14 +2932,19 @@ DEFUN ("fetch-bytecode", Ffetch_bytecode, Sfetch_bytecode,
 {
   Lisp_Object tem;
 
-  if (COMPILEDP (object)
-      && CONSP (XVECTOR (object)->contents[COMPILED_BYTECODE]))
+  if (COMPILEDP (object) && CONSP (AREF (object, COMPILED_BYTECODE)))
     {
-      tem = read_doc_string (XVECTOR (object)->contents[COMPILED_BYTECODE]);
+      tem = read_doc_string (AREF (object, COMPILED_BYTECODE));
       if (!CONSP (tem))
-       error ("invalid byte code");
-      XVECTOR (object)->contents[COMPILED_BYTECODE] = XCAR (tem);
-      XVECTOR (object)->contents[COMPILED_CONSTANTS] = XCDR (tem);
+       {
+         tem = AREF (object, COMPILED_BYTECODE);
+         if (CONSP (tem) && STRINGP (XCAR (tem)))
+           error ("Invalid byte code in %s", SDATA (XCAR (tem)));
+         else
+           error ("Invalid byte code");
+       }
+      AREF (object, COMPILED_BYTECODE) = XCAR (tem);
+      AREF (object, COMPILED_CONSTANTS) = XCDR (tem);
     }
   return object;
 }
@@ -2932,7 +2952,7 @@ DEFUN ("fetch-bytecode", Ffetch_bytecode, Sfetch_bytecode,
 void
 grow_specpdl ()
 {
-  register int count = specpdl_ptr - specpdl;
+  register int count = SPECPDL_INDEX ();
   if (specpdl_size >= max_specpdl_size)
     {
       if (max_specpdl_size < 400)
@@ -3231,14 +3251,19 @@ syms_of_eval ()
   DEFVAR_INT ("max-specpdl-size", &max_specpdl_size,
              doc: /* *Limit on number of Lisp variable bindings & unwind-protects.
 If Lisp code tries to make more than this many at once,
-an error is signaled.  */);
+an error is signaled.
+You can safely use a value considerably larger than the default value,
+if that proves inconveniently small.  However, if you increase it too far,
+Emacs could run out of memory trying to make the stack bigger.  */);
 
   DEFVAR_INT ("max-lisp-eval-depth", &max_lisp_eval_depth,
              doc: /* *Limit on depth in `eval', `apply' and `funcall' before error.
-This limit is to catch infinite recursions for you before they cause
+
+This limit serves to catch infinite recursions for you before they cause
 actual stack overflow in C, which would be fatal for Emacs.
 You can safely make it considerably larger than its default value,
-if that proves inconveniently small.  */);
+if that proves inconveniently small.  However, if you increase it too far,
+Emacs could overflow the real C stack, and crash.  */);
 
   DEFVAR_LISP ("quit-flag", &Vquit_flag,
               doc: /* Non-nil causes `eval' to abort, unless `inhibit-quit' is non-nil.
@@ -3265,6 +3290,9 @@ before making `inhibit-quit' nil.  */);
   Qmacro = intern ("macro");
   staticpro (&Qmacro);
 
+  Qdeclare = intern ("declare");
+  staticpro (&Qdeclare);
+  
   /* Note that the process handling also uses Qexit, but we don't want
      to staticpro it twice, so we just do it here.  */
   Qexit = intern ("exit");
@@ -3279,6 +3307,9 @@ before making `inhibit-quit' nil.  */);
   Qdefun = intern ("defun");
   staticpro (&Qdefun);
 
+  Qdefvar = intern ("defvar");
+  staticpro (&Qdefvar);
+
   Qand_rest = intern ("&rest");
   staticpro (&Qand_rest);
 
@@ -3286,8 +3317,9 @@ before making `inhibit-quit' nil.  */);
   staticpro (&Qand_optional);
 
   DEFVAR_LISP ("stack-trace-on-error", &Vstack_trace_on_error,
-              doc: /* *Non-nil means automatically display a backtrace buffer
-after any error that is handled by the editor command loop.
+              doc: /* *Non-nil means errors display a backtrace buffer.
+More precisely, this happens for any error that is handled
+by the editor command loop.
 If the value is a list, an error only means to display a backtrace
 if one of its condition symbols appears in the list.  */);
   Vstack_trace_on_error = Qnil;
@@ -3343,18 +3375,20 @@ It receives the same arguments that `signal' was given.
 The Edebug package uses this to regain control.  */);
   Vsignal_hook_function = Qnil;
 
-  Qmocklisp_arguments = intern ("mocklisp-arguments");
-  staticpro (&Qmocklisp_arguments);
-  DEFVAR_LISP ("mocklisp-arguments", &Vmocklisp_arguments,
-              doc: /* While in a mocklisp function, the list of its unevaluated args.  */);
-  Vmocklisp_arguments = Qt;
-
   DEFVAR_LISP ("debug-on-signal", &Vdebug_on_signal,
               doc: /* *Non-nil means call the debugger regardless of condition handlers.
 Note that `debug-on-error', `debug-on-quit' and friends
 still determine whether to handle the particular condition.  */);
   Vdebug_on_signal = Qnil;
 
+  DEFVAR_LISP ("macro-declaration-function", &Vmacro_declaration_function,
+              doc: /* Function to process declarations in a macro definition.
+The function will be called with two args MACRO and DECL.
+MACRO is the name of the macro being defined.
+DECL is a list `(declare ...)' containing the declarations.
+The value the function returns is not used.  */);
+  Vmacro_declaration_function = Qnil;
+
   Vrun_hooks = intern ("run-hooks");
   staticpro (&Vrun_hooks);