diff options
Diffstat (limited to 'src/eval.c')
| -rw-r--r-- | src/eval.c | 107 |
1 files changed, 40 insertions, 67 deletions
diff --git a/src/eval.c b/src/eval.c index e47478bb1f1..561ba922482 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -31,17 +31,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 31 | #include "xterm.h" | 31 | #include "xterm.h" |
| 32 | #endif | 32 | #endif |
| 33 | 33 | ||
| 34 | struct backtrace | 34 | struct backtrace *backtrace_list; |
| 35 | { | ||
| 36 | struct backtrace *next; | ||
| 37 | Lisp_Object *function; | ||
| 38 | Lisp_Object *args; /* Points to vector of args. */ | ||
| 39 | ptrdiff_t nargs; /* Length of vector. */ | ||
| 40 | /* Nonzero means call value of debugger when done with this operation. */ | ||
| 41 | unsigned int debug_on_exit : 1; | ||
| 42 | }; | ||
| 43 | |||
| 44 | static struct backtrace *backtrace_list; | ||
| 45 | 35 | ||
| 46 | #if !BYTE_MARK_STACK | 36 | #if !BYTE_MARK_STACK |
| 47 | static | 37 | static |
| @@ -562,7 +552,7 @@ interactive_p (void) | |||
| 562 | 552 | ||
| 563 | /* If this isn't a byte-compiled function, there may be a frame at | 553 | /* If this isn't a byte-compiled function, there may be a frame at |
| 564 | the top for Finteractive_p. If so, skip it. */ | 554 | the top for Finteractive_p. If so, skip it. */ |
| 565 | fun = Findirect_function (*btp->function, Qnil); | 555 | fun = Findirect_function (btp->function, Qnil); |
| 566 | if (SUBRP (fun) && (XSUBR (fun) == &Sinteractive_p | 556 | if (SUBRP (fun) && (XSUBR (fun) == &Sinteractive_p |
| 567 | || XSUBR (fun) == &Scalled_interactively_p)) | 557 | || XSUBR (fun) == &Scalled_interactively_p)) |
| 568 | btp = btp->next; | 558 | btp = btp->next; |
| @@ -575,7 +565,7 @@ interactive_p (void) | |||
| 575 | If this isn't a byte-compiled function, then we may now be | 565 | If this isn't a byte-compiled function, then we may now be |
| 576 | looking at several frames for special forms. Skip past them. */ | 566 | looking at several frames for special forms. Skip past them. */ |
| 577 | while (btp | 567 | while (btp |
| 578 | && (EQ (*btp->function, Qbytecode) | 568 | && (EQ (btp->function, Qbytecode) |
| 579 | || btp->nargs == UNEVALLED)) | 569 | || btp->nargs == UNEVALLED)) |
| 580 | btp = btp->next; | 570 | btp = btp->next; |
| 581 | 571 | ||
| @@ -583,13 +573,13 @@ interactive_p (void) | |||
| 583 | a special form, ignoring frames for Finteractive_p and/or | 573 | a special form, ignoring frames for Finteractive_p and/or |
| 584 | Fbytecode at the top. If this frame is for a built-in function | 574 | Fbytecode at the top. If this frame is for a built-in function |
| 585 | (such as load or eval-region) return false. */ | 575 | (such as load or eval-region) return false. */ |
| 586 | fun = Findirect_function (*btp->function, Qnil); | 576 | fun = Findirect_function (btp->function, Qnil); |
| 587 | if (SUBRP (fun)) | 577 | if (SUBRP (fun)) |
| 588 | return 0; | 578 | return 0; |
| 589 | 579 | ||
| 590 | /* `btp' points to the frame of a Lisp function that called interactive-p. | 580 | /* `btp' points to the frame of a Lisp function that called interactive-p. |
| 591 | Return t if that function was called interactively. */ | 581 | Return t if that function was called interactively. */ |
| 592 | if (btp && btp->next && EQ (*btp->next->function, Qcall_interactively)) | 582 | if (btp && btp->next && EQ (btp->next->function, Qcall_interactively)) |
| 593 | return 1; | 583 | return 1; |
| 594 | return 0; | 584 | return 0; |
| 595 | } | 585 | } |
| @@ -1076,7 +1066,7 @@ internal_catch (Lisp_Object tag, Lisp_Object (*func) (Lisp_Object), Lisp_Object | |||
| 1076 | /* Unwind the specbind, catch, and handler stacks back to CATCH, and | 1066 | /* Unwind the specbind, catch, and handler stacks back to CATCH, and |
| 1077 | jump to that CATCH, returning VALUE as the value of that catch. | 1067 | jump to that CATCH, returning VALUE as the value of that catch. |
| 1078 | 1068 | ||
| 1079 | This is the guts Fthrow and Fsignal; they differ only in the way | 1069 | This is the guts of Fthrow and Fsignal; they differ only in the way |
| 1080 | they choose the catch tag to throw to. A catch tag for a | 1070 | they choose the catch tag to throw to. A catch tag for a |
| 1081 | condition-case form has a TAG of Qnil. | 1071 | condition-case form has a TAG of Qnil. |
| 1082 | 1072 | ||
| @@ -1085,7 +1075,7 @@ internal_catch (Lisp_Object tag, Lisp_Object (*func) (Lisp_Object), Lisp_Object | |||
| 1085 | the handler stack as we go, so that the proper handlers are in | 1075 | the handler stack as we go, so that the proper handlers are in |
| 1086 | effect for each unwind-protect clause we run. At the end, restore | 1076 | effect for each unwind-protect clause we run. At the end, restore |
| 1087 | some static info saved in CATCH, and longjmp to the location | 1077 | some static info saved in CATCH, and longjmp to the location |
| 1088 | specified in the | 1078 | specified there. |
| 1089 | 1079 | ||
| 1090 | This is used for correct unwinding in Fthrow and Fsignal. */ | 1080 | This is used for correct unwinding in Fthrow and Fsignal. */ |
| 1091 | 1081 | ||
| @@ -1099,7 +1089,7 @@ unwind_to_catch (struct catchtag *catch, Lisp_Object value) | |||
| 1099 | 1089 | ||
| 1100 | /* Restore certain special C variables. */ | 1090 | /* Restore certain special C variables. */ |
| 1101 | set_poll_suppress_count (catch->poll_suppress_count); | 1091 | set_poll_suppress_count (catch->poll_suppress_count); |
| 1102 | UNBLOCK_INPUT_TO (catch->interrupt_input_blocked); | 1092 | unblock_input_to (catch->interrupt_input_blocked); |
| 1103 | immediate_quit = 0; | 1093 | immediate_quit = 0; |
| 1104 | 1094 | ||
| 1105 | do | 1095 | do |
| @@ -1114,16 +1104,6 @@ unwind_to_catch (struct catchtag *catch, Lisp_Object value) | |||
| 1114 | } | 1104 | } |
| 1115 | while (! last_time); | 1105 | while (! last_time); |
| 1116 | 1106 | ||
| 1117 | #if HAVE_X_WINDOWS | ||
| 1118 | /* If x_catch_errors was done, turn it off now. | ||
| 1119 | (First we give unbind_to a chance to do that.) */ | ||
| 1120 | #if 0 /* This would disable x_catch_errors after x_connection_closed. | ||
| 1121 | The catch must remain in effect during that delicate | ||
| 1122 | state. --lorentey */ | ||
| 1123 | x_fully_uncatch_errors (); | ||
| 1124 | #endif | ||
| 1125 | #endif | ||
| 1126 | |||
| 1127 | byte_stack_list = catch->byte_stack; | 1107 | byte_stack_list = catch->byte_stack; |
| 1128 | gcprolist = catch->gcpro; | 1108 | gcprolist = catch->gcpro; |
| 1129 | #ifdef DEBUG_GCPRO | 1109 | #ifdef DEBUG_GCPRO |
| @@ -1516,10 +1496,10 @@ See also the function `condition-case'. */) | |||
| 1516 | if (backtrace_list && !NILP (error_symbol)) | 1496 | if (backtrace_list && !NILP (error_symbol)) |
| 1517 | { | 1497 | { |
| 1518 | bp = backtrace_list->next; | 1498 | bp = backtrace_list->next; |
| 1519 | if (bp && bp->function && EQ (*bp->function, Qerror)) | 1499 | if (bp && EQ (bp->function, Qerror)) |
| 1520 | bp = bp->next; | 1500 | bp = bp->next; |
| 1521 | if (bp && bp->function) | 1501 | if (bp) |
| 1522 | Vsignaling_function = *bp->function; | 1502 | Vsignaling_function = bp->function; |
| 1523 | } | 1503 | } |
| 1524 | 1504 | ||
| 1525 | for (h = handlerlist; h; h = h->next) | 1505 | for (h = handlerlist; h; h = h->next) |
| @@ -1530,7 +1510,7 @@ See also the function `condition-case'. */) | |||
| 1530 | } | 1510 | } |
| 1531 | 1511 | ||
| 1532 | if (/* Don't run the debugger for a memory-full error. | 1512 | if (/* Don't run the debugger for a memory-full error. |
| 1533 | (There is no room in memory to do that!) */ | 1513 | (There is no room in memory to do that!) */ |
| 1534 | !NILP (error_symbol) | 1514 | !NILP (error_symbol) |
| 1535 | && (!NILP (Vdebug_on_signal) | 1515 | && (!NILP (Vdebug_on_signal) |
| 1536 | /* If no handler is present now, try to run the debugger. */ | 1516 | /* If no handler is present now, try to run the debugger. */ |
| @@ -1713,7 +1693,7 @@ maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, Lisp_Object data) | |||
| 1713 | if ( | 1693 | if ( |
| 1714 | /* Don't try to run the debugger with interrupts blocked. | 1694 | /* Don't try to run the debugger with interrupts blocked. |
| 1715 | The editing loop would return anyway. */ | 1695 | The editing loop would return anyway. */ |
| 1716 | ! INPUT_BLOCKED_P | 1696 | ! input_blocked_p () |
| 1717 | && NILP (Vinhibit_debugger) | 1697 | && NILP (Vinhibit_debugger) |
| 1718 | /* Does user want to enter debugger for this kind of error? */ | 1698 | /* Does user want to enter debugger for this kind of error? */ |
| 1719 | && (EQ (sig, Qquit) | 1699 | && (EQ (sig, Qquit) |
| @@ -2065,11 +2045,11 @@ eval_sub (Lisp_Object form) | |||
| 2065 | original_args = XCDR (form); | 2045 | original_args = XCDR (form); |
| 2066 | 2046 | ||
| 2067 | backtrace.next = backtrace_list; | 2047 | backtrace.next = backtrace_list; |
| 2068 | backtrace_list = &backtrace; | 2048 | backtrace.function = original_fun; /* This also protects them from gc. */ |
| 2069 | backtrace.function = &original_fun; /* This also protects them from gc. */ | ||
| 2070 | backtrace.args = &original_args; | 2049 | backtrace.args = &original_args; |
| 2071 | backtrace.nargs = UNEVALLED; | 2050 | backtrace.nargs = UNEVALLED; |
| 2072 | backtrace.debug_on_exit = 0; | 2051 | backtrace.debug_on_exit = 0; |
| 2052 | backtrace_list = &backtrace; | ||
| 2073 | 2053 | ||
| 2074 | if (debug_on_next_call) | 2054 | if (debug_on_next_call) |
| 2075 | do_debug_on_call (Qt); | 2055 | do_debug_on_call (Qt); |
| @@ -2371,14 +2351,10 @@ usage: (run-hooks &rest HOOKS) */) | |||
| 2371 | DEFUN ("run-hook-with-args", Frun_hook_with_args, | 2351 | DEFUN ("run-hook-with-args", Frun_hook_with_args, |
| 2372 | Srun_hook_with_args, 1, MANY, 0, | 2352 | Srun_hook_with_args, 1, MANY, 0, |
| 2373 | doc: /* Run HOOK with the specified arguments ARGS. | 2353 | doc: /* Run HOOK with the specified arguments ARGS. |
| 2374 | HOOK should be a symbol, a hook variable. If HOOK has a non-nil | 2354 | HOOK should be a symbol, a hook variable. The value of HOOK |
| 2375 | value, that value may be a function or a list of functions to be | 2355 | may be nil, a function, or a list of functions. Call each |
| 2376 | called to run the hook. If the value is a function, it is called with | 2356 | function in order with arguments ARGS. The final return value |
| 2377 | the given arguments and its return value is returned. If it is a list | 2357 | is unspecified. |
| 2378 | of functions, those functions are called, in order, | ||
| 2379 | with the given arguments ARGS. | ||
| 2380 | It is best not to depend on the value returned by `run-hook-with-args', | ||
| 2381 | as that may change. | ||
| 2382 | 2358 | ||
| 2383 | Do not use `make-local-variable' to make a hook variable buffer-local. | 2359 | Do not use `make-local-variable' to make a hook variable buffer-local. |
| 2384 | Instead, use `add-hook' and specify t for the LOCAL argument. | 2360 | Instead, use `add-hook' and specify t for the LOCAL argument. |
| @@ -2388,18 +2364,18 @@ usage: (run-hook-with-args HOOK &rest ARGS) */) | |||
| 2388 | return run_hook_with_args (nargs, args, funcall_nil); | 2364 | return run_hook_with_args (nargs, args, funcall_nil); |
| 2389 | } | 2365 | } |
| 2390 | 2366 | ||
| 2367 | /* NB this one still documents a specific non-nil return value. | ||
| 2368 | (As did run-hook-with-args and run-hook-with-args-until-failure | ||
| 2369 | until they were changed in 24.1.) */ | ||
| 2391 | DEFUN ("run-hook-with-args-until-success", Frun_hook_with_args_until_success, | 2370 | DEFUN ("run-hook-with-args-until-success", Frun_hook_with_args_until_success, |
| 2392 | Srun_hook_with_args_until_success, 1, MANY, 0, | 2371 | Srun_hook_with_args_until_success, 1, MANY, 0, |
| 2393 | doc: /* Run HOOK with the specified arguments ARGS. | 2372 | doc: /* Run HOOK with the specified arguments ARGS. |
| 2394 | HOOK should be a symbol, a hook variable. If HOOK has a non-nil | 2373 | HOOK should be a symbol, a hook variable. The value of HOOK |
| 2395 | value, that value may be a function or a list of functions to be | 2374 | may be nil, a function, or a list of functions. Call each |
| 2396 | called to run the hook. If the value is a function, it is called with | 2375 | function in order with arguments ARGS, stopping at the first |
| 2397 | the given arguments and its return value is returned. | 2376 | one that returns non-nil, and return that value. Otherwise (if |
| 2398 | If it is a list of functions, those functions are called, in order, | 2377 | all functions return nil, or if there are no functions to call), |
| 2399 | with the given arguments ARGS, until one of them | 2378 | return nil. |
| 2400 | returns a non-nil value. Then we return that value. | ||
| 2401 | However, if they all return nil, we return nil. | ||
| 2402 | If the value of HOOK is nil, this function returns nil. | ||
| 2403 | 2379 | ||
| 2404 | Do not use `make-local-variable' to make a hook variable buffer-local. | 2380 | Do not use `make-local-variable' to make a hook variable buffer-local. |
| 2405 | Instead, use `add-hook' and specify t for the LOCAL argument. | 2381 | Instead, use `add-hook' and specify t for the LOCAL argument. |
| @@ -2418,15 +2394,12 @@ funcall_not (ptrdiff_t nargs, Lisp_Object *args) | |||
| 2418 | DEFUN ("run-hook-with-args-until-failure", Frun_hook_with_args_until_failure, | 2394 | DEFUN ("run-hook-with-args-until-failure", Frun_hook_with_args_until_failure, |
| 2419 | Srun_hook_with_args_until_failure, 1, MANY, 0, | 2395 | Srun_hook_with_args_until_failure, 1, MANY, 0, |
| 2420 | doc: /* Run HOOK with the specified arguments ARGS. | 2396 | doc: /* Run HOOK with the specified arguments ARGS. |
| 2421 | HOOK should be a symbol, a hook variable. If HOOK has a non-nil | 2397 | HOOK should be a symbol, a hook variable. The value of HOOK |
| 2422 | value, that value may be a function or a list of functions to be | 2398 | may be nil, a function, or a list of functions. Call each |
| 2423 | called to run the hook. If the value is a function, it is called with | 2399 | function in order with arguments ARGS, stopping at the first |
| 2424 | the given arguments. Then we return nil if the function returns nil, | 2400 | one that returns nil, and return nil. Otherwise (if all functions |
| 2425 | and t if it returns non-nil. | 2401 | return non-nil, or if there are no functions to call), return non-nil |
| 2426 | If it is a list of functions, those functions are called, in order, | 2402 | \(do not rely on the precise return value in this case). |
| 2427 | with the given arguments ARGS, until one of them returns nil. | ||
| 2428 | Then we return nil. However, if they all return non-nil, we return t. | ||
| 2429 | If the value of HOOK is nil, this function returns t. | ||
| 2430 | 2403 | ||
| 2431 | Do not use `make-local-variable' to make a hook variable buffer-local. | 2404 | Do not use `make-local-variable' to make a hook variable buffer-local. |
| 2432 | Instead, use `add-hook' and specify t for the LOCAL argument. | 2405 | Instead, use `add-hook' and specify t for the LOCAL argument. |
| @@ -2740,11 +2713,11 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */) | |||
| 2740 | } | 2713 | } |
| 2741 | 2714 | ||
| 2742 | backtrace.next = backtrace_list; | 2715 | backtrace.next = backtrace_list; |
| 2743 | backtrace_list = &backtrace; | 2716 | backtrace.function = args[0]; |
| 2744 | backtrace.function = &args[0]; | ||
| 2745 | backtrace.args = &args[1]; /* This also GCPROs them. */ | 2717 | backtrace.args = &args[1]; /* This also GCPROs them. */ |
| 2746 | backtrace.nargs = nargs - 1; | 2718 | backtrace.nargs = nargs - 1; |
| 2747 | backtrace.debug_on_exit = 0; | 2719 | backtrace.debug_on_exit = 0; |
| 2720 | backtrace_list = &backtrace; | ||
| 2748 | 2721 | ||
| 2749 | /* Call GC after setting up the backtrace, so the latter GCPROs the args. */ | 2722 | /* Call GC after setting up the backtrace, so the latter GCPROs the args. */ |
| 2750 | maybe_gc (); | 2723 | maybe_gc (); |
| @@ -3316,12 +3289,12 @@ Output stream used is value of `standard-output'. */) | |||
| 3316 | write_string (backlist->debug_on_exit ? "* " : " ", 2); | 3289 | write_string (backlist->debug_on_exit ? "* " : " ", 2); |
| 3317 | if (backlist->nargs == UNEVALLED) | 3290 | if (backlist->nargs == UNEVALLED) |
| 3318 | { | 3291 | { |
| 3319 | Fprin1 (Fcons (*backlist->function, *backlist->args), Qnil); | 3292 | Fprin1 (Fcons (backlist->function, *backlist->args), Qnil); |
| 3320 | write_string ("\n", -1); | 3293 | write_string ("\n", -1); |
| 3321 | } | 3294 | } |
| 3322 | else | 3295 | else |
| 3323 | { | 3296 | { |
| 3324 | tem = *backlist->function; | 3297 | tem = backlist->function; |
| 3325 | Fprin1 (tem, Qnil); /* This can QUIT. */ | 3298 | Fprin1 (tem, Qnil); /* This can QUIT. */ |
| 3326 | write_string ("(", -1); | 3299 | write_string ("(", -1); |
| 3327 | if (backlist->nargs == MANY) | 3300 | if (backlist->nargs == MANY) |
| @@ -3379,7 +3352,7 @@ If NFRAMES is more than the number of frames, the value is nil. */) | |||
| 3379 | if (!backlist) | 3352 | if (!backlist) |
| 3380 | return Qnil; | 3353 | return Qnil; |
| 3381 | if (backlist->nargs == UNEVALLED) | 3354 | if (backlist->nargs == UNEVALLED) |
| 3382 | return Fcons (Qnil, Fcons (*backlist->function, *backlist->args)); | 3355 | return Fcons (Qnil, Fcons (backlist->function, *backlist->args)); |
| 3383 | else | 3356 | else |
| 3384 | { | 3357 | { |
| 3385 | if (backlist->nargs == MANY) /* FIXME: Can this happen? */ | 3358 | if (backlist->nargs == MANY) /* FIXME: Can this happen? */ |
| @@ -3387,7 +3360,7 @@ If NFRAMES is more than the number of frames, the value is nil. */) | |||
| 3387 | else | 3360 | else |
| 3388 | tem = Flist (backlist->nargs, backlist->args); | 3361 | tem = Flist (backlist->nargs, backlist->args); |
| 3389 | 3362 | ||
| 3390 | return Fcons (Qt, Fcons (*backlist->function, tem)); | 3363 | return Fcons (Qt, Fcons (backlist->function, tem)); |
| 3391 | } | 3364 | } |
| 3392 | } | 3365 | } |
| 3393 | 3366 | ||