emacs-devel
[Top][All Lists]
Advanced

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

Re: Brittleness of called-interactively-p


From: Dmitri Paduchikh
Subject: Re: Brittleness of called-interactively-p
Date: Fri, 07 Aug 2015 18:35:20 +0500
User-agent: Gnus/5.13 (Gnus v5.13)

Stefan Monnier <address@hidden> writes:

>> These calls are internal to the advice mechanism and, of course, they
>> cannot be considered conceptually interactive.

SM> If the original function uses called-interactively-p and the "whole
SM> advised function" is called interactively, then called-interactively-p
SM> should return t, yet this call is inside an interactive function which
SM> is called non-interactively.

Exactly, see above. I thought that may be it is better to associate
interactive form with function symbol rather than with function itself. This
would solve issues with calls that are internal to advice system. When
advised, the original function becomes non-interactive automatically. There
can be other issues with such approach though. The most obvious one is that
it is not longer possible to use interactive lambdas. Personally I think
that they are not so necessary and are better to be avoided when defining
key bindings because symbols look better in help output. Also there is
problem with idiom like this:

(call-interactively (lambda (b e) (interactive "r") ...))

But note that conceptually this is not a interactive call of command. It is
about reusing the feature of interactive calls to obtain values for
arguments. So it probably can be replaced with something like

(call-with-interactive-args "r" (lambda (b e) ...))

>> It is not clear for me whether this approach will help to solve the current
>> problem of macros wrapping fragments of code in lambdas.

SM> BTW, the real solution, which is simple and reliable is to not use
SM> called-interactively-p at all, and use an argument instead:

SM>    (defun foo (bar &optional called-interactively)
SM>      (interactive (list toto t))

Yes, indeed, and this method is described in the doc string of
called-interactively-p. This means however that one odd argument is added to
the function interface which plays only technical role. And also advices
which need this information will have to modify the argument list of the
original function if it does not provide it already.

RMS had an idea to make sort of separate argument for this purpose which
does not belong to function interface. My comment above was directed to him.
As you can see I was confused, since in theory it can work with macros and
lambdas no worse than your recommendation of using special argument. I have
not ideas about this approach, so do not comment it further.

I will be away for next ten days, and so won't be able to participate in the
discussion in the case you or somebody else is interested.



reply via email to

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