540 |
|
|
541 |
|
|
542 |
DEFUN ("interactive-p", Finteractive_p, Sinteractive_p, 0, 0, 0, |
DEFUN ("interactive-p", Finteractive_p, Sinteractive_p, 0, 0, 0, |
543 |
doc: /* Return t if function in which this appears was called interactively. |
doc: /* Return t if the function was run directly by user input. |
544 |
This means that the function was called with call-interactively (which |
This means that the function was called with call-interactively (which |
545 |
includes being called as the binding of a key) |
includes being called as the binding of a key) |
546 |
and input is currently coming from the keyboard (not in keyboard macro). */) |
and input is currently coming from the keyboard (not in keyboard macro), |
547 |
|
and Emacs is not running in batch mode (`noninteractive' is nil). |
548 |
|
|
549 |
|
The only known proper use of `interactive-p' is in deciding whether to |
550 |
|
display a helpful message, or how to display it. If you're thinking |
551 |
|
of using it for any other purpose, it is quite likely that you're |
552 |
|
making a mistake. Think: what do you want to do when the command is |
553 |
|
called from a keyboard macro? |
554 |
|
|
555 |
|
If you want to test whether your function was called with |
556 |
|
`call-interactively', the way to do that is by adding an extra |
557 |
|
optional argument, and making the `interactive' spec specify non-nil |
558 |
|
unconditionally for that argument. (`p' is a good way to do this.) */) |
559 |
() |
() |
560 |
{ |
{ |
561 |
return interactive_p (1) ? Qt : Qnil; |
return (INTERACTIVE && interactive_p (1)) ? Qt : Qnil; |
562 |
} |
} |
563 |
|
|
564 |
|
|
565 |
/* Return 1 if function in which this appears was called |
DEFUN ("called-interactively-p", Fcall_interactive_p, Scall_interactive_p, 0, 0, 0, |
566 |
interactively. This means that the function was called with |
doc: /* Return t if the function using this was called with call-interactively. |
567 |
call-interactively (which includes being called as the binding of |
This is used for implementing advice and other function-modifying |
568 |
a key) and input is currently coming from the keyboard (not in |
features of Emacs. |
569 |
keyboard macro). |
|
570 |
|
The cleanest way to test whether your function was called with |
571 |
|
`call-interactively', the way to do that is by adding an extra |
572 |
|
optional argument, and making the `interactive' spec specify non-nil |
573 |
|
unconditionally 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. |
582 |
|
|
583 |
EXCLUDE_SUBRS_P non-zero means always return 0 if the function |
EXCLUDE_SUBRS_P non-zero means always return 0 if the function |
584 |
called is a built-in. */ |
called is a built-in. */ |
590 |
struct backtrace *btp; |
struct backtrace *btp; |
591 |
Lisp_Object fun; |
Lisp_Object fun; |
592 |
|
|
|
if (!INTERACTIVE) |
|
|
return 0; |
|
|
|
|
593 |
btp = backtrace_list; |
btp = backtrace_list; |
594 |
|
|
595 |
/* If this isn't a byte-compiled function, there may be a frame at |
/* If this isn't a byte-compiled function, there may be a frame at |
1996 |
struct backtrace backtrace; |
struct backtrace backtrace; |
1997 |
struct gcpro gcpro1, gcpro2, gcpro3; |
struct gcpro gcpro1, gcpro2, gcpro3; |
1998 |
|
|
1999 |
if (handling_signal) |
if (handling_signal || INPUT_BLOCKED_P) |
2000 |
abort (); |
abort (); |
2001 |
|
|
2002 |
if (SYMBOLP (form)) |
if (SYMBOLP (form)) |