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 #132 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: Fri, 20 Sep 2013 09:54:24 -0700
On 9/20/13 7:35 AM, Stefan Monnier wrote:
>> After a little more consideration, I think I know what the bug is. The goal
>> of "advice--called-interactively-skip" is to skip all the advice-related
>> stack frames of the called function, not advice-related stack frames for
>> advice on call-interactively.
> Oh, right.  How 'bout the patch below?
>
>
>          Stefan
>
>
> === modified file 'lisp/subr.el'
> --- lisp/subr.el	2013-09-18 03:50:18 +0000
> +++ lisp/subr.el	2013-09-20 14:34:03 +0000
> @@ -4246,6 +4246,8 @@
>   if those frames don't seem special and otherwise, it should return
>   the number of frames to skip (minus 1).")
>   
> +(defconst internal--call-interactively (symbol-function 'call-interactively))
> +
>   (defun called-interactively-p (&optional kind)
>     "Return t if the containing function was called by `call-interactively'.
>   If KIND is `interactive', then only return t if the call was made
> @@ -4321,7 +4323,9 @@
>           ;; Somehow, I sometimes got `command-execute' rather than
>           ;; `call-interactively' on my stacktrace !?
>           ;;(`(,_ . (t command-execute . ,_)) t)
> -        (`(,_ . (t call-interactively . ,_)) t)))))
> +        (`(,_ . (t ,(or `call-interactively
> +                        (pred (eq internal--call-interactively))) . ,_))
> +         t)))))
>   
>   (defun interactive-p ()
>     "Return t if the containing function was run directly by user input.
>
That would certainly work, assuming that subr.el is always loaded before 
nadvice.el (so call-interactively could not possibly be advised yet), 
which seems likely to be true since subr.el contains so many core functions.

Since this bug report is just about advising call-interactively, which 
we now have a fix for, should I open a separate bug about the around 
advice?




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.