Subject: bug#3984: Fix for #3984

From: Stefan Monnier <[email-masked]>
Date: Tue, 17 Sep 2013 09:10:40 -0400

> We have "ad-is-advised" which we can use to find which stack frames
> correspond to advised functions. We have "ad-get-orig-definition" which we
> can use to find the original definition of an advised function.

These are functions of advice.el, which is on the way out.  We need to
look at nadvice.el.

Thinking about it once more, I realize that your "advised
call-interactively" case might indeed be resolved by the current code,
except that it bumps into the problematic case of "deepest advice is
using :around".

Could you check if it is the case simply be doing a dummy (advice-add
'call-interactively :before #'ignore) before your defadvice?

If that works, then we can probably fix that problem in the following way:
- keep track of every function value (e.g. #<subr call-interactively> in
  our case) that is wrapped (at the deepest level) in an :around advice
  (e.g. in a hash-table).
- when walking up the stack, if we find such a function, look up the
  stack searching for the matching function symbol (just like we already
  do when encountering an internal advice element on the stack).

        Stefan