aboutsummaryrefslogtreecommitdiffstats
path: root/src/eval.c
diff options
context:
space:
mode:
authorTom Tromey2012-09-04 10:10:06 -0600
committerTom Tromey2012-09-04 10:10:06 -0600
commitbf69f522a9e135f9aa483cedd53e71e915f2bf75 (patch)
tree3f73c47fb863ef87f420de1d30858da821072bd9 /src/eval.c
parent303324a9232dbc89369faceb6b3530740d0fc1bd (diff)
parent6ec9a5a7b5efb129807f567709ca858211ed7840 (diff)
downloademacs-bf69f522a9e135f9aa483cedd53e71e915f2bf75.tar.gz
emacs-bf69f522a9e135f9aa483cedd53e71e915f2bf75.zip
merge from trunk
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c96
1 files changed, 34 insertions, 62 deletions
diff --git a/src/eval.c b/src/eval.c
index c7a35fc91af..ecdbe960a8a 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -131,7 +131,7 @@ int handling_signal;
131Lisp_Object inhibit_lisp_code; 131Lisp_Object inhibit_lisp_code;
132 132
133static Lisp_Object funcall_lambda (Lisp_Object, ptrdiff_t, Lisp_Object *); 133static Lisp_Object funcall_lambda (Lisp_Object, ptrdiff_t, Lisp_Object *);
134static int interactive_p (int); 134static bool interactive_p (void);
135static Lisp_Object apply_lambda (Lisp_Object fun, Lisp_Object args); 135static Lisp_Object apply_lambda (Lisp_Object fun, Lisp_Object args);
136 136
137/* Functions to set Lisp_Object slots of struct specbinding. */ 137/* Functions to set Lisp_Object slots of struct specbinding. */
@@ -213,7 +213,7 @@ restore_stack_limits (Lisp_Object data)
213static Lisp_Object 213static Lisp_Object
214call_debugger (Lisp_Object arg) 214call_debugger (Lisp_Object arg)
215{ 215{
216 int debug_while_redisplaying; 216 bool debug_while_redisplaying;
217 ptrdiff_t count = SPECPDL_INDEX (); 217 ptrdiff_t count = SPECPDL_INDEX ();
218 Lisp_Object val; 218 Lisp_Object val;
219 EMACS_INT old_max = max_specpdl_size; 219 EMACS_INT old_max = max_specpdl_size;
@@ -544,7 +544,7 @@ spec that specifies non-nil unconditionally (such as \"p\"); or (ii)
544use `called-interactively-p'. */) 544use `called-interactively-p'. */)
545 (void) 545 (void)
546{ 546{
547 return interactive_p (1) ? Qt : Qnil; 547 return interactive_p () ? Qt : Qnil;
548} 548}
549 549
550 550
@@ -563,26 +563,23 @@ thinking of using it for any other purpose, it is quite likely that
563you're making a mistake. Think: what do you want to do when the 563you're making a mistake. Think: what do you want to do when the
564command is called from a keyboard macro? 564command is called from a keyboard macro?
565 565
566This function is meant for implementing advice and other 566Instead of using this function, it is sometimes cleaner to give your
567function-modifying features. Instead of using this, it is sometimes 567function an extra optional argument whose `interactive' spec specifies
568cleaner to give your function an extra optional argument whose 568non-nil unconditionally (\"p\" is a good way to do this), or via
569`interactive' spec specifies non-nil unconditionally (\"p\" is a good 569\(not (or executing-kbd-macro noninteractive)). */)
570way to do this), or via (not (or executing-kbd-macro noninteractive)). */)
571 (Lisp_Object kind) 570 (Lisp_Object kind)
572{ 571{
573 return ((INTERACTIVE || !EQ (kind, intern ("interactive"))) 572 return (((INTERACTIVE || !EQ (kind, intern ("interactive")))
574 && interactive_p (1)) ? Qt : Qnil; 573 && interactive_p ())
574 ? Qt : Qnil);
575} 575}
576 576
577 577
578/* Return 1 if function in which this appears was called using 578/* Return true if function in which this appears was called using
579 call-interactively. 579 call-interactively and is not a built-in. */
580 580
581 EXCLUDE_SUBRS_P non-zero means always return 0 if the function 581static bool
582 called is a built-in. */ 582interactive_p (void)
583
584static int
585interactive_p (int exclude_subrs_p)
586{ 583{
587 struct backtrace *btp; 584 struct backtrace *btp;
588 Lisp_Object fun; 585 Lisp_Object fun;
@@ -611,9 +608,9 @@ interactive_p (int exclude_subrs_p)
611 /* `btp' now points at the frame of the innermost function that isn't 608 /* `btp' now points at the frame of the innermost function that isn't
612 a special form, ignoring frames for Finteractive_p and/or 609 a special form, ignoring frames for Finteractive_p and/or
613 Fbytecode at the top. If this frame is for a built-in function 610 Fbytecode at the top. If this frame is for a built-in function
614 (such as load or eval-region) return nil. */ 611 (such as load or eval-region) return false. */
615 fun = Findirect_function (*btp->function, Qnil); 612 fun = Findirect_function (*btp->function, Qnil);
616 if (exclude_subrs_p && SUBRP (fun)) 613 if (SUBRP (fun))
617 return 0; 614 return 0;
618 615
619 /* `btp' points to the frame of a Lisp function that called interactive-p. 616 /* `btp' points to the frame of a Lisp function that called interactive-p.
@@ -1121,7 +1118,7 @@ internal_catch (Lisp_Object tag, Lisp_Object (*func) (Lisp_Object), Lisp_Object
1121static _Noreturn void 1118static _Noreturn void
1122unwind_to_catch (struct catchtag *catch, Lisp_Object value) 1119unwind_to_catch (struct catchtag *catch, Lisp_Object value)
1123{ 1120{
1124 int last_time; 1121 bool last_time;
1125 1122
1126 /* Save the value in the tag. */ 1123 /* Save the value in the tag. */
1127 catch->val = value; 1124 catch->val = value;
@@ -1470,8 +1467,8 @@ internal_condition_case_n (Lisp_Object (*bfun) (ptrdiff_t, Lisp_Object *),
1470 1467
1471 1468
1472static Lisp_Object find_handler_clause (Lisp_Object, Lisp_Object); 1469static Lisp_Object find_handler_clause (Lisp_Object, Lisp_Object);
1473static int maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, 1470static bool maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig,
1474 Lisp_Object data); 1471 Lisp_Object data);
1475 1472
1476void 1473void
1477process_quit_flag (void) 1474process_quit_flag (void)
@@ -1576,7 +1573,7 @@ See also the function `condition-case'. */)
1576 if requested". */ 1573 if requested". */
1577 || EQ (h->handler, Qerror))) 1574 || EQ (h->handler, Qerror)))
1578 { 1575 {
1579 int debugger_called 1576 bool debugger_called
1580 = maybe_call_debugger (conditions, error_symbol, data); 1577 = maybe_call_debugger (conditions, error_symbol, data);
1581 /* We can't return values to code which signaled an error, but we 1578 /* We can't return values to code which signaled an error, but we
1582 can continue code which has signaled a quit. */ 1579 can continue code which has signaled a quit. */
@@ -1670,10 +1667,10 @@ signal_error (const char *s, Lisp_Object arg)
1670} 1667}
1671 1668
1672 1669
1673/* Return nonzero if LIST is a non-nil atom or 1670/* Return true if LIST is a non-nil atom or
1674 a list containing one of CONDITIONS. */ 1671 a list containing one of CONDITIONS. */
1675 1672
1676static int 1673static bool
1677wants_debugger (Lisp_Object list, Lisp_Object conditions) 1674wants_debugger (Lisp_Object list, Lisp_Object conditions)
1678{ 1675{
1679 if (NILP (list)) 1676 if (NILP (list))
@@ -1693,15 +1690,15 @@ wants_debugger (Lisp_Object list, Lisp_Object conditions)
1693 return 0; 1690 return 0;
1694} 1691}
1695 1692
1696/* Return 1 if an error with condition-symbols CONDITIONS, 1693/* Return true if an error with condition-symbols CONDITIONS,
1697 and described by SIGNAL-DATA, should skip the debugger 1694 and described by SIGNAL-DATA, should skip the debugger
1698 according to debugger-ignored-errors. */ 1695 according to debugger-ignored-errors. */
1699 1696
1700static int 1697static bool
1701skip_debugger (Lisp_Object conditions, Lisp_Object data) 1698skip_debugger (Lisp_Object conditions, Lisp_Object data)
1702{ 1699{
1703 Lisp_Object tail; 1700 Lisp_Object tail;
1704 int first_string = 1; 1701 bool first_string = 1;
1705 Lisp_Object error_message; 1702 Lisp_Object error_message;
1706 1703
1707 error_message = Qnil; 1704 error_message = Qnil;
@@ -1736,7 +1733,7 @@ skip_debugger (Lisp_Object conditions, Lisp_Object data)
1736 = SIG is the error symbol, and DATA is the rest of the data. 1733 = SIG is the error symbol, and DATA is the rest of the data.
1737 = SIG is nil, and DATA is (SYMBOL . REST-OF-DATA). 1734 = SIG is nil, and DATA is (SYMBOL . REST-OF-DATA).
1738 This is for memory-full errors only. */ 1735 This is for memory-full errors only. */
1739static int 1736static bool
1740maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, Lisp_Object data) 1737maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, Lisp_Object data)
1741{ 1738{
1742 Lisp_Object combined_data; 1739 Lisp_Object combined_data;
@@ -2252,7 +2249,6 @@ eval_sub (Lisp_Object form)
2252 if (EQ (funcar, Qmacro)) 2249 if (EQ (funcar, Qmacro))
2253 { 2250 {
2254 ptrdiff_t count = SPECPDL_INDEX (); 2251 ptrdiff_t count = SPECPDL_INDEX ();
2255 extern Lisp_Object Qlexical_binding;
2256 Lisp_Object exp; 2252 Lisp_Object exp;
2257 /* Bind lexical-binding during expansion of the macro, so the 2253 /* Bind lexical-binding during expansion of the macro, so the
2258 macro can know reliably if the code it outputs will be 2254 macro can know reliably if the code it outputs will be
@@ -2741,33 +2737,9 @@ DEFUN ("functionp", Ffunctionp, Sfunctionp, 1, 1, 0,
2741 doc: /* Non-nil if OBJECT is a function. */) 2737 doc: /* Non-nil if OBJECT is a function. */)
2742 (Lisp_Object object) 2738 (Lisp_Object object)
2743{ 2739{
2744 if (SYMBOLP (object) && !NILP (Ffboundp (object))) 2740 if (FUNCTIONP (object))
2745 {
2746 object = Findirect_function (object, Qt);
2747
2748 if (CONSP (object) && EQ (XCAR (object), Qautoload))
2749 {
2750 /* Autoloaded symbols are functions, except if they load
2751 macros or keymaps. */
2752 int i;
2753 for (i = 0; i < 4 && CONSP (object); i++)
2754 object = XCDR (object);
2755
2756 return (CONSP (object) && !NILP (XCAR (object))) ? Qnil : Qt;
2757 }
2758 }
2759
2760 if (SUBRP (object))
2761 return (XSUBR (object)->max_args != UNEVALLED) ? Qt : Qnil;
2762 else if (COMPILEDP (object))
2763 return Qt; 2741 return Qt;
2764 else if (CONSP (object)) 2742 return Qnil;
2765 {
2766 Lisp_Object car = XCAR (object);
2767 return (EQ (car, Qlambda) || EQ (car, Qclosure)) ? Qt : Qnil;
2768 }
2769 else
2770 return Qnil;
2771} 2743}
2772 2744
2773DEFUN ("funcall", Ffuncall, Sfuncall, 1, MANY, 0, 2745DEFUN ("funcall", Ffuncall, Sfuncall, 1, MANY, 0,
@@ -2984,7 +2956,7 @@ funcall_lambda (Lisp_Object fun, ptrdiff_t nargs,
2984 Lisp_Object val, syms_left, next, lexenv; 2956 Lisp_Object val, syms_left, next, lexenv;
2985 ptrdiff_t count = SPECPDL_INDEX (); 2957 ptrdiff_t count = SPECPDL_INDEX ();
2986 ptrdiff_t i; 2958 ptrdiff_t i;
2987 int optional, rest; 2959 bool optional, rest;
2988 2960
2989 if (CONSP (fun)) 2961 if (CONSP (fun))
2990 { 2962 {
@@ -3470,13 +3442,13 @@ Output stream used is value of `standard-output'. */)
3470 write_string ("(", -1); 3442 write_string ("(", -1);
3471 if (backlist->nargs == MANY) 3443 if (backlist->nargs == MANY)
3472 { /* FIXME: Can this happen? */ 3444 { /* FIXME: Can this happen? */
3473 int i; 3445 bool later_arg = 0;
3474 for (tail = *backlist->args, i = 0; 3446 for (tail = *backlist->args; !NILP (tail); tail = Fcdr (tail))
3475 !NILP (tail);
3476 tail = Fcdr (tail), i = 1)
3477 { 3447 {
3478 if (i) write_string (" ", -1); 3448 if (later_arg)
3449 write_string (" ", -1);
3479 Fprin1 (Fcar (tail), Qnil); 3450 Fprin1 (Fcar (tail), Qnil);
3451 later_arg = 1;
3480 } 3452 }
3481 } 3453 }
3482 else 3454 else