/* Evaluator for GNU Emacs Lisp interpreter.
- Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995 Free Software Foundation, Inc.
+ Copyright (C) 1985, 86, 87, 93, 94, 95, 99, 2000
+ Free Software Foundation, Inc.
This file is part of GNU Emacs.
#include <config.h>
#include "lisp.h"
#include "blockinput.h"
-
-#ifndef standalone
#include "commands.h"
#include "keyboard.h"
-#else
-#define INTERACTIVE 1
-#endif
-
+#include "dispextern.h"
#include <setjmp.h>
/* This definition is duplicated in alloc.c and keyboard.c */
int lisp_eval_depth;
int pdlcount;
int poll_suppress_count;
+ struct byte_stack *byte_stack;
};
struct catchtag *catchlist;
+#ifdef DEBUG_GCPRO
+/* Count levels of GCPRO to detect failure to UNGCPRO. */
+int gcpro_level;
+#endif
+
Lisp_Object Qautoload, Qmacro, Qexit, Qinteractive, Qcommandp, Qdefun;
Lisp_Object Qinhibit_quit, Vinhibit_quit, Vquit_flag;
Lisp_Object Qmocklisp_arguments, Vmocklisp_arguments, Qmocklisp;
/* Nonzero means enter debugger before next function call */
int debug_on_next_call;
+/* Non-zero means debuffer may continue. This is zero when the
+ debugger is called during redisplay, where it might not be safe to
+ continue the interrupted redisplay. */
+
+int debugger_may_continue;
+
/* List of conditions (non-nil atom means all) which cause a backtrace
if an error is handled by the command loop's error handler. */
Lisp_Object Vstack_trace_on_error;
is handled by the command loop's error handler. */
int debug_on_quit;
-/* The value of num_nonmacro_input_chars as of the last time we
+/* The value of num_nonmacro_input_events as of the last time we
started to enter the debugger. If we decide to enter the debugger
- again when this is still equal to num_nonmacro_input_chars, then we
+ again when this is still equal to num_nonmacro_input_events, then we
know that the debugger itself has an error, and we should just
signal the error instead of entering an infinite loop of debugger
invocations. */
Lisp_Object funcall_lambda ();
extern Lisp_Object ml_apply (); /* Apply a mocklisp function to unevaluated argument list */
+void
init_eval_once ()
{
specpdl_size = 50;
specpdl = (struct specbinding *) xmalloc (specpdl_size * sizeof (struct specbinding));
specpdl_ptr = specpdl;
max_specpdl_size = 600;
- max_lisp_eval_depth = 200;
+ max_lisp_eval_depth = 300;
Vrun_hooks = Qnil;
}
+void
init_eval ()
{
specpdl_ptr = specpdl;
Vquit_flag = Qnil;
debug_on_next_call = 0;
lisp_eval_depth = 0;
- /* This is less than the initial value of num_nonmacro_input_chars. */
+#ifdef DEBUG_GCPRO
+ gcpro_level = 0;
+#endif
+ /* This is less than the initial value of num_nonmacro_input_events. */
when_entered_debugger = -1;
}
call_debugger (arg)
Lisp_Object arg;
{
+ int debug_while_redisplaying;
+ int count = specpdl_ptr - specpdl;
+ Lisp_Object val;
+
if (lisp_eval_depth + 20 > max_lisp_eval_depth)
max_lisp_eval_depth = lisp_eval_depth + 20;
+
if (specpdl_size + 40 > max_specpdl_size)
max_specpdl_size = specpdl_size + 40;
+
debug_on_next_call = 0;
- when_entered_debugger = num_nonmacro_input_chars;
- return apply1 (Vdebugger, arg);
+ when_entered_debugger = num_nonmacro_input_events;
+
+ /* Resetting redisplaying_p to 0 makes sure that debug output is
+ displayed if the debugger is invoked during redisplay. */
+ debug_while_redisplaying = redisplaying_p;
+ redisplaying_p = 0;
+ specbind (intern ("debugger-may-continue"),
+ debug_while_redisplaying ? Qnil : Qt);
+
+ val = apply1 (Vdebugger, arg);
+
+ /* Interrupting redisplay and resuming it later is not safe under
+ all circumstances. So, when the debugger returns, abort the
+ interupted redisplay by going back to the top-level. */
+ if (debug_while_redisplaying)
+ Ftop_level ();
+
+ return unbind_to (count, val);
}
+void
do_debug_on_call (code)
Lisp_Object code;
{
}
DEFUN ("if", Fif, Sif, 2, UNEVALLED, 0,
- "(if COND THEN ELSE...): if COND yields non-nil, do THEN, else do ELSE...\n\
+ "If COND yields non-nil, do THEN, else do ELSE...\n\
Returns the value of THEN or the value of the last of the ELSE's.\n\
THEN must be one expression, but ELSE... can be zero or more expressions.\n\
If COND yields nil, and there are no ELSE's, the value is nil.")
}
DEFUN ("cond", Fcond, Scond, 0, UNEVALLED, 0,
- "(cond CLAUSES...): try each clause until one succeeds.\n\
+ "Try each clause until one succeeds.\n\
Each clause looks like (CONDITION BODY...). CONDITION is evaluated\n\
and, if the value is non-nil, this clause succeeds:\n\
then the expressions in BODY are evaluated and the last one's\n\
val = Feval (Fcar (clause));
if (!NILP (val))
{
- if (!EQ (XCONS (clause)->cdr, Qnil))
- val = Fprogn (XCONS (clause)->cdr);
+ if (!EQ (XCDR (clause), Qnil))
+ val = Fprogn (XCDR (clause));
break;
}
- args = XCONS (args)->cdr;
+ args = XCDR (args);
}
UNGCPRO;
}
DEFUN ("progn", Fprogn, Sprogn, 0, UNEVALLED, 0,
- "(progn BODY...): eval BODY forms sequentially and return value of last one.")
+ "Eval BODY forms sequentially and return value of last one.")
(args)
Lisp_Object args;
{
}
DEFUN ("prog1", Fprog1, Sprog1, 1, UNEVALLED, 0,
- "(prog1 FIRST BODY...): eval FIRST and BODY sequentially; value from FIRST.\n\
+ "Eval FIRST and BODY sequentially; value from FIRST.\n\
The value of FIRST is saved during the evaluation of the remaining args,\n\
whose values are discarded.")
(args)
}
DEFUN ("prog2", Fprog2, Sprog2, 2, UNEVALLED, 0,
- "(prog2 X Y BODY...): eval X, Y and BODY sequentially; value from Y.\n\
+ "Eval X, Y and BODY sequentially; value from Y.\n\
The value of Y is saved during the evaluation of the remaining args,\n\
whose values are discarded.")
(args)
}
DEFUN ("setq", Fsetq, Ssetq, 0, UNEVALLED, 0,
- "(setq SYM VAL SYM VAL ...): set each SYM to the value of its VAL.\n\
+ "Set each SYM to the value of its VAL.\n\
The symbols SYM are variables; they are literal (not evaluated).\n\
The values VAL are expressions; they are evaluated.\n\
Thus, (setq x (1+ y)) sets `x' to the value of `(1+ y)'.\n\
}
DEFUN ("defun", Fdefun, Sdefun, 2, UNEVALLED, 0,
- "(defun NAME ARGLIST [DOCSTRING] BODY...): define NAME as a function.\n\
+ "Define NAME as a function.\n\
The definition is (lambda ARGLIST [DOCSTRING] BODY...).\n\
See also the function `interactive'.")
(args)
}
DEFUN ("defmacro", Fdefmacro, Sdefmacro, 2, UNEVALLED, 0,
- "(defmacro NAME ARGLIST [DOCSTRING] BODY...): define NAME as a macro.\n\
+ "Define NAME as a macro.\n\
The definition is (macro lambda ARGLIST [DOCSTRING] BODY...).\n\
When the macro is called, as in (NAME ARGS...),\n\
the function (lambda ARGLIST BODY...) is applied to\n\
}
DEFUN ("defvar", Fdefvar, Sdefvar, 1, UNEVALLED, 0,
- "(defvar SYMBOL INITVALUE DOCSTRING): define SYMBOL as a variable.\n\
+ "Define SYMBOL as a variable.\n\
You are not required to define a variable in order to use it,\n\
but the definition can supply documentation and an initial value\n\
in a way that tags can recognize.\n\n\
}
DEFUN ("defconst", Fdefconst, Sdefconst, 2, UNEVALLED, 0,
- "(defconst SYMBOL INITVALUE DOCSTRING): define SYMBOL as a constant variable.\n\
-The intent is that programs do not change this value, but users may.\n\
+ "Define SYMBOL as a constant variable.\n\
+The intent is that neither programs nor users should ever change this value.\n\
Always sets the value of SYMBOL to the result of evalling INITVALUE.\n\
If SYMBOL is buffer-local, its default value is what is set;\n\
buffer-local values are not affected.\n\
-DOCSTRING is optional.\n\
-If DOCSTRING starts with *, this variable is identified as a user option.\n\
- This means that M-x set-variable and M-x edit-options recognize it.\n\n\
-Note: do not use `defconst' for user options in libraries that are not\n\
-normally loaded, since it is useful for users to be able to specify\n\
-their own values for such variables before loading the library.\n\
-Since `defconst' unconditionally assigns the variable,\n\
-it would override the user's choice.")
+DOCSTRING is optional.")
(args)
Lisp_Object args;
{
if (!NILP (Fcdr (Fcdr (Fcdr (args)))))
error ("too many arguments");
- Fset_default (sym, Feval (Fcar (Fcdr (args))));
+ tem = Feval (Fcar (Fcdr (args)));
+ if (!NILP (Vpurify_flag))
+ tem = Fpurecopy (tem);
+ Fset_default (sym, tem);
tem = Fcar (Fcdr (Fcdr (args)));
if (!NILP (tem))
{
"Returns t if VARIABLE is intended to be set and modified by users.\n\
\(The alternative is a variable used internally in a Lisp program.)\n\
Determined by whether the first character of the documentation\n\
-for the variable is `*'.")
+for the variable is `*' or if the variable is customizable (has a non-nil\n\
+value of any of `custom-type', `custom-loads' or `standard-value'\n\
+on its property list).")
(variable)
Lisp_Object variable;
{
Lisp_Object documentation;
+ if (!SYMBOLP (variable))
+ return Qnil;
+
documentation = Fget (variable, Qvariable_documentation);
if (INTEGERP (documentation) && XINT (documentation) < 0)
return Qt;
return Qt;
/* If it is (STRING . INTEGER), a negative integer means a user variable. */
if (CONSP (documentation)
- && STRINGP (XCONS (documentation)->car)
- && INTEGERP (XCONS (documentation)->cdr)
- && XINT (XCONS (documentation)->cdr) < 0)
+ && STRINGP (XCAR (documentation))
+ && INTEGERP (XCDR (documentation))
+ && XINT (XCDR (documentation)) < 0)
+ return Qt;
+ /* Customizable? */
+ if ((!NILP (Fget (variable, intern ("custom-type"))))
+ || (!NILP (Fget (variable, intern ("custom-loads"))))
+ || (!NILP (Fget (variable, intern ("standard-value")))))
return Qt;
return Qnil;
}
\f
DEFUN ("let*", FletX, SletX, 1, UNEVALLED, 0,
- "(let* VARLIST BODY...): bind variables according to VARLIST then eval BODY.\n\
+ "Bind variables according to VARLIST then eval BODY.\n\
The value of the last form in BODY is returned.\n\
Each element of VARLIST is a symbol (which is bound to nil)\n\
or a list (SYMBOL VALUEFORM) (which binds SYMBOL to the value of VALUEFORM).\n\
}
DEFUN ("let", Flet, Slet, 1, UNEVALLED, 0,
- "(let VARLIST BODY...): bind variables according to VARLIST then eval BODY.\n\
+ "Bind variables according to VARLIST then eval BODY.\n\
The value of the last form in BODY is returned.\n\
Each element of VARLIST is a symbol (which is bound to nil)\n\
or a list (SYMBOL VALUEFORM) (which binds SYMBOL to the value of VALUEFORM).\n\
}
DEFUN ("while", Fwhile, Swhile, 1, UNEVALLED, 0,
- "(while TEST BODY...): if TEST yields non-nil, eval BODY... and repeat.\n\
+ "If TEST yields non-nil, eval BODY... and repeat.\n\
The order of execution is thus TEST, BODY, TEST, BODY and so on\n\
until TEST returns nil.")
(args)
if (!CONSP (form))
break;
/* Set SYM, give DEF and TEM right values in case SYM is not a symbol. */
- def = sym = XCONS (form)->car;
+ def = sym = XCAR (form);
tem = Qnil;
/* Trace symbols aliases to other symbols
until we get a symbol that is not an alias. */
if (EQ (def, Qunbound) || !CONSP (def))
/* Not defined or definition not suitable */
break;
- if (EQ (XCONS (def)->car, Qautoload))
+ if (EQ (XCAR (def), Qautoload))
{
/* Autoloading function: will it be a macro when loaded? */
tem = Fnth (make_number (4), def);
else
break;
}
- else if (!EQ (XCONS (def)->car, Qmacro))
+ else if (!EQ (XCAR (def), Qmacro))
break;
- else expander = XCONS (def)->cdr;
+ else expander = XCDR (def);
}
else
{
- expander = XCONS (tem)->cdr;
+ expander = XCDR (tem);
if (NILP (expander))
break;
}
- form = apply1 (expander, XCONS (form)->cdr);
+ form = apply1 (expander, XCDR (form));
}
return form;
}
\f
DEFUN ("catch", Fcatch, Scatch, 1, UNEVALLED, 0,
- "(catch TAG BODY...): eval BODY allowing nonlocal exits using `throw'.\n\
-TAG is evalled to get the tag to use. Then the BODY is executed.\n\
+ "Eval BODY allowing nonlocal exits using `throw'.\n\
+TAG is evalled to get the tag to use; it must not be nil.\n\
+\n\
+Then the BODY is executed.\n\
Within BODY, (throw TAG) with same tag exits BODY and exits this `catch'.\n\
If no throw happens, `catch' returns the value of the last BODY form.\n\
If a throw happens, it specifies the value to return from `catch'.")
c.pdlcount = specpdl_ptr - specpdl;
c.poll_suppress_count = poll_suppress_count;
c.gcpro = gcprolist;
+ c.byte_stack = byte_stack_list;
catchlist = &c;
/* Call FUNC. */
}
while (! last_time);
+ byte_stack_list = catch->byte_stack;
gcprolist = catch->gcpro;
+#ifdef DEBUG_GCPRO
+ if (gcprolist != 0)
+ gcpro_level = gcprolist->level + 1;
+ else
+ gcpro_level = 0;
+#endif
backtrace_list = catch->backlist;
lisp_eval_depth = catch->lisp_eval_depth;
}
DEFUN ("throw", Fthrow, Sthrow, 2, 2, 0,
- "(throw TAG VALUE): throw to the catch for TAG and return VALUE from it.\n\
+ "Throw to the catch for TAG and return VALUE from it.\n\
Both TAG and VALUE are evalled.")
(tag, value)
register Lisp_Object tag, value;
DEFUN ("unwind-protect", Funwind_protect, Sunwind_protect, 1, UNEVALLED, 0,
"Do BODYFORM, protecting with UNWINDFORMS.\n\
-Usage looks like (unwind-protect BODYFORM UNWINDFORMS...).\n\
If BODYFORM completes normally, its value is returned\n\
after executing the UNWINDFORMS.\n\
If BODYFORM exits nonlocally, the UNWINDFORMS are executed anyway.")
DEFUN ("condition-case", Fcondition_case, Scondition_case, 2, UNEVALLED, 0,
"Regain control when an error is signaled.\n\
-Usage looks like (condition-case VAR BODYFORM HANDLERS...).\n\
executes BODYFORM and returns its value if no error happens.\n\
Each element of HANDLERS looks like (CONDITION-NAME BODY...)\n\
where the BODY is made of Lisp expressions.\n\n\
tem = Fcar (val);
if (! (NILP (tem)
|| (CONSP (tem)
- && (SYMBOLP (XCONS (tem)->car)
- || CONSP (XCONS (tem)->car)))))
+ && (SYMBOLP (XCAR (tem))
+ || CONSP (XCAR (tem))))))
error ("Invalid condition handler", tem);
}
c.pdlcount = specpdl_ptr - specpdl;
c.poll_suppress_count = poll_suppress_count;
c.gcpro = gcprolist;
+ c.byte_stack = byte_stack_list;
if (_setjmp (c.jmp))
{
if (!NILP (h.var))
c.pdlcount = specpdl_ptr - specpdl;
c.poll_suppress_count = poll_suppress_count;
c.gcpro = gcprolist;
+ c.byte_stack = byte_stack_list;
if (_setjmp (c.jmp))
{
return (*hfun) (c.val);
c.pdlcount = specpdl_ptr - specpdl;
c.poll_suppress_count = poll_suppress_count;
c.gcpro = gcprolist;
+ c.byte_stack = byte_stack_list;
if (_setjmp (c.jmp))
{
return (*hfun) (c.val);
(error_symbol, data)
Lisp_Object error_symbol, data;
{
+ /* When memory is full, ERROR-SYMBOL is nil,
+ and DATA is (REAL-ERROR-SYMBOL . REAL-DATA). */
register struct handler *allhandlers = handlerlist;
Lisp_Object conditions;
extern int gc_in_progress;
extern int waiting_for_input;
Lisp_Object debugger_value;
Lisp_Object string;
+ Lisp_Object real_error_symbol;
+ extern int display_busy_cursor_p;
- quit_error_check ();
immediate_quit = 0;
if (gc_in_progress || waiting_for_input)
abort ();
-#ifdef HAVE_WINDOW_SYSTEM
TOTALLY_UNBLOCK_INPUT;
+
+ if (NILP (error_symbol))
+ real_error_symbol = Fcar (data);
+ else
+ real_error_symbol = error_symbol;
+
+#ifdef HAVE_X_WINDOWS
+ if (display_busy_cursor_p)
+ Fx_hide_busy_cursor (Qt);
#endif
/* This hook is used by edebug. */
if (! NILP (Vsignal_hook_function))
- Ffuncall (Vsignal_hook_function, error_symbol, data);
+ call2 (Vsignal_hook_function, error_symbol, data);
- conditions = Fget (error_symbol, Qerror_conditions);
+ conditions = Fget (real_error_symbol, Qerror_conditions);
for (; handlerlist; handlerlist = handlerlist->next)
{
{
/* We can't return values to code which signaled an error, but we
can continue code which has signaled a quit. */
- if (EQ (error_symbol, Qquit))
+ if (EQ (real_error_symbol, Qquit))
return Qnil;
else
error ("Cannot return from the debugger in an error");
struct handler *h = handlerlist;
handlerlist = allhandlers;
- if (EQ (data, memory_signal_data))
- unwind_data = memory_signal_data;
+
+ if (NILP (error_symbol))
+ unwind_data = data;
else
unwind_data = Fcons (error_symbol, data);
h->chosen_clause = clause;
if (catchlist != 0)
Fthrow (Qtop_level, Qt);
- if (! EQ (data, memory_signal_data))
+ if (! NILP (error_symbol))
data = Fcons (error_symbol, data);
string = Ferror_message_string (data);
- fatal (XSTRING (string)->data, 0, 0);
+ fatal ("%s", XSTRING (string)->data, 0);
}
/* Return nonzero iff LIST is a non-nil atom or
while (CONSP (conditions))
{
Lisp_Object this, tail;
- this = XCONS (conditions)->car;
- for (tail = list; CONSP (tail); tail = XCONS (tail)->cdr)
- if (EQ (XCONS (tail)->car, this))
+ this = XCAR (conditions);
+ for (tail = list; CONSP (tail); tail = XCDR (tail))
+ if (EQ (XCAR (tail), this))
return 1;
- conditions = XCONS (conditions)->cdr;
+ conditions = XCDR (conditions);
}
return 0;
}
Lisp_Object error_message;
for (tail = Vdebug_ignored_errors; CONSP (tail);
- tail = XCONS (tail)->cdr)
+ tail = XCDR (tail))
{
- if (STRINGP (XCONS (tail)->car))
+ if (STRINGP (XCAR (tail)))
{
if (first_string)
{
error_message = Ferror_message_string (data);
first_string = 0;
}
- if (fast_string_match (XCONS (tail)->car, error_message) >= 0)
+ if (fast_string_match (XCAR (tail), error_message) >= 0)
return 1;
}
else
Lisp_Object contail;
for (contail = conditions; CONSP (contail);
- contail = XCONS (contail)->cdr)
- if (EQ (XCONS (tail)->car, XCONS (contail)->car))
+ contail = XCDR (contail))
+ if (EQ (XCAR (tail), XCAR (contail)))
return 1;
}
}
}
/* Value of Qlambda means we have called debugger and user has continued.
+ There are two ways to pass SIG and DATA:
+ = SIG is the error symbol, and DATA is the rest of the data.
+ = SIG is nil, and DATA is (SYMBOL . REST-OF-DATA).
+ This is for memory-full errors only.
+
Store value returned from debugger into *DEBUGGER_VALUE_PTR. */
static Lisp_Object
{
int count = specpdl_ptr - specpdl;
int debugger_called = 0;
+ Lisp_Object sig_symbol, combined_data;
+ /* This is set to 1 if we are handling a memory-full error,
+ because these must not run the debugger.
+ (There is no room in memory to do that!) */
+ int no_debugger = 0;
+
+ if (NILP (sig))
+ {
+ combined_data = data;
+ sig_symbol = Fcar (data);
+ no_debugger = 1;
+ }
+ else
+ {
+ combined_data = Fcons (sig, data);
+ sig_symbol = sig;
+ }
if (wants_debugger (Vstack_trace_on_error, conditions))
- internal_with_output_to_temp_buffer ("*Backtrace*", Fbacktrace, Qnil);
- if ((EQ (sig, Qquit)
- ? debug_on_quit
- : wants_debugger (Vdebug_on_error, conditions))
- && ! skip_debugger (conditions, Fcons (sig, data))
- && when_entered_debugger < num_nonmacro_input_chars)
+ {
+#ifdef __STDC__
+ internal_with_output_to_temp_buffer ("*Backtrace*",
+ (Lisp_Object (*) (Lisp_Object)) Fbacktrace,
+ Qnil);
+#else
+ internal_with_output_to_temp_buffer ("*Backtrace*",
+ Fbacktrace, Qnil);
+#endif
+ }
+ if (! no_debugger
+ && (EQ (sig_symbol, Qquit)
+ ? debug_on_quit
+ : wants_debugger (Vdebug_on_error, conditions))
+ && ! skip_debugger (conditions, combined_data)
+ && when_entered_debugger < num_nonmacro_input_events)
{
specbind (Qdebug_on_error, Qnil);
*debugger_value_ptr
= call_debugger (Fcons (Qerror,
- Fcons (Fcons (sig, data),
- Qnil)));
+ Fcons (combined_data, Qnil)));
debugger_called = 1;
}
/* If there is no handler, return saying whether we ran the debugger. */
tem = Fmemq (Fcar (condit), conditions);
if (!NILP (tem))
return handler;
- condit = XCONS (condit)->cdr;
+ condit = XCDR (condit);
}
}
}
while (1)
{
- int used = doprnt (buf, size, m, m + mlen, 3, args);
+ int used = doprnt (buffer, size, m, m + mlen, 3, args);
if (used < size)
break;
size *= 2;
}
}
- string = build_string (buf);
+ string = build_string (buffer);
if (allocated)
free (buffer);
{
register Lisp_Object fun;
register Lisp_Object funcar;
- register Lisp_Object tem;
- register int i = 0;
fun = function;
/* If function is defined and not as an autoload, don't override */
if (!EQ (XSYMBOL (function)->function, Qunbound)
&& !(CONSP (XSYMBOL (function)->function)
- && EQ (XCONS (XSYMBOL (function)->function)->car, Qautoload)))
+ && EQ (XCAR (XSYMBOL (function)->function), Qautoload)))
return Qnil;
#ifdef NO_ARG_ARRAY
FUNNAME is the symbol which is the function's name.
FUNDEF is the autoload definition (a list). */
+void
do_autoload (fundef, funname)
Lisp_Object fundef, funname;
{
int count = specpdl_ptr - specpdl;
- Lisp_Object fun, val, queue, first, second;
+ Lisp_Object fun, queue, first, second;
struct gcpro gcpro1, gcpro2, gcpro3;
fun = funname;
CHECK_SYMBOL (funname, 0);
GCPRO3 (fun, funname, fundef);
- /* Value saved here is to be restored into Vautoload_queue */
+ /* Preserve the match data. */
+ record_unwind_protect (Fset_match_data, Fmatch_data (Qnil, Qnil));
+
+ /* Value saved here is to be restored into Vautoload_queue. */
record_unwind_protect (un_autoload, Vautoload_queue);
Vautoload_queue = Qt;
- Fload (Fcar (Fcdr (fundef)), Qnil, noninteractive ? Qt : Qnil, Qnil);
+ Fload (Fcar (Fcdr (fundef)), Qnil, noninteractive ? Qt : Qnil, Qnil, Qt);
- /* Save the old autoloads, in case we ever do an unload. */
+ /* Save the old autoloads, in case we ever do an unload. */
queue = Vautoload_queue;
while (CONSP (queue))
{
/* Note: This test is subtle. The cdr of an autoload-queue entry
may be an atom if the autoload entry was generated by a defalias
- or fset. */
+ or fset. */
if (CONSP (second))
Fput (first, Qautoload, (Fcdr (second)));
struct backtrace backtrace;
struct gcpro gcpro1, gcpro2, gcpro3;
+ /* Since Fsignal resets this to 0, it had better be 0 now
+ or else we have a potential bug. */
+ if (interrupt_input_blocked != 0)
+ abort ();
+
if (SYMBOLP (form))
{
if (EQ (Vmocklisp_arguments, Qt))
if (SUBRP (fun))
{
Lisp_Object numargs;
- Lisp_Object argvals[7];
+ Lisp_Object argvals[8];
Lisp_Object args_left;
register int i, maxargs;
argvals[6]);
goto done;
+ case 8:
+ val = (*XSUBR (fun)->function) (argvals[0], argvals[1], argvals[2],
+ argvals[3], argvals[4], argvals[5],
+ argvals[6], argvals[7]);
+ goto done;
+
default:
/* Someone has created a subr that takes more arguments than
is supported by this code. We need to either rewrite the
return Ffuncall (nargs - 1, args);
else if (numargs == 1)
{
- args [nargs - 1] = XCONS (spread_arg)->car;
+ args [nargs - 1] = XCAR (spread_arg);
return Ffuncall (nargs, args);
}
i = nargs - 1;
while (!NILP (spread_arg))
{
- funcall_args [i++] = XCONS (spread_arg)->car;
- spread_arg = XCONS (spread_arg)->cdr;
+ funcall_args [i++] = XCAR (spread_arg);
+ spread_arg = XCDR (spread_arg);
}
RETURN_UNGCPRO (Ffuncall (gcpro1.nvars, funcall_args));
enum run_hooks_condition cond;
{
Lisp_Object sym, val, ret;
- struct gcpro gcpro1, gcpro2;
+ Lisp_Object globals;
+ struct gcpro gcpro1, gcpro2, gcpro3;
/* If we are dying or still initializing,
don't do anything--it would probably crash if we tried. */
if (NILP (Vrun_hooks))
- return;
+ return Qnil;
sym = args[0];
val = find_symbol_value (sym);
if (EQ (val, Qunbound) || NILP (val))
return ret;
- else if (!CONSP (val) || EQ (XCONS (val)->car, Qlambda))
+ else if (!CONSP (val) || EQ (XCAR (val), Qlambda))
{
args[0] = val;
return Ffuncall (nargs, args);
}
else
{
- GCPRO2 (sym, val);
+ globals = Qnil;
+ GCPRO3 (sym, val, globals);
for (;
CONSP (val) && ((cond == to_completion)
|| (cond == until_success ? NILP (ret)
: !NILP (ret)));
- val = XCONS (val)->cdr)
+ val = XCDR (val))
{
- if (EQ (XCONS (val)->car, Qt))
+ if (EQ (XCAR (val), Qt))
{
/* t indicates this hook has a local binding;
it means to run the global binding too. */
- Lisp_Object globals;
for (globals = Fdefault_value (sym);
CONSP (globals) && ((cond == to_completion)
|| (cond == until_success ? NILP (ret)
: !NILP (ret)));
- globals = XCONS (globals)->cdr)
+ globals = XCDR (globals))
{
- args[0] = XCONS (globals)->car;
+ args[0] = XCAR (globals);
/* In a global value, t should not occur. If it does, we
must ignore it to avoid an endless loop. */
if (!EQ (args[0], Qt))
}
else
{
- args[0] = XCONS (val)->car;
+ args[0] = XCAR (val);
ret = Ffuncall (nargs, args);
}
}
{
Lisp_Object sym;
Lisp_Object val;
- struct gcpro gcpro1, gcpro2;
+ Lisp_Object globals;
+ struct gcpro gcpro1, gcpro2, gcpro3;
sym = args[0];
- GCPRO2 (sym, val);
+ globals = Qnil;
+ GCPRO3 (sym, val, globals);
- for (val = funlist; CONSP (val); val = XCONS (val)->cdr)
+ for (val = funlist; CONSP (val); val = XCDR (val))
{
- if (EQ (XCONS (val)->car, Qt))
+ if (EQ (XCAR (val), Qt))
{
/* t indicates this hook has a local binding;
it means to run the global binding too. */
- Lisp_Object globals;
for (globals = Fdefault_value (sym);
CONSP (globals);
- globals = XCONS (globals)->cdr)
+ globals = XCDR (globals))
{
- args[0] = XCONS (globals)->car;
+ args[0] = XCAR (globals);
/* In a global value, t should not occur. If it does, we
must ignore it to avoid an endless loop. */
if (!EQ (args[0], Qt))
}
else
{
- args[0] = XCONS (val)->car;
+ args[0] = XCAR (val);
Ffuncall (nargs, args);
}
}
internal_args[6]);
goto done;
+ case 8:
+ val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1],
+ internal_args[2], internal_args[3],
+ internal_args[4], internal_args[5],
+ internal_args[6], internal_args[7]);
+ goto done;
+
default:
- /* If a subr takes more than 6 arguments without using MANY
+ /* If a subr takes more than 8 arguments without using MANY
or UNEVALLED, we need to extend this function to support it.
Until this is done, there is no way to call the function. */
abort ();
tem = read_doc_string (XVECTOR (object)->contents[COMPILED_BYTECODE]);
if (!CONSP (tem))
error ("invalid byte code");
- XVECTOR (object)->contents[COMPILED_BYTECODE] = XCONS (tem)->car;
- XVECTOR (object)->contents[COMPILED_CONSTANTS] = XCONS (tem)->cdr;
+ XVECTOR (object)->contents[COMPILED_BYTECODE] = XCAR (tem);
+ XVECTOR (object)->contents[COMPILED_CONSTANTS] = XCDR (tem);
}
return object;
}
CHECK_SYMBOL (symbol, 0);
+ ovalue = find_symbol_value (symbol);
+
if (specpdl_ptr == specpdl + specpdl_size)
grow_specpdl ();
- specpdl_ptr->symbol = symbol;
specpdl_ptr->func = 0;
- specpdl_ptr->old_value = ovalue = find_symbol_value (symbol);
+ specpdl_ptr->old_value = ovalue;
+
+ if (BUFFER_LOCAL_VALUEP (XSYMBOL (symbol)->value)
+ || SOME_BUFFER_LOCAL_VALUEP (XSYMBOL (symbol)->value)
+ || BUFFER_OBJFWDP (XSYMBOL (symbol)->value))
+ {
+ Lisp_Object buffer;
+ /* For a local variable, record both the symbol and which
+ buffer's value we are saving. */
+ buffer = Fcurrent_buffer ();
+ /* If the variable is not local in this buffer,
+ we are saving the global value, so restore that. */
+ if (NILP (Flocal_variable_p (symbol, buffer)))
+ buffer = Qnil;
+ specpdl_ptr->symbol = Fcons (symbol, buffer);
+ }
+ else
+ specpdl_ptr->symbol = symbol;
+
specpdl_ptr++;
if (BUFFER_OBJFWDP (ovalue) || KBOARD_OBJFWDP (ovalue))
store_symval_forwarding (symbol, ovalue, value);
else
- Fset (symbol, value);
+ set_internal (symbol, value, 0, 1);
}
void
record_unwind_protect (function, arg)
- Lisp_Object (*function)();
+ Lisp_Object (*function) P_ ((Lisp_Object));
Lisp_Object arg;
{
if (specpdl_ptr == specpdl + specpdl_size)
if (specpdl_ptr->func != 0)
(*specpdl_ptr->func) (specpdl_ptr->old_value);
/* Note that a "binding" of nil is really an unwind protect,
- so in that case the "old value" is a list of forms to evaluate. */
+ so in that case the "old value" is a list of forms to evaluate. */
else if (NILP (specpdl_ptr->symbol))
Fprogn (specpdl_ptr->old_value);
+ else if (CONSP (specpdl_ptr->symbol))
+ {
+ Lisp_Object symbol, buffer;
+
+ symbol = XCAR (specpdl_ptr->symbol);
+ buffer = XCDR (specpdl_ptr->symbol);
+
+ /* Handle restoring a default value. */
+ if (NILP (buffer))
+ Fset_default (symbol, specpdl_ptr->old_value);
+ /* Handle restoring a value saved from a live buffer. */
+ else
+ set_internal (symbol, specpdl_ptr->old_value, XBUFFER (buffer), 1);
+ }
else
- Fset (specpdl_ptr->symbol, specpdl_ptr->old_value);
+ set_internal (specpdl_ptr->symbol, specpdl_ptr->old_value, 0, 1);
}
if (NILP (Vquit_flag) && quitf) Vquit_flag = Qt;
}
}
\f
+void
syms_of_eval ()
{
DEFVAR_INT ("max-specpdl-size", &max_specpdl_size,
- "Limit on number of Lisp variable bindings & unwind-protects before error.");
+ "*Limit on number of Lisp variable bindings & unwind-protects.\n\
+If Lisp code tries to make more than this many at once,\n\
+an error is signaled.");
DEFVAR_INT ("max-lisp-eval-depth", &max_lisp_eval_depth,
- "Limit on depth in `eval', `apply' and `funcall' before error.\n\
+ "*Limit on depth in `eval', `apply' and `funcall' before error.\n\
This limit is to catch infinite recursions for you before they cause\n\
actual stack overflow in C, which would be fatal for Emacs.\n\
You can safely make it considerably larger than its default value,\n\
DEFVAR_BOOL ("debug-on-next-call", &debug_on_next_call,
"Non-nil means enter debugger before next `eval', `apply' or `funcall'.");
+ DEFVAR_BOOL ("debugger-may-continue", &debugger_may_continue,
+ "Non-nil means debugger may continue execution.\n\
+This is nil when the debugger is called under circumstances where it\n\
+might not be safe to continue.");
+ debugger_may_continue = 1;
+
DEFVAR_LISP ("debugger", &Vdebugger,
"Function to call to invoke debugger.\n\
If due to frame exit, args are `exit' and the value being returned;\n\