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

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

bug#3984:


From: Ryan
Subject: bug#3984:
Date: Tue, 17 Sep 2013 10:22:51 -0700
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130801 Thunderbird/17.0.8

On 9/17/13 6:10 AM, Stefan Monnier wrote:
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.
Wait, so defadvice and friends are going away entirely? Is everything in advice.el going away, or are some parts of it going to be converted to the new advice system? Is all this documented somewhere?

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
I tried the before advice, and it doesn't seem to work. With the following code in emacs -Q:

(advice-add 'call-interactively :before #'ignore)
(defun myfun2 ()
  (interactive)
  (or (called-interactively-p)
      (error "Must be interactive!")))
(call-interactively 'myfun2)

I get the following stack trace:

Debugger entered--Lisp error: (error "Must be interactive!")
  signal(error ("Must be interactive!"))
  error("Must be interactive!")
  (or (called-interactively-p) (error "Must be interactive!"))
  myfun2()
  #<subr call-interactively>(myfun2)
  apply(#<subr call-interactively> myfun2)
  call-interactively(myfun2)
eval-region(345 373 t (lambda (ignore) (goto-char 373) (quote (call-interactively (quote myfun2))))) ; Reading at buffer position 345 apply(eval-region (345 373 t (lambda (ignore) (goto-char 373) (quote (call-interactively (quote myfun2))))))
  eval-defun-2()
  eval-defun(nil)
  #<subr call-interactively>(eval-defun nil nil)
  apply(#<subr call-interactively> (eval-defun nil nil))
  call-interactively(eval-defun nil nil)
  command-execute(eval-defun)

Same thing happens when I do M-x myfun2.





reply via email to

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