unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Brittleness of called-interactively-p
@ 2015-07-12  5:00 Dmitri Paduchikh
  2015-07-12 13:53 ` Stefan Monnier
                   ` (2 more replies)
  0 siblings, 3 replies; 35+ messages in thread
From: Dmitri Paduchikh @ 2015-07-12  5:00 UTC (permalink / raw)
  To: emacs-devel

Hello,

The documentation string of called-interactively-p states this:

> This function is very brittle, it may fail to return the intended result
> when the code is debugged, advised, or instrumented in some form. Some
> macros and special forms (such as `condition-case') may also sometimes
> wrap their bodies in a `lambda', so any call to `called-interactively-p'
> from those bodies will indicate whether that lambda (rather than the
> surrounding function) was called interactively.

I would like to make a suggestion. All these problems can be resolved by
introducing a special (dynamically bound) variable. Each call -- not only
interactive -- to an interactive function would rebind it to the value
providing all the necessary information about interactiveness of this call.
The called-interactively-p function would simply return this value. Of
course, this will change the meaning of called-interactively-p inside the
usual functions without interactive form, but previously it didn't make
sense to check called-interactively-p inside such functions anyway, so the
change shouldn't cause problems with existing code.

This will allow using called-interactively-p in those cases when changing of
function signature is undesirable for some reasons. For example, when
interactivity of call is insignificant for function interface and you don't
want to compromise the cleanness of function signature for such a little
reason. Or inside advices, when overriding function signature is undesirable
for compatibility reasons. And it even makes provision for some new uses,
e.g. inside function hooks.

Sorry if this idea has already been discussed here.



^ permalink raw reply	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2015-08-07 17:18 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-12  5:00 Brittleness of called-interactively-p Dmitri Paduchikh
2015-07-12 13:53 ` Stefan Monnier
2015-07-12 15:17   ` Dmitri Paduchikh
2015-07-12 23:26     ` Stefan Monnier
2015-07-13 15:17       ` Dmitri Paduchikh
2015-07-14 23:24         ` Stefan Monnier
2015-07-16 15:57           ` raman
2015-07-16 17:36             ` Drew Adams
2015-07-16 17:58               ` T.V Raman
2015-07-17  1:55                 ` Richard Stallman
2015-07-17  4:52                   ` Dmitri Paduchikh
2015-07-17 13:36                     ` Dmitri Paduchikh
     [not found]                       ` <jwvpp3qp9dn.fsf-monnier+emacs@gnu.org>
2015-07-18  5:16                         ` Dmitri Paduchikh
2015-07-17 18:15                     ` raman
2015-07-17 18:14                   ` raman
2015-07-17 19:31                     ` Drew Adams
2015-07-17 23:25                       ` raman
2015-07-18  1:47                         ` Drew Adams
2015-07-20 12:19                       ` Andreas Röhler
2015-07-16 22:55             ` Stefan Monnier
2015-07-17 18:10               ` raman
2015-07-18  0:57                 ` Stefan Monnier
2015-07-18  4:39               ` Dmitri Paduchikh
2015-07-20 12:22                 ` Andreas Röhler
2015-07-20 22:23                 ` Stefan Monnier
2015-08-06 22:30         ` Stefan Monnier
2015-08-06 22:33         ` Stefan Monnier
2015-08-07 13:35           ` Dmitri Paduchikh
2015-08-07 17:18             ` Stefan Monnier
2015-07-18 22:29   ` raman
2015-07-12 21:59 ` Richard Stallman
2015-07-13 15:17   ` Dmitri Paduchikh
2015-07-13 23:03     ` Richard Stallman
2015-08-06 22:36     ` Stefan Monnier
2015-07-17 20:35 ` Przemysław Wojnowski

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).