GNU bug report logs - #19066
25.0.50; nadvice and interactive-form

Previous Next

Package: emacs;

Reported by: Leo Liu <sdl.web <at> gmail.com>

Date: Sun, 16 Nov 2014 10:02:01 UTC

Severity: normal

Tags: confirmed

Found in versions 25.2, 25.0.50

To reply to this bug, email your comments to 19066 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to monnier <at> iro.umontreal.ca, bug-gnu-emacs <at> gnu.org:
bug#19066; Package emacs. (Sun, 16 Nov 2014 10:02:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Leo Liu <sdl.web <at> gmail.com>:
New bug report received and forwarded. Copy sent to monnier <at> iro.umontreal.ca, bug-gnu-emacs <at> gnu.org. (Sun, 16 Nov 2014 10:02:02 GMT) Full text and rfc822 format available.

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

From: Leo Liu <sdl.web <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.0.50; nadvice and interactive-form
Date: Sun, 16 Nov 2014 18:00:21 +0800
1. Start emacs and load a file with these lines:

--8<---------------cut here---------------start------------->8---
   (advice-add 'just-one-space :before #'change-interactive-form)
   (defun change-interactive-form (&optional x y)
     (interactive (list 1 1))
     (princ (list x y)))
--8<---------------cut here---------------end--------------->8---

M-x just-one-space prints (1 nil)

2. Start emacs and load a file with these lines:

--8<---------------cut here---------------start------------->8---
   (defun change-interactive-form (&optional x y)
     (interactive (list 1 1))
     (princ (list x y)))
   (advice-add 'just-one-space :before #'change-interactive-form)
--8<---------------cut here---------------end--------------->8---

M-x just-one-space errs: apply: Wrong number of arguments: (0 . 1), 2

Leo




bug Marked as found in versions 25.2. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Wed, 22 Feb 2017 05:10:01 GMT) Full text and rfc822 format available.

Added tag(s) confirmed. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Wed, 22 Feb 2017 05:10:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19066; Package emacs. (Fri, 28 May 2021 02:12:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Leo Liu <sdl.web <at> gmail.com>
Cc: 19066 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#19066: 25.0.50; nadvice and interactive-form
Date: Fri, 28 May 2021 04:11:13 +0200
Leo Liu <sdl.web <at> gmail.com> writes:

> 1. Start emacs and load a file with these lines:
>
>    (advice-add 'just-one-space :before #'change-interactive-form)
>    (defun change-interactive-form (&optional x y)
>      (interactive (list 1 1))
>      (princ (list x y)))
>
> M-x just-one-space prints (1 nil)
>
> 2. Start emacs and load a file with these lines:
>
>    (defun change-interactive-form (&optional x y)
>      (interactive (list 1 1))
>      (princ (list x y)))
>    (advice-add 'just-one-space :before #'change-interactive-form)
>
> M-x just-one-space errs: apply: Wrong number of arguments: (0 . 1), 2

So whether this works depends on whether `change-interactive-form' is
defined or not when `advice-add' is run?  (The only difference here is
the order.)

Perhaps Stefan has some insights here; added to the CCs.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19066; Package emacs. (Sun, 30 May 2021 17:28:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Leo Liu <sdl.web <at> gmail.com>, 19066 <at> debbugs.gnu.org
Subject: Re: bug#19066: 25.0.50; nadvice and interactive-form
Date: Sun, 30 May 2021 13:26:52 -0400
Lars Ingebrigtsen [2021-05-28 04:11:13] wrote:
> Leo Liu <sdl.web <at> gmail.com> writes:
>> 1. Start emacs and load a file with these lines:
>>
>>    (advice-add 'just-one-space :before #'change-interactive-form)
>>    (defun change-interactive-form (&optional x y)
>>      (interactive (list 1 1))
>>      (princ (list x y)))
>>
>> M-x just-one-space prints (1 nil)
>>
>> 2. Start emacs and load a file with these lines:
>>
>>    (defun change-interactive-form (&optional x y)
>>      (interactive (list 1 1))
>>      (princ (list x y)))
>>    (advice-add 'just-one-space :before #'change-interactive-form)
>>
>> M-x just-one-space errs: apply: Wrong number of arguments: (0 . 1), 2
>
> So whether this works depends on whether `change-interactive-form' is
> defined or not when `advice-add' is run?  (The only difference here is
> the order.)
> Perhaps Stefan has some insights here; added to the CCs.

[ Side note: the correct/desired behavior is the one described by (2),
  i.e. it should signal a "Wrong number of arguments" (tho after
  printing (1 1)).  ]

`advice-add` creates a new function object which is a "composition" of
the old function and the advice that's added to it.

In the case where `change-interactive-form` is defined later, one way to
make this work right would be for `advice-add` to put some kind of
"watcher" on (symbol-function 'change-interactive-form) to recompute the
interactive form of the "composed function".

Another way would be to make the interactive form of the "compose
function" more dynamic: make it re-checks the interactive form of every
advice function every time.  That's probably the better option.


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19066; Package emacs. (Mon, 31 May 2021 05:44:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Leo Liu <sdl.web <at> gmail.com>, 19066 <at> debbugs.gnu.org
Subject: Re: bug#19066: 25.0.50; nadvice and interactive-form
Date: Mon, 31 May 2021 07:43:34 +0200
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

> Another way would be to make the interactive form of the "compose
> function" more dynamic: make it re-checks the interactive form of every
> advice function every time.  That's probably the better option.

That sounds like a good solution to me -- the interactive path isn't
normally performance critical, so adding more work in that case should
be fine.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19066; Package emacs. (Mon, 31 May 2021 12:50:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Leo Liu <sdl.web <at> gmail.com>, 19066 <at> debbugs.gnu.org
Subject: Re: bug#19066: 25.0.50; nadvice and interactive-form
Date: Mon, 31 May 2021 08:49:27 -0400
Lars Ingebrigtsen [2021-05-31 07:43:34] wrote:
> Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>> Another way would be to make the interactive form of the "compose
>> function" more dynamic: make it re-checks the interactive form of every
>> advice function every time.  That's probably the better option.
> That sounds like a good solution to me -- the interactive path isn't
> normally performance critical, so adding more work in that case should
> be fine.

Yes, performance is not an issue.  But preserving the semantics 100% is
currently somewhere between hard and impossible.  99.9% is fairly easy,
OTOH (IIRC the main problem has to do with how the args get represented
in `command-history`).


        Stefan





This bug report was last modified 4 years and 14 days ago.

Previous Next


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