aboutsummaryrefslogtreecommitdiffstats
path: root/src/eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c61
1 files changed, 34 insertions, 27 deletions
diff --git a/src/eval.c b/src/eval.c
index f625258229e..a867d00150e 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1,6 +1,6 @@
1/* Evaluator for GNU Emacs Lisp interpreter. 1/* Evaluator for GNU Emacs Lisp interpreter.
2 Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1999, 2000, 2001, 2 Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1999, 2000, 2001,
3 2002, 2004, 2005 Free Software Foundation, Inc. 3 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
@@ -235,6 +235,7 @@ restore_stack_limits (data)
235{ 235{
236 max_specpdl_size = XINT (XCAR (data)); 236 max_specpdl_size = XINT (XCAR (data));
237 max_lisp_eval_depth = XINT (XCDR (data)); 237 max_lisp_eval_depth = XINT (XCDR (data));
238 return Qnil;
238} 239}
239 240
240/* Call the Lisp debugger, giving it argument ARG. */ 241/* Call the Lisp debugger, giving it argument ARG. */
@@ -471,10 +472,10 @@ usage: (prog1 FIRST BODY...) */)
471} 472}
472 473
473DEFUN ("prog2", Fprog2, Sprog2, 2, UNEVALLED, 0, 474DEFUN ("prog2", Fprog2, Sprog2, 2, UNEVALLED, 0,
474 doc: /* Eval X, Y and BODY sequentially; value from Y. 475 doc: /* Eval FORM1, FORM2 and BODY sequentially; value from FORM2.
475The value of Y is saved during the evaluation of the remaining args, 476The value of FORM2 is saved during the evaluation of the
476whose values are discarded. 477remaining args, whose values are discarded.
477usage: (prog2 X Y BODY...) */) 478usage: (prog2 FORM1 FORM2 BODY...) */)
478 (args) 479 (args)
479 Lisp_Object args; 480 Lisp_Object args;
480{ 481{
@@ -564,8 +565,8 @@ usage: (function ARG) */)
564 565
565DEFUN ("interactive-p", Finteractive_p, Sinteractive_p, 0, 0, 0, 566DEFUN ("interactive-p", Finteractive_p, Sinteractive_p, 0, 0, 0,
566 doc: /* Return t if the function was run directly by user input. 567 doc: /* Return t if the function was run directly by user input.
567This means that the function was called with call-interactively (which 568This means that the function was called with `call-interactively'
568includes being called as the binding of a key) 569\(which includes being called as the binding of a key)
569and input is currently coming from the keyboard (not in keyboard macro), 570and input is currently coming from the keyboard (not in keyboard macro),
570and Emacs is not running in batch mode (`noninteractive' is nil). 571and Emacs is not running in batch mode (`noninteractive' is nil).
571 572
@@ -586,14 +587,14 @@ unconditionally for that argument. (`p' is a good way to do this.) */)
586 587
587 588
588DEFUN ("called-interactively-p", Fcalled_interactively_p, Scalled_interactively_p, 0, 0, 0, 589DEFUN ("called-interactively-p", Fcalled_interactively_p, Scalled_interactively_p, 0, 0, 0,
589 doc: /* Return t if the function using this was called with call-interactively. 590 doc: /* Return t if the function using this was called with `call-interactively'.
590This is used for implementing advice and other function-modifying 591This is used for implementing advice and other function-modifying
591features of Emacs. 592features of Emacs.
592 593
593The cleanest way to test whether your function was called with 594The cleanest way to test whether your function was called with
594`call-interactively', the way to do that is by adding an extra 595`call-interactively' is by adding an extra optional argument,
595optional argument, and making the `interactive' spec specify non-nil 596and making the `interactive' spec specify non-nil unconditionally
596unconditionally for that argument. (`p' is a good way to do this.) */) 597for that argument. (`p' is a good way to do this.) */)
597 () 598 ()
598{ 599{
599 return interactive_p (1) ? Qt : Qnil; 600 return interactive_p (1) ? Qt : Qnil;
@@ -779,7 +780,7 @@ The return value is BASE-VARIABLE. */)
779 780
780 781
781DEFUN ("defvar", Fdefvar, Sdefvar, 1, UNEVALLED, 0, 782DEFUN ("defvar", Fdefvar, Sdefvar, 1, UNEVALLED, 0,
782 doc: /* Define SYMBOL as a variable. 783 doc: /* Define SYMBOL as a variable, and return SYMBOL.
783You are not required to define a variable in order to use it, 784You are not required to define a variable in order to use it,
784but the definition can supply documentation and an initial value 785but the definition can supply documentation and an initial value
785in a way that tags can recognize. 786in a way that tags can recognize.
@@ -806,10 +807,6 @@ usage: (defvar SYMBOL &optional INITVALUE DOCSTRING) */)
806 register Lisp_Object sym, tem, tail; 807 register Lisp_Object sym, tem, tail;
807 808
808 sym = Fcar (args); 809 sym = Fcar (args);
809 if (SYMBOL_CONSTANT_P (sym))
810 error ("Constant symbol `%s' specified in defvar",
811 SDATA (SYMBOL_NAME (sym)));
812
813 tail = Fcdr (args); 810 tail = Fcdr (args);
814 if (!NILP (Fcdr (Fcdr (tail)))) 811 if (!NILP (Fcdr (Fcdr (tail))))
815 error ("Too many arguments"); 812 error ("Too many arguments");
@@ -817,6 +814,18 @@ usage: (defvar SYMBOL &optional INITVALUE DOCSTRING) */)
817 tem = Fdefault_boundp (sym); 814 tem = Fdefault_boundp (sym);
818 if (!NILP (tail)) 815 if (!NILP (tail))
819 { 816 {
817 if (SYMBOL_CONSTANT_P (sym))
818 {
819 /* For upward compatibility, allow (defvar :foo (quote :foo)). */
820 Lisp_Object tem = Fcar (tail);
821 if (! (CONSP (tem)
822 && EQ (XCAR (tem), Qquote)
823 && CONSP (XCDR (tem))
824 && EQ (XCAR (XCDR (tem)), sym)))
825 error ("Constant symbol `%s' specified in defvar",
826 SDATA (SYMBOL_NAME (sym)));
827 }
828
820 if (NILP (tem)) 829 if (NILP (tem))
821 Fset_default (sym, Feval (Fcar (tail))); 830 Fset_default (sym, Feval (Fcar (tail)));
822 else 831 else
@@ -2085,7 +2094,8 @@ DEFUN ("eval", Feval, Seval, 1, 1, 0,
2085 return form; 2094 return form;
2086 2095
2087 QUIT; 2096 QUIT;
2088 if (consing_since_gc > gc_cons_threshold) 2097 if (consing_since_gc > gc_cons_threshold
2098 && consing_since_gc > gc_relative_threshold)
2089 { 2099 {
2090 GCPRO1 (form); 2100 GCPRO1 (form);
2091 Fgarbage_collect (); 2101 Fgarbage_collect ();
@@ -2785,7 +2795,8 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */)
2785 register int i; 2795 register int i;
2786 2796
2787 QUIT; 2797 QUIT;
2788 if (consing_since_gc > gc_cons_threshold) 2798 if (consing_since_gc > gc_cons_threshold
2799 && consing_since_gc > gc_relative_threshold)
2789 Fgarbage_collect (); 2800 Fgarbage_collect ();
2790 2801
2791 if (++lisp_eval_depth > max_lisp_eval_depth) 2802 if (++lisp_eval_depth > max_lisp_eval_depth)
@@ -2851,8 +2862,7 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */)
2851 val = (*XSUBR (fun)->function) (internal_args[0]); 2862 val = (*XSUBR (fun)->function) (internal_args[0]);
2852 goto done; 2863 goto done;
2853 case 2: 2864 case 2:
2854 val = (*XSUBR (fun)->function) (internal_args[0], 2865 val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1]);
2855 internal_args[1]);
2856 goto done; 2866 goto done;
2857 case 3: 2867 case 3:
2858 val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1], 2868 val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1],
@@ -2860,8 +2870,7 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */)
2860 goto done; 2870 goto done;
2861 case 4: 2871 case 4:
2862 val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1], 2872 val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1],
2863 internal_args[2], 2873 internal_args[2], internal_args[3]);
2864 internal_args[3]);
2865 goto done; 2874 goto done;
2866 case 5: 2875 case 5:
2867 val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1], 2876 val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1],
@@ -3387,7 +3396,7 @@ void
3387syms_of_eval () 3396syms_of_eval ()
3388{ 3397{
3389 DEFVAR_INT ("max-specpdl-size", &max_specpdl_size, 3398 DEFVAR_INT ("max-specpdl-size", &max_specpdl_size,
3390 doc: /* *Limit on number of Lisp variable bindings & unwind-protects. 3399 doc: /* *Limit on number of Lisp variable bindings and `unwind-protect's.
3391If Lisp code tries to increase the total number past this amount, 3400If Lisp code tries to increase the total number past this amount,
3392an error is signaled. 3401an error is signaled.
3393You can safely use a value considerably larger than the default value, 3402You can safely use a value considerably larger than the default value,
@@ -3484,10 +3493,8 @@ It does not apply to errors handled by `condition-case'. */);
3484 Vdebug_ignored_errors = Qnil; 3493 Vdebug_ignored_errors = Qnil;
3485 3494
3486 DEFVAR_BOOL ("debug-on-quit", &debug_on_quit, 3495 DEFVAR_BOOL ("debug-on-quit", &debug_on_quit,
3487 doc: /* *Non-nil means enter debugger if quit is signaled (C-g, for example). 3496 doc: /* *Non-nil means enter debugger if quit is signaled (C-g, for example).
3488Does not apply if quit is handled by a `condition-case'. 3497Does not apply if quit is handled by a `condition-case'. */);
3489When you evaluate an expression interactively, this variable
3490is temporarily non-nil if `eval-expression-debug-on-quit' is non-nil. */);
3491 debug_on_quit = 0; 3498 debug_on_quit = 0;
3492 3499
3493 DEFVAR_BOOL ("debug-on-next-call", &debug_on_next_call, 3500 DEFVAR_BOOL ("debug-on-next-call", &debug_on_next_call,