From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#19066: 25.0.50; nadvice and interactive-form Date: Sun, 30 May 2021 13:26:52 -0400 Message-ID: References: <87y4rbtqh6.fsf@gmail.com> <87r1hry5dq.fsf@gnus.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32667"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Leo Liu , 19066@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 30 19:28:15 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lnPEU-0008Ga-MN for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 30 May 2021 19:28:14 +0200 Original-Received: from localhost ([::1]:39728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lnPET-0001y7-MJ for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 30 May 2021 13:28:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58484) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lnPEI-0001xr-Jk for bug-gnu-emacs@gnu.org; Sun, 30 May 2021 13:28:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48740) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lnPEI-0005SS-56 for bug-gnu-emacs@gnu.org; Sun, 30 May 2021 13:28:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lnPEI-0000Lx-0d for bug-gnu-emacs@gnu.org; Sun, 30 May 2021 13:28:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 30 May 2021 17:28:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19066 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 19066-submit@debbugs.gnu.org id=B19066.16223956251286 (code B ref 19066); Sun, 30 May 2021 17:28:01 +0000 Original-Received: (at 19066) by debbugs.gnu.org; 30 May 2021 17:27:05 +0000 Original-Received: from localhost ([127.0.0.1]:60286 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lnPDN-0000Kf-8o for submit@debbugs.gnu.org; Sun, 30 May 2021 13:27:05 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:40445) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lnPDI-0000K6-JC for 19066@debbugs.gnu.org; Sun, 30 May 2021 13:27:03 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id E58E88009E; Sun, 30 May 2021 13:26:54 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 816568040B; Sun, 30 May 2021 13:26:53 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1622395613; bh=tjyrVFC8kfKAeAt0NHel/X8JeOgmUZJz/sMrSAAegh8=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=UJ8dcQjX0OiaORj+Lv4XUfYzqLbAMxPLKoXg0YF/MSYkk/Hr/CDogIwqXb79JrF0k sQpas9pmUBtb0x3xbnT4YYmoxpCQCQlK5mtKL+oIjos7mqAxyH7RTmyWWu28cpjh5f 7Z93n1clxBK+N5tl24IvmwRJrv3bvOktNwfWNbRMF3JGtMSzQVQ6813/OCd+rOKkAF g8D8s8b4ezPJBcNRC48ULEphGfkIDOPu6qNHuR0lRoYufxFj61MlzgaOn9fUEJ0ZLF OQBf+O1oo8rw5XgL8mOUplIrrB/jkoQ3kAvMA8EdCFuoQ2Nv1ev/rU+0uRZyeija9k WLGnWwiQkMeoA== Original-Received: from alfajor (69-196-163-239.dsl.teksavvy.com [69.196.163.239]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 41845120D90; Sun, 30 May 2021 13:26:53 -0400 (EDT) In-Reply-To: <87r1hry5dq.fsf@gnus.org> (Lars Ingebrigtsen's message of "Fri, 28 May 2021 04:11:13 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:207637 Archived-At: Lars Ingebrigtsen [2021-05-28 04:11:13] wrote: > Leo Liu 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