bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#3984: Fix for #3984


From: Stefan Monnier
Subject: bug#3984: Fix for #3984
Date: Fri, 13 Sep 2013 17:02:38 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

>> Looking at the code in trunk, I see that there is a special hook for
>> functions to decide which stack frames to skip over when looking for
>> call-interactively. I still think they should relax the test for
>> equality to "equal indirect-functions" instead of exactly the symbol
>> call-interactively.

The code does check "equal modulo indirect-functions" in some cases, but
indeed not all.  I don't think that replacing the equality check against
`call-interactively' with a check modulo indirect-functions would solve
your problem, tho (that only helps when calling though an alias of
call-interactively, but here the relevant stack frame will be a call to
the #<subr call-interactively> which is not
equal-modulo-indirect-functions to call-interactively since
call-interactively has been redefined to a different functions by the
advice).

You can probably use called-interactively-p-functions to detect the
#<subr call-interactively> and skip the frames between it and the
corresponding call to `call-interactively'.

But if you find a cute patch against the current code which makes it
work for you in a cleanish way, do send it here, to see if it can
be included.

> Actually, I just noticed that in trunk, nadvice.el adds a function to
> "called-interactively-p-functions" to skip advice-related stack frames, but
> this works only for advice on the interactive function, not advice defined
> on call-interactively itself.

Indeed.  It doesn't even work for all advices (more specifically it
doesn't work for :around advices, which means it doesn't work for
advices defined via `defadvice' since these all turn into one
big :around "new advice").

> Furthermore, from my limited testing it appears that the structure of
> the call stack for advised functions has changes significantly in
> trunk, making my code obsolete.

Indeed, the implementation of advices has been completely changed.

> The whole thing looks like a work in progress right now.

There's no planned change to it, so I consider it "ready modulo
bug-reports".  AFAIK it works "at least as well as before" (it works
better than before in the sense that Edebugging a function with calls
to called-interactively-p should now work correctly).

`called-interactively-p' is a big ugly hack and only works sometimes.
It can break in all kinds of cases (e.g. it currently won't work in
byte-compiled lexical-binding code within a `catch', or
a `condition-case', or the unwind part of an `unwind-protect').  Also,
the functions called (non-interactively, obviously) by your
`call-interactively' advice will probably think that they're called
interactively (hopefully your advice doesn't call many functions, and
hopefully none of them cares whether it's called interactively or not).


        Stefan





reply via email to

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