Function: interactive-p
interactive-p is a byte-compiled function defined in subr.el.gz.
This function is obsolete since 23.2; use called-interactively-p
instead.
Signature
(interactive-p)
Documentation
Return t if the containing function was run directly by user input.
This means that the function was called with call-interactively
(which includes being called as the binding of a key)
and input is currently coming from the keyboard (not a keyboard macro),
and Emacs is not running in batch mode (noninteractive is nil).
The only known proper use of interactive-p is in deciding whether to
display a helpful message, or how to display it. If you're thinking
of using it for any other purpose, it is quite likely that you're
making a mistake. Think: what do you want to do when the command is
called from a keyboard macro or in batch mode?
To test whether your function was called with call-interactively,
either (i) add an extra optional argument and give it an interactive
spec that specifies non-nil unconditionally (such as "p"); or (ii)
use called-interactively-p.
To test whether a function can be called interactively, use
commandp.
Probably introduced at or before Emacs version 22.1.
Source Code
;; Defined in /usr/src/emacs/lisp/subr.el.gz
(defun interactive-p ()
"Return t if the containing function was run directly by user input.
This means that the function was called with `call-interactively'
\(which includes being called as the binding of a key)
and input is currently coming from the keyboard (not a keyboard macro),
and Emacs is not running in batch mode (`noninteractive' is nil).
The only known proper use of `interactive-p' is in deciding whether to
display a helpful message, or how to display it. If you're thinking
of using it for any other purpose, it is quite likely that you're
making a mistake. Think: what do you want to do when the command is
called from a keyboard macro or in batch mode?
To test whether your function was called with `call-interactively',
either (i) add an extra optional argument and give it an `interactive'
spec that specifies non-nil unconditionally (such as \"p\"); or (ii)
use `called-interactively-p'.
To test whether a function can be called interactively, use
`commandp'."
;; Kept around for now. See discussion at:
;; https://lists.gnu.org/r/emacs-devel/2020-08/msg00564.html
(declare (obsolete called-interactively-p "23.2"))
(called-interactively-p 'interactive))