emacs-devel
[Top][All Lists]
Advanced

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

Brittleness of called-interactively-p


From: Dmitri Paduchikh
Subject: Brittleness of called-interactively-p
Date: Sun, 12 Jul 2015 10:00:54 +0500
User-agent: Gnus/5.13 (Gnus v5.13)

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.



reply via email to

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