aboutsummaryrefslogtreecommitdiffstats
path: root/src/eval.c
diff options
context:
space:
mode:
authorRichard M. Stallman2004-11-02 08:59:26 +0000
committerRichard M. Stallman2004-11-02 08:59:26 +0000
commitc63df42bfac4b43ba7af2590d18edbfc8e073690 (patch)
treee703a750bc49dde64dbbe80b0947c27bb65656e1 /src/eval.c
parentfe4dcb868e1371946b675415fdf19249a606281f (diff)
downloademacs-c63df42bfac4b43ba7af2590d18edbfc8e073690.tar.gz
emacs-c63df42bfac4b43ba7af2590d18edbfc8e073690.zip
(Fcall_interactive_p): New function.
(interactive_p): Don't test INTERACTIVE here. (Finteractive_p): Doc fix. (Feval): Abort if INPUT_BLOCKED_P.
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c45
1 files changed, 33 insertions, 12 deletions
diff --git a/src/eval.c b/src/eval.c
index ee74215b2ee..6d37d43c79c 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -540,21 +540,45 @@ usage: (function ARG) */)
540 540
541 541
542DEFUN ("interactive-p", Finteractive_p, Sinteractive_p, 0, 0, 0, 542DEFUN ("interactive-p", Finteractive_p, Sinteractive_p, 0, 0, 0,
543 doc: /* Return t if function in which this appears was called interactively. 543 doc: /* Return t if the function was run directly by user input.
544This means that the function was called with call-interactively (which 544This means that the function was called with call-interactively (which
545includes being called as the binding of a key) 545includes being called as the binding of a key)
546and input is currently coming from the keyboard (not in keyboard macro). */) 546and input is currently coming from the keyboard (not in keyboard macro),
547and Emacs is not running in batch mode (`noninteractive' is nil).
548
549The only known proper use of `interactive-p' is in deciding whether to
550display a helpful message, or how to display it. If you're thinking
551of using it for any other purpose, it is quite likely that you're
552making a mistake. Think: what do you want to do when the command is
553called from a keyboard macro?
554
555If you want to test whether your function was called with
556`call-interactively', the way to do that is by adding an extra
557optional argument, and making the `interactive' spec specify non-nil
558unconditionally for that argument. (`p' is a good way to do this.) */)
547 () 559 ()
548{ 560{
549 return interactive_p (1) ? Qt : Qnil; 561 return (INTERACTIVE && interactive_p (1)) ? Qt : Qnil;
550} 562}
551 563
552 564
553/* Return 1 if function in which this appears was called 565DEFUN ("called-interactively-p", Fcall_interactive_p, Scall_interactive_p, 0, 0, 0,
554 interactively. This means that the function was called with 566 doc: /* Return t if the function using this was called with call-interactively.
555 call-interactively (which includes being called as the binding of 567This is used for implementing advice and other function-modifying
556 a key) and input is currently coming from the keyboard (not in 568features of Emacs.
557 keyboard macro). 569
570The cleanest way to test whether your function was called with
571`call-interactively', the way to do that is by adding an extra
572optional argument, and making the `interactive' spec specify non-nil
573unconditionally for that argument. (`p' is a good way to do this.) */)
574 ()
575{
576 return (INTERACTIVE && interactive_p (1)) ? Qt : Qnil;
577}
578
579
580/* Return 1 if function in which this appears was called using
581 call-interactively.
558 582
559 EXCLUDE_SUBRS_P non-zero means always return 0 if the function 583 EXCLUDE_SUBRS_P non-zero means always return 0 if the function
560 called is a built-in. */ 584 called is a built-in. */
@@ -566,9 +590,6 @@ interactive_p (exclude_subrs_p)
566 struct backtrace *btp; 590 struct backtrace *btp;
567 Lisp_Object fun; 591 Lisp_Object fun;
568 592
569 if (!INTERACTIVE)
570 return 0;
571
572 btp = backtrace_list; 593 btp = backtrace_list;
573 594
574 /* If this isn't a byte-compiled function, there may be a frame at 595 /* If this isn't a byte-compiled function, there may be a frame at
@@ -1975,7 +1996,7 @@ DEFUN ("eval", Feval, Seval, 1, 1, 0,
1975 struct backtrace backtrace; 1996 struct backtrace backtrace;
1976 struct gcpro gcpro1, gcpro2, gcpro3; 1997 struct gcpro gcpro1, gcpro2, gcpro3;
1977 1998
1978 if (handling_signal) 1999 if (handling_signal || INPUT_BLOCKED_P)
1979 abort (); 2000 abort ();
1980 2001
1981 if (SYMBOLP (form)) 2002 if (SYMBOLP (form))