emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Suggest: dont declare interactive-p obsolete


From: raman
Subject: Suggest: dont declare interactive-p obsolete
Date: Wed, 18 Nov 2015 17:57:49 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

This is a minor change -- that will let existing code run without
warnings.
If we turned the defun in subr.el to  a defsubst and dropped the 
(declare (obsolete called-interactively-p "23.2"))
  (called-interactively-p 'interactive))
-- 
we'd lose nothing as far as I can tell, but eliminate  the warning ---
and keep code more readable --
(when  (interactive-p)...)
is arguably more readable than 
(when (called-interactively-p 'interactive) ...)

At present   subr.el defines:

(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'."
  (declare (obsolete called-interactively-p "23.2"))
  (called-interactively-p 'interactive))
-- 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]