GNU bug report logs - #3984
23.0.96; defadvice of call-interactively defeats interactive-p

Previous Next

Package: emacs;

Reported by: "Drew Adams" <drew.adams <at> oracle.com>

Date: Thu, 30 Jul 2009 22:45:04 UTC

Severity: minor

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


Message #90 received at 3984 <at> debbugs.gnu.org (full text, mbox):

From: Ryan <rct <at> thompsonclan.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 3984 <at> debbugs.gnu.org
Subject: Re: bug#3984
Date: Tue, 17 Sep 2013 10:22:51 -0700
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.




This bug report was last modified 11 years and 243 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.