X-Loop: help-debbugs@HIDDEN Subject: bug#68114: [PATCH] Make 'advice-remove' interactive Resent-From: Steven Allen <steven@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Fri, 29 Dec 2023 19:58:02 +0000 Resent-Message-ID: <handler.68114.B.170387984521718 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: report 68114 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 68114 <at> debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@HIDDEN Received: via spool by submit <at> debbugs.gnu.org id=B.170387984521718 (code B ref -1); Fri, 29 Dec 2023 19:58:02 +0000 Received: (at submit) by debbugs.gnu.org; 29 Dec 2023 19:57:25 +0000 Received: from localhost ([127.0.0.1]:42279 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rJIyz-0005eE-15 for submit <at> debbugs.gnu.org; Fri, 29 Dec 2023 14:57:25 -0500 Received: from lists.gnu.org ([2001:470:142::17]:49130) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <steven@HIDDEN>) id 1rJIyx-0005e0-9W for submit <at> debbugs.gnu.org; Fri, 29 Dec 2023 14:57:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <steven@HIDDEN>) id 1rJIyr-00028g-HE for bug-gnu-emacs@HIDDEN; Fri, 29 Dec 2023 14:57:17 -0500 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <steven@HIDDEN>) id 1rJIyp-0006Xi-Pq for bug-gnu-emacs@HIDDEN; Fri, 29 Dec 2023 14:57:17 -0500 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 66C6E5C02A2 for <bug-gnu-emacs@HIDDEN>; Fri, 29 Dec 2023 14:57:13 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Fri, 29 Dec 2023 14:57:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stebalien.com; h=cc:content-type:content-type:date:date:from:from:in-reply-to :message-id:mime-version:reply-to:subject:subject:to:to; s=fm1; t=1703879833; x=1703966233; bh=UBaS2HmHX+H70wAN7gePV2kOoekIZrZr TQNtT6lTWck=; b=MAjYNMqtIz1omGz6BuzCI36jFfcnkCyZmCAn7GiuAT/ykUdq mBP1cdveZOPsUx8ciP/e7kx7AZI1KtIMWUUglOiAtHRIyKvEbCJGO54q+bHHUMPz kNPz7g1z4T/I2TuvaAFnSKg4QBl6RI/U9/G0X4qE5uj4ZBiKzvd+TVbdzM9uopGg I6zKTaGlxn456SdWuYvWVauP5G8dvzEgRLwbmt0g/RnzUBWIxsCILjnS5G1bgEWh qfX+9/lD6KB8ahcEJr0L5W8GmRuCCPigcfvT21aRm1UZR1OlGgdOqzitDJwI1dY3 ejn7+gmofaTqYWN41+rIl/mc/JY+uUhAMoiLrw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:message-id :mime-version:reply-to:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1703879833; x=1703966233; bh=UBaS2HmHX+H70wAN7gePV2kOoekIZrZrTQN tT6lTWck=; b=Uq1ojKfOyCbuJ7/Wdyp2DDsP2AIRe6PeyTH6YkxsW0ukRYbU6ir XCW53797F9BHZ+7RAZkYkFSpioIgxaq+/ukOQCYBIDk/oFPO2P+bsGFiY9JZAJu8 8k7zqSx9LD778Z4aMmTAiSHTheU3cPQSBavJsqoROayPi9i+7Zwq8mfgPnIJeZQn c+guY3dJQ7opAuf0ZB/sOuE89B8y9ckfz26kq7qKrsHCZgo5oA2Ym+Izp0cEUsQ3 D5k8T0uMrt1LZ7ybfGwwmMgtMRWdzkGnC/jNCj02csr20SzAWEk/rf4Jm0mwcfD6 e0O2k8wlpcJbhwmjZv8ThSAeTlSf9h6VBDw== X-ME-Sender: <xms:mSSPZcIH7bW9n3utM-C8cAbBTlqIUHDeEeEvoMYuKpHZT5j_hmbdFA> <xme:mSSPZcK1shUjZ0JpYIwFc0uMjE3FBJhiXOAV3owzK-NzecnSWBb6UVjuU9IkB_A81 CUVcds9q7sUTn_Ak2k> X-ME-Received: <xmr:mSSPZcsHnI70qHyuZKV7az9l3nRptO4DTYklrxaVVFLJzkq0fzpV1Vbc4KuqoOLQttycgknDcSjKIw5P6xCDilv44yQx6A> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdeffedgudeftdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkfggtgesmhdtreertd dttdenucfhrhhomhepufhtvghvvghnucetlhhlvghnuceoshhtvghvvghnsehsthgvsggr lhhivghnrdgtohhmqeenucggtffrrghtthgvrhhnpeekffffgfevteehtdeiffelffegke dvieeigeehfedtteejkeefhfevtddtkeefffenucevlhhushhtvghrufhiiigvpedtnecu rfgrrhgrmhepmhgrihhlfhhrohhmpehsthgvvhgvnhesshhtvggsrghlihgvnhdrtghomh X-ME-Proxy: <xmx:mSSPZZYfd2VSu8M2pqZgEND8aRFfDScJur62mUm87H8Uihf7Jj5RGA> <xmx:mSSPZTb7pKj_wf4Qcc5oILT0BL6LrhFNVubacmQsoOn_W0GRLh0_2Q> <xmx:mSSPZVAWoPL-LTLPNnihAwcUU0EqMmlGQLdr_MHdDdTJjcVvDccCmA> <xmx:mSSPZd0eu_0ULModz0inTP-Lz0dFvj3XKK0ZtkzYyRI-S3F3ajwtnw> Feedback-ID: ie8a146a7:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for <bug-gnu-emacs@HIDDEN>; Fri, 29 Dec 2023 14:57:12 -0500 (EST) From: Steven Allen <steven@HIDDEN> Date: Fri, 29 Dec 2023 11:57:12 -0800 Message-ID: <87r0j42353.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=66.111.4.28; envelope-from=steven@HIDDEN; helo=out4-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.6 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.4 (/) --=-=-= Content-Type: text/plain This patch makes 'advice-remove' interactive to match 'ad-advice-remove'. Unlike 'ad-advice-remove', 'advice-remove' works with new-style advice as well. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Make-advice-remove-interactive.patch From 41de95097d3e79967f4fbb417aba424e8ffce058 Mon Sep 17 00:00:00 2001 From: Steven Allen <steven@HIDDEN> Date: Fri, 29 Dec 2023 09:53:05 -0800 Subject: [PATCH] Make 'advice-remove' interactive `ad-advice-remove' is already interactive, but it doesn't work with new-style advice. * lisp/emacs-lisp/nadvice.el (advice-remove): Make it interactive. --- lisp/emacs-lisp/nadvice.el | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lisp/emacs-lisp/nadvice.el b/lisp/emacs-lisp/nadvice.el index 9f2b42f5765..32e54b3dd02 100644 --- a/lisp/emacs-lisp/nadvice.el +++ b/lisp/emacs-lisp/nadvice.el @@ -539,6 +539,16 @@ advice-remove or an autoload and it preserves `fboundp'. Instead of the actual function to remove, FUNCTION can also be the `name' of the piece of advice." + (interactive + (let ((symbol (intern (completing-read + "Advised Function: " + obarray + (lambda (sym) (advice--p (advice--symbol-function sym))) + t nil nil + (when-let (def (function-called-at-point)) (symbol-name def))))) + advice) + (advice-mapc (lambda (f _) (push (cons (prin1-to-string f) f) advice)) symbol) + (list symbol (cdr (assoc-string (completing-read "Advice: " advice) advice))))) (let ((f (symbol-function symbol))) (remove-function (cond ;This is `advice--symbol-function' but as a "place". ((get symbol 'advice--pending) -- 2.43.0 --=-=-=--
Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) Content-Type: text/plain; charset=utf-8 X-Loop: help-debbugs@HIDDEN From: help-debbugs@HIDDEN (GNU bug Tracking System) To: Steven Allen <steven@HIDDEN> Subject: bug#68114: Acknowledgement ([PATCH] Make 'advice-remove' interactive) Message-ID: <handler.68114.B.170387984521718.ack <at> debbugs.gnu.org> References: <87r0j42353.fsf@HIDDEN> X-Gnu-PR-Message: ack 68114 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 68114 <at> debbugs.gnu.org Date: Fri, 29 Dec 2023 19:58:02 +0000 Thank you for filing a new bug report with debbugs.gnu.org. This is an automatically generated reply to let you know your message has been received. Your message is being forwarded to the package maintainers and other interested parties for their attention; they will reply in due course. Your message has been sent to the package maintainer(s): bug-gnu-emacs@HIDDEN If you wish to submit further information on this problem, please send it to 68114 <at> debbugs.gnu.org. Please do not send mail to help-debbugs@HIDDEN unless you wish to report a problem with the Bug-tracking system. --=20 68114: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D68114 GNU Bug Tracking System Contact help-debbugs@HIDDEN with problems
X-Loop: help-debbugs@HIDDEN Subject: bug#68114: [PATCH] Make 'advice-remove' interactive Resent-From: Eli Zaretskii <eliz@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Fri, 29 Dec 2023 20:13:01 +0000 Resent-Message-ID: <handler.68114.B68114.1703880754857 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 68114 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Steven Allen <steven@HIDDEN>, Stefan Monnier <monnier@HIDDEN> Cc: 68114 <at> debbugs.gnu.org Received: via spool by 68114-submit <at> debbugs.gnu.org id=B68114.1703880754857 (code B ref 68114); Fri, 29 Dec 2023 20:13:01 +0000 Received: (at 68114) by debbugs.gnu.org; 29 Dec 2023 20:12:34 +0000 Received: from localhost ([127.0.0.1]:42314 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rJJDd-0000Dl-Us for submit <at> debbugs.gnu.org; Fri, 29 Dec 2023 15:12:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40440) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1rJJDb-0000DX-Gy for 68114 <at> debbugs.gnu.org; Fri, 29 Dec 2023 15:12:32 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1rJJDV-0004u1-Sh; Fri, 29 Dec 2023 15:12:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=xI1YwKIzXUcOVbsfahpQ0HuBE5gILeymA6KIKAmfQlo=; b=DNXFrnKYwl3N k0EEvpY20i2xIdewREi/4ZrmP7tm3xdXNmiMpAeXVFCSgn2JYPkQzyOw2NdPxBHc76BJ9N6qfTPnU IaDdhs4J+ceaJnSACC9LMMo3o9WUh2u7XixeLr+Sa9C0faH2EQU2/19xSqa3nMDsjBYZLcxcsA2M3 cwPHzK2LOQ0ShqEkFbnhmovUeSsOERq7YIg4hRPzNlUU+KlvvB3VlwJxebY3xggTg5tiQAVTTuuwH 1hMyDORT/me/tBQYCLyBKE3sHqlOOUKL0JLJHdDbh5xMtmY86PMQjnu+7msLKPDB0KgIB0GZmAEcm 1ktT9aug7TKCLJ0BW4fvFg==; Date: Fri, 29 Dec 2023 22:12:13 +0200 Message-Id: <83a5ps6a5e.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> In-Reply-To: <87r0j42353.fsf@HIDDEN> (message from Steven Allen on Fri, 29 Dec 2023 11:57:12 -0800) References: <87r0j42353.fsf@HIDDEN> X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > From: Steven Allen <steven@HIDDEN> > Date: Fri, 29 Dec 2023 11:57:12 -0800 > > This patch makes 'advice-remove' interactive to match > 'ad-advice-remove'. Unlike 'ad-advice-remove', 'advice-remove' works > with new-style advice as well. Stefan, any comments? In any case, this change needs a corresponding changes for documentation and NEWS. Thanks.
X-Loop: help-debbugs@HIDDEN Subject: bug#68114: [PATCH] Make 'advice-remove' interactive Resent-From: Steven Allen <steven@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Fri, 29 Dec 2023 20:48:02 +0000 Resent-Message-ID: <handler.68114.B68114.17038828811900 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 68114 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Eli Zaretskii <eliz@HIDDEN>, Stefan Monnier <monnier@HIDDEN> Cc: 68114 <at> debbugs.gnu.org Received: via spool by 68114-submit <at> debbugs.gnu.org id=B68114.17038828811900 (code B ref 68114); Fri, 29 Dec 2023 20:48:02 +0000 Received: (at 68114) by debbugs.gnu.org; 29 Dec 2023 20:48:01 +0000 Received: from localhost ([127.0.0.1]:42345 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rJJlw-0000UW-P4 for submit <at> debbugs.gnu.org; Fri, 29 Dec 2023 15:48:01 -0500 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:52239) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <steven@HIDDEN>) id 1rJJlu-0000Tk-KH for 68114 <at> debbugs.gnu.org; Fri, 29 Dec 2023 15:47:59 -0500 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 380085C02D4; Fri, 29 Dec 2023 15:47:53 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Fri, 29 Dec 2023 15:47:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stebalien.com; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm1; t=1703882873; x= 1703969273; bh=rq/wHt9sHHVchA5kDjp1cpHEg+X2ZOdmV/pzvqSCJPk=; b=N xNGmmgwq1YZeKtkcCxbE1bMXnTwE8bfzBs4ONnXS1RleuyBF7zzWtKkf+ahJ4ZfS V2cy7tbcKTxNHTLgzSg4kNYuITpCA3jZ55BXMwBtdgVpiP17UFfvJ/Mui+fT8xNA NBpP1iwPtW0p4WXVASLGg08OxNwTbRTfxEqKwzoSRiPykA6EsmYj8O+3sP1wzaUS +ICAKpACDEbAE1agH1OOSOP1yxh66XnmnglpjHhkB3EHG9ujMMwYDk3Lm2qAlliT 5fLsSXOKQ+1AccRtGhzxezI1p+ZdlUT92WUvgA1ZI4gEeHjnq7dU8MiJ7q/o7P9U kDnUd4YbXB5NATKa6efqg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1703882873; x=1703969273; bh=rq/wHt9sHHVchA5kDjp1cpHEg+X2 ZOdmV/pzvqSCJPk=; b=p/i+IL6ttvUYoKM7J0cvugXH0xaxbqoal9ib0og8o3lR wI5ZFoOBw6fYA67omu3xwoATEA7HDsA/LjyqwbfovZmioYy8b0iE7HuIbu1opYwe qhxA1kOOwm47ch1uyl9lYR6znRDGC/y97mD4z2M/jmwqgvZCDk/eo91eV+AcAdZJ 9gKigGvCY1CRzSNBCGTRYxvjB//m35OPuXYOtKW57oUBmcTEpQ2Fr2ykj2P4ZL10 DDdOOHv/YW4JVUiiZ+8xuNJ0sY1HTsBvrzpvnCLwy5zpNgFchGKYkZoNstuB9ixA gJd3kuD/9i1fnJuzmCzW4ORdN6MEJJ1AjR+smbQhZw== X-ME-Sender: <xms:eDCPZXNh64zT74rLr7CKY6L4yeTrBAIenOOYcAFopEdP5t1w7YQqug> <xme:eDCPZR_sv1HEZkcDN_ZNeWwHjqtuVp9VDyoYBSmWP1zQxx15rqM4GuAR8c9TNnAyH tmyi_jcvGKIGhVps_c> X-ME-Received: <xmr:eDCPZWS7z8KAa4pLfTdLqrT4tLoKGZEUE3W4RV-Vs1PRNCIzIp6aR7NdDEZ-WuStLFQnIcNm0hPbJLkn_c1vI2F5iGFqsg> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdeffedgudegudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufgjfhffkfggtgesmhdtreertddttdenucfhrhhomhepufhtvghv vghnucetlhhlvghnuceoshhtvghvvghnsehsthgvsggrlhhivghnrdgtohhmqeenucggtf frrghtthgvrhhnpeejudefvdeijeeukedttdegudegffevjeehheeiueelgfffhfelffeh feevhfdvgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehsthgvvhgvnhesshhtvggsrghlihgvnhdrtghomh X-ME-Proxy: <xmx:eDCPZbsN4lHoqO0tA4MR7QMUwjCEnO-aQJDl3xcZn3ExMOPAFIxMSQ> <xmx:eDCPZfeePQR-NCDwJ4dtdhA6kPSqC_q1g15ooZzG5qDAYI5fdV7V0Q> <xmx:eDCPZX01qWmwL3luc_EL27-wtd_7qkcmp-tXnfse8LYN5RdsW0c-HA> <xmx:eTCPZXH1CDGNnqFF3aeSCEB7oqN7Xb-uxq9au8I2mSat-R9S_1cVRw> Feedback-ID: ie8a146a7:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 29 Dec 2023 15:47:52 -0500 (EST) From: Steven Allen <steven@HIDDEN> In-Reply-To: <83a5ps6a5e.fsf@HIDDEN> References: <87r0j42353.fsf@HIDDEN> <83a5ps6a5e.fsf@HIDDEN> Date: Fri, 29 Dec 2023 12:47:50 -0800 Message-ID: <87r0j491mx.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain Thanks for the quick feedback. I've attached an updated patch with a NEWS and update and some documentation. Let me know if there's a better place to document this of if I made a mistake somewhere. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment From e1c6ccbf22a80f9ec96a7034ef66d2d7b66e793b Mon Sep 17 00:00:00 2001 From: Steven Allen <steven@HIDDEN> Date: Fri, 29 Dec 2023 09:53:05 -0800 Subject: [PATCH] Make 'advice-remove' interactive `ad-advice-remove' is already interactive, but it doesn't work with new-style advice. * lisp/emacs-lisp/nadvice.el (advice-remove): Make it interactive. * doc/lispref/functions.texi (Advising Named Functions): Document that 'advice-remove' is now an interactive command. --- doc/lispref/functions.texi | 8 +++++--- etc/NEWS | 4 ++++ lisp/emacs-lisp/nadvice.el | 10 ++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi index d0c8f3e90e8..30779cb7c72 100644 --- a/doc/lispref/functions.texi +++ b/doc/lispref/functions.texi @@ -2077,10 +2077,12 @@ Advising Named Functions (@pxref{Core Advising Primitives}). @end defun -@defun advice-remove symbol function +@deffn Command advice-remove symbol function Remove the advice @var{function} from the named function @var{symbol}. -@var{function} can also be the @code{name} of a piece of advice. -@end defun +@var{function} can also be the @code{name} of a piece of advice. When +called interactively, prompt for both an advised @var{function} and +the advice to remove. +@end deffn @defun advice-member-p function symbol Return non-@code{nil} if the advice @var{function} is already in the named diff --git a/etc/NEWS b/etc/NEWS index c002ec33d45..d4c0784e3f2 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1362,6 +1362,10 @@ values. * Lisp Changes in Emacs 30.1 +++ +** 'advice-remove' is now an interactive command. +When called interactively, 'advice-remove' now prompts for an advised +function to the advice to remove. + ** New 'pop-up-frames' action alist entry for 'display-buffer'. This has the same effect as the variable of the same name and takes precedence over the variable when present. diff --git a/lisp/emacs-lisp/nadvice.el b/lisp/emacs-lisp/nadvice.el index 9f2b42f5765..32e54b3dd02 100644 --- a/lisp/emacs-lisp/nadvice.el +++ b/lisp/emacs-lisp/nadvice.el @@ -539,6 +539,16 @@ advice-remove or an autoload and it preserves `fboundp'. Instead of the actual function to remove, FUNCTION can also be the `name' of the piece of advice." + (interactive + (let ((symbol (intern (completing-read + "Advised Function: " + obarray + (lambda (sym) (advice--p (advice--symbol-function sym))) + t nil nil + (when-let (def (function-called-at-point)) (symbol-name def))))) + advice) + (advice-mapc (lambda (f _) (push (cons (prin1-to-string f) f) advice)) symbol) + (list symbol (cdr (assoc-string (completing-read "Advice: " advice) advice))))) (let ((f (symbol-function symbol))) (remove-function (cond ;This is `advice--symbol-function' but as a "place". ((get symbol 'advice--pending) -- 2.43.0 --=-=-=--
X-Loop: help-debbugs@HIDDEN Subject: bug#68114: [PATCH] Make 'advice-remove' interactive Resent-From: Stefan Kangas <stefankangas@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Fri, 29 Dec 2023 21:21:02 +0000 Resent-Message-ID: <handler.68114.B68114.170388485324968 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 68114 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Steven Allen <steven@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>, Stefan Monnier <monnier@HIDDEN> Cc: 68114 <at> debbugs.gnu.org Received: via spool by 68114-submit <at> debbugs.gnu.org id=B68114.170388485324968 (code B ref 68114); Fri, 29 Dec 2023 21:21:02 +0000 Received: (at 68114) by debbugs.gnu.org; 29 Dec 2023 21:20:53 +0000 Received: from localhost ([127.0.0.1]:42376 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rJKHk-0006Ue-VD for submit <at> debbugs.gnu.org; Fri, 29 Dec 2023 16:20:53 -0500 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]:56664) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <stefankangas@HIDDEN>) id 1rJKHi-0006UR-3g for 68114 <at> debbugs.gnu.org; Fri, 29 Dec 2023 16:20:51 -0500 Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-5555b8de81fso2756727a12.1 for <68114 <at> debbugs.gnu.org>; Fri, 29 Dec 2023 13:20:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703884844; x=1704489644; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:from:to:cc:subject:date:message-id:reply-to; bh=kA+5Dyo/c/kkLh5Ol19MX6CUmP59zDizVliTC2m0+oM=; b=OMMOhwx5EZ6Tho9Q6YWzq6i9uWb3L13HVpl8bbPcOXpE8uV77MtuaNhg4VI40gILWa yjjslYt/Vp28W0aG93k8Cs6Blw/cYeUyw4668r5DqlcfF8r1JQdKv77Bc3tbk+9rt0Io jzl/GpSX1X+9aUx+344ot9V+FZrzsKwrptRlWwYk/tpiNPnEqxX7h1P12dJNIqU5smlC b2w3LlPNNuu0xS5vJtnPQJNZ95G5/T+NtCTj/zA5+LmycV+9h9zkH4d+sOjcBlQ2LVul +Y0pBaKb2Stay4Zm374qrzgkKYkdAu+sqSxYG6tpJYGyGXCeKSF4TJTreMjdeSJQ+JUJ pztQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703884844; x=1704489644; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=kA+5Dyo/c/kkLh5Ol19MX6CUmP59zDizVliTC2m0+oM=; b=ra5WBSPFa8dK7jS+5iQWqcZwBomoTiPLLnL47IokwMuMIiTHZyYRP4ECkrHSclwqAc 9sRcPqw1kG6lfFOk2jHTq1odLyV8hXwzwbN/uchDOHaKkv5Hax08cSmZUzXIFUvsGAOq u2NXn0jeMlzxj4v+vTpoG2q4nJYlTDI6NqL6/EqUFkO8r7+MQ6COz/3glc3gyeMl2gn3 9Ndgk5jxYWGc34p92cIbIHf5Mtrau18Ysw3u/H427hF//6ihFVOp4nlc0kVd2qexrmUI j8Yl35qo4VOIurI+FG9XcDqr0IfCJU7WeP1Rq6fZKFuzJHWvWW5BskQWVhe2qW+V8Zaj TQSQ== X-Gm-Message-State: AOJu0YzN6h6NrCSw0+5zM+Gdxum1g1an6PXUhMQ7/5YwtZpT9Xd8jYnT 2NUP+TNBdr9tAhEFbCVU0Ow8H6tI++1WZDFz12U= X-Google-Smtp-Source: AGHT+IEYYLah5wmx9ElO6ZSe88MBt3tCgqdpQOqZ/nHsMh0gPvKKYoZoR8VAuGnQlUfxZSG6iQKVrXJxCL1pM5kRoYo= X-Received: by 2002:a50:9b53:0:b0:553:b950:f9d4 with SMTP id a19-20020a509b53000000b00553b950f9d4mr6215020edj.80.1703884843987; Fri, 29 Dec 2023 13:20:43 -0800 (PST) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Fri, 29 Dec 2023 13:20:43 -0800 From: Stefan Kangas <stefankangas@HIDDEN> In-Reply-To: <87r0j491mx.fsf@HIDDEN> References: <87r0j42353.fsf@HIDDEN> <83a5ps6a5e.fsf@HIDDEN> <87r0j491mx.fsf@HIDDEN> MIME-Version: 1.0 Date: Fri, 29 Dec 2023 13:20:43 -0800 Message-ID: <CADwFkm=pz-m-OCuqSw8g=ZM2+55CiWJC_rG98ocQ5Chs8NrfUg@HIDDEN> Content-Type: text/plain; charset="UTF-8" X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Steven Allen <steven@HIDDEN> writes: > --- a/doc/lispref/functions.texi > +++ b/doc/lispref/functions.texi > @@ -2077,10 +2077,12 @@ Advising Named Functions > (@pxref{Core Advising Primitives}). > @end defun > > -@defun advice-remove symbol function > +@deffn Command advice-remove symbol function > Remove the advice @var{function} from the named function @var{symbol}. > -@var{function} can also be the @code{name} of a piece of advice. > -@end defun > +@var{function} can also be the @code{name} of a piece of advice. When ^^ Our coding standards mandates two spaces between sentences. > +called interactively, prompt for both an advised @var{function} and > +the advice to remove. > +@end deffn > --- a/etc/NEWS > +++ b/etc/NEWS > @@ -1362,6 +1362,10 @@ values. > * Lisp Changes in Emacs 30.1 > > +++ > +** 'advice-remove' is now an interactive command. > +When called interactively, 'advice-remove' now prompts for an advised > +function to the advice to remove. Doesn't this change belong under "Changes" rather than "Lisp Changes"? It shouldn't change anything from the point of view of Lisp libraries.
X-Loop: help-debbugs@HIDDEN Subject: bug#68114: [PATCH] Make 'advice-remove' interactive Resent-From: Steven Allen <steven@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Fri, 29 Dec 2023 22:45:01 +0000 Resent-Message-ID: <handler.68114.B68114.170388984918314 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 68114 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Stefan Kangas <stefankangas@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>, Stefan Monnier <monnier@HIDDEN> Cc: 68114 <at> debbugs.gnu.org Received: via spool by 68114-submit <at> debbugs.gnu.org id=B68114.170388984918314 (code B ref 68114); Fri, 29 Dec 2023 22:45:01 +0000 Received: (at 68114) by debbugs.gnu.org; 29 Dec 2023 22:44:09 +0000 Received: from localhost ([127.0.0.1]:42456 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rJLaK-0004lK-E0 for submit <at> debbugs.gnu.org; Fri, 29 Dec 2023 17:44:08 -0500 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:33055) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <steven@HIDDEN>) id 1rJLaJ-0004l7-Fq for 68114 <at> debbugs.gnu.org; Fri, 29 Dec 2023 17:44:08 -0500 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 326F15C00B5; Fri, 29 Dec 2023 17:44:02 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Fri, 29 Dec 2023 17:44:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stebalien.com; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm1; t=1703889842; x= 1703976242; bh=OL+b1kQac335pXt8TlfsvUhlI+HlLer2ltH2e/eLUVU=; b=g yhE3O5gRpEoJUReybA/LTYVZ9h7kOAsEJHge6mYeKT/ZtwAQzVF8ez2HntN0ek6T xbtcWt0iQyDJevqEr9pWgWV+ALSNobvEm/30VT3aqIjkpdEJLuAJx343AxC//z0E QvBQRhJAJcrhacMfKsX/kU87tghjxM/HaW8BV1R443vsopK622o9WKh7/TMumFsg t8vyFfUHTnmTgtukvC+k6t2lFzTNZxattKZ45wN7YQZjyEDIx4idGYOB13OJyb8U nH/KcuofhSOYEN3PEsRQf8IEuO3YL/02uPBdZd7X/OtbOvv8/S/2N3NsQu42eosZ Sbm0rbMnu8kzO3MBVHP6A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1703889842; x=1703976242; bh=OL+b1kQac335pXt8TlfsvUhlI+Hl Ler2ltH2e/eLUVU=; b=zS8EQVS1AQQFmct4/iVIckCqWxnoLTGzk9jczbnc7RTW R+TNyrf168xHH9DR6Z4Vkc79thfzKd9zs/pUislbrPs+Tn54X+W5kJz9yotG7q/o zh+bPDPplCiEgIjsxgriscDMFFd7shm3o4VjKssViZIouXtoj6RrOmURJtlTZ3RL JObUfWe1mec8+nLXSw3jlMRt2KeRnLk9PLbULmFqwpQ8JNq6RP/WivHTW/xe6Eln AQkSObdbOsfMBNVZ+gr3QM/RaiOF78wyGhlthFp1pypkMMZZxn+dyGt4LWIl0/5g XRIMQLTSainMWK56Vflm24Lw6+YhEFfm9X1vjkeLZA== X-ME-Sender: <xms:sUuPZePp587x43nz_kNMc9stQb5X7tvpbi3ezEaqyKH5TANKNnFSQQ> <xme:sUuPZc-jGjQdHQ9wZvt27xhj7ffgTrNdAF_9ftFtm-F2NMbiOSk3SBSfm5jwbKchV lbK2GVPiVrBfFwYA5c> X-ME-Received: <xmr:sUuPZVQRuJotAF6UHZq2Fb0VOR8MpN8pNw9MZrantW_jp1VYuVoUeItyeayfiFrqCCoRUTyLdamYQ2_KNAoVVyIHje436A> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdefgedgtdefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefujghffffkgggtsehmtderredttddtnecuhfhrohhmpefuthgvvhgv nhcutehllhgvnhcuoehsthgvvhgvnhesshhtvggsrghlihgvnhdrtghomheqnecuggftrf grthhtvghrnhepjedufedvieejueektddtgedugeffveejheehieeulefgfffhleffheef vefhvdegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epshhtvghvvghnsehsthgvsggrlhhivghnrdgtohhm X-ME-Proxy: <xmx:sUuPZetERFbYKwhF3LEtYGLl_O03WqJ8BeAvA3e6PnceEu8cDRiNYg> <xmx:sUuPZWc-5J_VLGcE0GVfPYLc-mbagpgzmyBnY2FPaqQ3_U3mnnZTKg> <xmx:sUuPZS24GX4XQcZXBBAQEFQHBb1EOSvNMkiqbb5KkhwM23oQHdJNLg> <xmx:skuPZXoR3BkTD5x8V73VT-wb2ClJ_LvABwgh82QnqS-uLplZc6SySA> Feedback-ID: ie8a146a7:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 29 Dec 2023 17:44:01 -0500 (EST) From: Steven Allen <steven@HIDDEN> In-Reply-To: <CADwFkm=pz-m-OCuqSw8g=ZM2+55CiWJC_rG98ocQ5Chs8NrfUg@HIDDEN> References: <87r0j42353.fsf@HIDDEN> <83a5ps6a5e.fsf@HIDDEN> <87r0j491mx.fsf@HIDDEN> <CADwFkm=pz-m-OCuqSw8g=ZM2+55CiWJC_rG98ocQ5Chs8NrfUg@HIDDEN> Date: Fri, 29 Dec 2023 14:43:59 -0800 Message-ID: <87wmswoci8.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain Fair points, fixed. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment From d4a07757aea1b5618c7ee629c89ae060a285a523 Mon Sep 17 00:00:00 2001 From: Steven Allen <steven@HIDDEN> Date: Fri, 29 Dec 2023 09:53:05 -0800 Subject: [PATCH] Make 'advice-remove' interactive `ad-advice-remove' is already interactive, but it doesn't work with new-style advice. * lisp/emacs-lisp/nadvice.el (advice-remove): Make it interactive. * doc/lispref/functions.texi (Advising Named Functions): Document that 'advice-remove' is now an interactive command. --- doc/lispref/functions.texi | 8 +++++--- etc/NEWS | 4 ++++ lisp/emacs-lisp/nadvice.el | 10 ++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi index d0c8f3e90e8..6f5c1a997e2 100644 --- a/doc/lispref/functions.texi +++ b/doc/lispref/functions.texi @@ -2077,10 +2077,12 @@ Advising Named Functions (@pxref{Core Advising Primitives}). @end defun -@defun advice-remove symbol function +@deffn Command advice-remove symbol function Remove the advice @var{function} from the named function @var{symbol}. -@var{function} can also be the @code{name} of a piece of advice. -@end defun +@var{function} can also be the @code{name} of a piece of advice. When +called interactively, prompt for both an advised @var{function} and +the advice to remove. +@end deffn @defun advice-member-p function symbol Return non-@code{nil} if the advice @var{function} is already in the named diff --git a/etc/NEWS b/etc/NEWS index c002ec33d45..553365fc7a4 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -83,6 +83,10 @@ see the variable 'url-request-extra-headers'. * Changes in Emacs 30.1 +** 'advice-remove' is now an interactive command. +When called interactively, 'advice-remove' now prompts for an advised +function to the advice to remove. + ** Emacs now supports Unicode Standard version 15.1. ** Network Security Manager diff --git a/lisp/emacs-lisp/nadvice.el b/lisp/emacs-lisp/nadvice.el index 9f2b42f5765..32e54b3dd02 100644 --- a/lisp/emacs-lisp/nadvice.el +++ b/lisp/emacs-lisp/nadvice.el @@ -539,6 +539,16 @@ advice-remove or an autoload and it preserves `fboundp'. Instead of the actual function to remove, FUNCTION can also be the `name' of the piece of advice." + (interactive + (let ((symbol (intern (completing-read + "Advised Function: " + obarray + (lambda (sym) (advice--p (advice--symbol-function sym))) + t nil nil + (when-let (def (function-called-at-point)) (symbol-name def))))) + advice) + (advice-mapc (lambda (f _) (push (cons (prin1-to-string f) f) advice)) symbol) + (list symbol (cdr (assoc-string (completing-read "Advice: " advice) advice))))) (let ((f (symbol-function symbol))) (remove-function (cond ;This is `advice--symbol-function' but as a "place". ((get symbol 'advice--pending) -- 2.43.0 --=-=-=--
X-Loop: help-debbugs@HIDDEN Subject: bug#68114: [PATCH] Make 'advice-remove' interactive Resent-From: Stefan Monnier <monnier@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Sat, 30 Dec 2023 05:07:01 +0000 Resent-Message-ID: <handler.68114.B68114.170391280225740 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 68114 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Steven Allen <steven@HIDDEN> Cc: Eli Zaretskii <eliz@HIDDEN>, 68114 <at> debbugs.gnu.org Received: via spool by 68114-submit <at> debbugs.gnu.org id=B68114.170391280225740 (code B ref 68114); Sat, 30 Dec 2023 05:07:01 +0000 Received: (at 68114) by debbugs.gnu.org; 30 Dec 2023 05:06:42 +0000 Received: from localhost ([127.0.0.1]:42808 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rJRYY-0006h5-9e for submit <at> debbugs.gnu.org; Sat, 30 Dec 2023 00:06:42 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:32542) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <monnier@HIDDEN>) id 1rJRYV-0006gr-SY for 68114 <at> debbugs.gnu.org; Sat, 30 Dec 2023 00:06:40 -0500 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id BEA854402A5; Sat, 30 Dec 2023 00:06:33 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1703912792; bh=AJH4+Bi+rjrzDu/GWwkoa3Z6D4mO/OyZ8abUhdpftrc=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=ZOY/ET/x4vB7d31+FGRBNqq6rX+0IEO7o/C7cKCTBtyhP/DnmK2DOFxL6vibUj1Nn 1bKvMXkCNEnwSTnenp//wSwZWmgjFFqWhflJWfihaK3nVfQV33pVqskyxfQKw/M3ZN vUZpc7TyRo7m4v99HRLHhQJoVX9JW4hOUnY1oCOZyA19anTwxrzgF0pBBVYKnBM8Od 29ulRlkb2vF3N/WC9tUhTQHJo3TQXZM07CvK128ZCkASkkZcKTvkvOtIzte0Khr2eE 8I4qWRGlnj4Nhn4TFV5AZH1Dd03Spy1CvEAGevvnplCzquPGRUhXRvK59fUUMF9blF nyYOGylZMZp6w== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 5D30144014C; Sat, 30 Dec 2023 00:06:32 -0500 (EST) Received: from pastel (65-110-221-238.cpe.pppoe.ca [65.110.221.238]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 344611211D5; Sat, 30 Dec 2023 00:06:32 -0500 (EST) From: Stefan Monnier <monnier@HIDDEN> In-Reply-To: <87r0j491mx.fsf@HIDDEN> (Steven Allen's message of "Fri, 29 Dec 2023 12:47:50 -0800") Message-ID: <jwv7ckwcmnv.fsf-monnier+emacs@HIDDEN> References: <87r0j42353.fsf@HIDDEN> <83a5ps6a5e.fsf@HIDDEN> <87r0j491mx.fsf@HIDDEN> Date: Sat, 30 Dec 2023 00:06:31 -0500 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.213 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > --- a/lisp/emacs-lisp/nadvice.el > +++ b/lisp/emacs-lisp/nadvice.el > @@ -539,6 +539,16 @@ advice-remove > or an autoload and it preserves `fboundp'. > Instead of the actual function to remove, FUNCTION can also be the `name' > of the piece of advice." > + (interactive > + (let ((symbol (intern (completing-read > + "Advised Function: " > + obarray > + (lambda (sym) (advice--p (advice--symbol-function sym))) > + t nil nil > + (when-let (def (function-called-at-point)) (symbol-name def))))) > + advice) You should include the default in the prompt using `format-prompt`. > + (advice-mapc (lambda (f _) (push (cons (prin1-to-string f) f) advice)) symbol) The var name `advice` suggests it holds a single piece of advice. I'd call it `advices` instead. Also, some advice's functions are lambda expressions (i.e. closures) which can be rather ugly/unwieldy when printed. When code expects to remove them, we usually provide a `name` property for them, so I suggest that you use something like (lambda (f p) (let ((k (or (alist-get 'name p) f))) (push (cons (prin1-to-string k) k) advices))) > + (list symbol (cdr (assoc-string (completing-read "Advice: " advice) advice))))) I suspect you want to `require-match` in the `completing-read` call. Stefan
X-Loop: help-debbugs@HIDDEN Subject: bug#68114: [PATCH] Make 'advice-remove' interactive Resent-From: Eli Zaretskii <eliz@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Sat, 30 Dec 2023 06:46:02 +0000 Resent-Message-ID: <handler.68114.B68114.17039187313834 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 68114 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Steven Allen <steven@HIDDEN> Cc: monnier@HIDDEN, 68114 <at> debbugs.gnu.org Received: via spool by 68114-submit <at> debbugs.gnu.org id=B68114.17039187313834 (code B ref 68114); Sat, 30 Dec 2023 06:46:02 +0000 Received: (at 68114) by debbugs.gnu.org; 30 Dec 2023 06:45:31 +0000 Received: from localhost ([127.0.0.1]:42892 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rJT6A-0000zB-9d for submit <at> debbugs.gnu.org; Sat, 30 Dec 2023 01:45:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60354) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1rJT68-0000lG-1w for 68114 <at> debbugs.gnu.org; Sat, 30 Dec 2023 01:45:28 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1rJT62-0008Sm-9m; Sat, 30 Dec 2023 01:45:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=eXnLyI0rA+UinV+/nR6NvIad36u41Oaa5guAQt6nAik=; b=cWbBxjh/FFne sVfd20A41A4ZHvfVz4zCKubf6OXQO791xIRGzZNkGCMIRhFEuiwoCYj1S6L6RDWonrg4OMmeTKo28 C4nQSrQ0RIuAAiTXa9H5LWsTT+IWkafOaHP21DNZYnHLfIQ8BCMN7ITp5ah/h4ZjsHfa56Trm0NYU UeYtX5xTBHNYDKnNAI/VPbgtf8aoapFCf4lZdWi9tVf0RfrUNDTw+aqblIZjrH46tWb4cpp8XJOs8 t2bqDqEm6mQj+5Q/WDrt9rX+Ajhm/VZzVDo4ZnrBaZGyzswS7T0HD7s9uedy07AiJ88YNqyfDR2RR MaMh6SJ8tYfUmGw7/PWPtw==; Date: Sat, 30 Dec 2023 08:45:11 +0200 Message-Id: <837ckw5gug.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> In-Reply-To: <87r0j491mx.fsf@HIDDEN> (message from Steven Allen on Fri, 29 Dec 2023 12:47:50 -0800) References: <87r0j42353.fsf@HIDDEN> <83a5ps6a5e.fsf@HIDDEN> <87r0j491mx.fsf@HIDDEN> X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > From: Steven Allen <steven@HIDDEN> > Cc: 68114 <at> debbugs.gnu.org > Date: Fri, 29 Dec 2023 12:47:50 -0800 > > Thanks for the quick feedback. I've attached an updated patch with a > NEWS and update and some documentation. Let me know if there's a better > place to document this of if I made a mistake somewhere. Thanks, a few minor comments while we wait for Stefan to chime in. > `ad-advice-remove' is already interactive, but it doesn't work with > new-style advice. > > * lisp/emacs-lisp/nadvice.el (advice-remove): Make it interactive. > * doc/lispref/functions.texi (Advising Named Functions): Document that > 'advice-remove' is now an interactive command. Please mention the bug number, since it is now known, in the log message. > -@defun advice-remove symbol function > +@deffn Command advice-remove symbol function > Remove the advice @var{function} from the named function @var{symbol}. > -@var{function} can also be the @code{name} of a piece of advice. > -@end defun > +@var{function} can also be the @code{name} of a piece of advice. When ^^ Two spaces between sentences, please. Btw, what is "the 'name' of a piece of advice"? I realize that this text was there to begin with, but I don't think I understand what it wants to tell me, so maybe we could clarify that. The only reference to a "name" in the preceding text uses "name" to mean a symbol, but then what is "the name of a piece of advice"? I guess this goes back to define-advice, which says: @defmac define-advice symbol (where lambda-list &optional name depth) &rest body This macro defines a piece of advice and adds it to the function named @var{symbol}. The advice is an anonymous function if @var{name} is @code{nil} or a function named @code{symbol@@name}. See @code{advice-add} for explanation of other arguments. which is also a bit mysterious. Does NAME used here serve as "the name of the piece of advice"? if so, should "@code{symbol@@name}" be "@code{symbol@@@var{name}}" instead, i.e. "name" is not a literal string but the reference to NAME? > --- a/lisp/emacs-lisp/nadvice.el > +++ b/lisp/emacs-lisp/nadvice.el > @@ -539,6 +539,16 @@ advice-remove > or an autoload and it preserves `fboundp'. > Instead of the actual function to remove, FUNCTION can also be the `name' > of the piece of advice." > + (interactive > + (let ((symbol (intern (completing-read > + "Advised Function: " I wonder whether "Remove advice from function: " would be a better prompt. > + obarray > + (lambda (sym) (advice--p (advice--symbol-function sym))) > + t nil nil > + (when-let (def (function-called-at-point)) (symbol-name def))))) > + advice) > + (advice-mapc (lambda (f _) (push (cons (prin1-to-string f) f) advice)) symbol) > + (list symbol (cdr (assoc-string (completing-read "Advice: " advice) advice))))) And here I wonder whether "Advice to remove: " would be a better prompt.
X-Loop: help-debbugs@HIDDEN Subject: bug#68114: [PATCH] Make 'advice-remove' interactive Resent-From: Steven Allen <steven@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Sat, 30 Dec 2023 16:23:02 +0000 Resent-Message-ID: <handler.68114.B68114.170395333829381 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 68114 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Stefan Monnier <monnier@HIDDEN> Cc: Eli Zaretskii <eliz@HIDDEN>, 68114 <at> debbugs.gnu.org Received: via spool by 68114-submit <at> debbugs.gnu.org id=B68114.170395333829381 (code B ref 68114); Sat, 30 Dec 2023 16:23:02 +0000 Received: (at 68114) by debbugs.gnu.org; 30 Dec 2023 16:22:18 +0000 Received: from localhost ([127.0.0.1]:44918 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rJc6L-0007dp-OC for submit <at> debbugs.gnu.org; Sat, 30 Dec 2023 11:22:18 -0500 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]:53815) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <steven@HIDDEN>) id 1rJc6I-0007db-R8 for 68114 <at> debbugs.gnu.org; Sat, 30 Dec 2023 11:22:16 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 00CF232004AE; Sat, 30 Dec 2023 11:22:07 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Sat, 30 Dec 2023 11:22:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stebalien.com; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm1; t=1703953327; x= 1704039727; bh=2PI0HRtaRk5R5+ywNO46h1/LuuajwBAvyBFraOdYUMs=; b=I octfKF5UJZmCzFVUiSxPmBvLuoEo96x5M0o5wt6AD38ktcd9c3fbGrhsTDyz7NVN WDCC53b8myHEFYRW7RW+i12KyFWUfnIcMEwzEG3H2JB0CRwNr/r/mmtGVBlGvgb1 WbbzXDGRy25/BFWOlscrWSI5ecNoR17nhAB52Xm2T+Pcu9lvrAGtmFTn7ZwUdMOA 9iXsxEDXUjzcuEy41M73HKfDTtJnLgfHTqPgp9u1uswTL+Zo8nvSAqh0umUbc9M8 RvEnf9wD9cj4v81HNevjWXCFoq2yng6HLnBjcoSkddSVIUcCpkgttiIC/xfhEjeL V5VuJCvTfFQndtM2sTlhQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1703953327; x=1704039727; bh=2PI0HRtaRk5R5+ywNO46h1/Luuaj wBAvyBFraOdYUMs=; b=3UhIlQ47oHZxReVgH5gBcE09cCkpHEWfSxuusvXovHYI KPZjlpMCTvecRBJcqaVvKa/mo+uIKgqKLway/ystMuY4HVbf29JtpmbJAcPi9a/9 ltXd1MfDlHaD7+rXpuv6iBLZZA2B5BFKIX8l3tn0OW0s4oZZ5KvBWUZ5YzclpKy4 ji8chILC2XIC/h7Ns+/Zh+WXthtILn5pnR64uiheC4K05mBVEMGThngt51XkfGbo vVJXs8z42mynSL1igK3KrO6zfb4xCLzscDUbVhZuHFycg25Lds85Ek9hOM9E33J/ j6+GhdP0US5n1KBSl027pzAH/U/0hC+ZhaHbeWwPqQ== X-ME-Sender: <xms:r0OQZbQdH8AnacOhcYnRGCixdrASymMlSeCXUjNlSG_yQdR49MdM0w> <xme:r0OQZcx51YOJPsmjnqSw87Cc8-HufsQc41UQ7YR_G2a2eJbkq6MYipPDcbBKz3_Kc T0yF0FH_tysv56EGK4> X-ME-Received: <xmr:r0OQZQ18whTGQjcQDHkDdGkVryEaAHM-LWt75ZWekmov7VFCVhPd5Mv6Fgnk8fUDvJjzT-HhDBMxk42IlMuY-ByaXctoUQ> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdefhedgkeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefujghffffkgggtsehmtderredttddtnecuhfhrohhmpefuthgvvhgv nhcutehllhgvnhcuoehsthgvvhgvnhesshhtvggsrghlihgvnhdrtghomheqnecuggftrf grthhtvghrnhepjedufedvieejueektddtgedugeffveejheehieeulefgfffhleffheef vefhvdegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epshhtvghvvghnsehsthgvsggrlhhivghnrdgtohhm X-ME-Proxy: <xmx:r0OQZbDrIXm9Y52RtmeYNzxWcvVrGABv8RMdBF9LhkaZ4JCzIKrAkA> <xmx:r0OQZUg-tS8NCVqYbAN_EoZA7yQiZh0xNhNnR19CpNpLAfT57nLd4g> <xmx:r0OQZfrQZoF0Eu87DS2dfbVHN28g9IqYsJ4dQf5F8lBLU1NnO04DNg> <xmx:r0OQZQa9iCqgU8y_rjkzTohXWUosIFriUUqOUEQTysyZ9DPO8T7-Eg> Feedback-ID: ie8a146a7:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 30 Dec 2023 11:22:06 -0500 (EST) From: Steven Allen <steven@HIDDEN> In-Reply-To: <jwv7ckwcmnv.fsf-monnier+emacs@HIDDEN> References: <87r0j42353.fsf@HIDDEN> <83a5ps6a5e.fsf@HIDDEN> <87r0j491mx.fsf@HIDDEN> <jwv7ckwcmnv.fsf-monnier+emacs@HIDDEN> Date: Sat, 30 Dec 2023 08:22:04 -0800 Message-ID: <87ttnzhd8z.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain > You should include the default in the prompt using `format-prompt`. > >> + (advice-mapc (lambda (f _) (push (cons (prin1-to-string f) f) advice)) symbol) Fixed. I also: - Broke the large `completing-read` call into multiple let bindings. - Made sure that the default value was actually advised before suggesting it. > The var name `advice` suggests it holds a single piece of advice. > I'd call it `advices` instead. Fixed > Also, some advice's functions are lambda expressions (i.e. closures) > which can be rather ugly/unwieldy when printed. When code expects to > remove them, we usually provide a `name` property for them, so I suggest > that you use something like Fixed, although I noticed a few oddities (commented in the code to avoid confusing future readers). Basically 1. 'name' can be either a string or a symbol, but they're not considered the same name. 2. The same advice can be applied multiple times with different names, so I changed the code to select the advice's 'name' instead of the advice itself, if named. > I suspect you want to `require-match` in the `completing-read` call. Fixed. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment From 130adbe7542304b2fa5dd23c23d66c275cd5bcb1 Mon Sep 17 00:00:00 2001 From: Steven Allen <steven@HIDDEN> Date: Fri, 29 Dec 2023 09:53:05 -0800 Subject: [PATCH] Make 'advice-remove' interactive `ad-advice-remove' is already interactive, but it doesn't work with new-style advice. * lisp/emacs-lisp/nadvice.el (advice-remove): Make it interactive. * doc/lispref/functions.texi (Advising Named Functions): Document that 'advice-remove' is now an interactive command. --- doc/lispref/functions.texi | 8 +++++--- etc/NEWS | 4 ++++ lisp/emacs-lisp/nadvice.el | 24 ++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi index d0c8f3e90e8..6f5c1a997e2 100644 --- a/doc/lispref/functions.texi +++ b/doc/lispref/functions.texi @@ -2077,10 +2077,12 @@ Advising Named Functions (@pxref{Core Advising Primitives}). @end defun -@defun advice-remove symbol function +@deffn Command advice-remove symbol function Remove the advice @var{function} from the named function @var{symbol}. -@var{function} can also be the @code{name} of a piece of advice. -@end defun +@var{function} can also be the @code{name} of a piece of advice. When +called interactively, prompt for both an advised @var{function} and +the advice to remove. +@end deffn @defun advice-member-p function symbol Return non-@code{nil} if the advice @var{function} is already in the named diff --git a/etc/NEWS b/etc/NEWS index c002ec33d45..553365fc7a4 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -83,6 +83,10 @@ see the variable 'url-request-extra-headers'. * Changes in Emacs 30.1 +** 'advice-remove' is now an interactive command. +When called interactively, 'advice-remove' now prompts for an advised +function to the advice to remove. + ** Emacs now supports Unicode Standard version 15.1. ** Network Security Manager diff --git a/lisp/emacs-lisp/nadvice.el b/lisp/emacs-lisp/nadvice.el index 9f2b42f5765..f2fa5f34ef8 100644 --- a/lisp/emacs-lisp/nadvice.el +++ b/lisp/emacs-lisp/nadvice.el @@ -539,6 +539,30 @@ advice-remove or an autoload and it preserves `fboundp'. Instead of the actual function to remove, FUNCTION can also be the `name' of the piece of advice." + (interactive + (let* ((pred (lambda (sym) (advice--p (advice--symbol-function sym)))) + (default (when-let* ((f (function-called-at-point)) + ((funcall pred f))) + (symbol-name f))) + (prompt (format-prompt "Advised Function" default)) + (symbol (intern (completing-read prompt obarray pred t nil nil default))) + advices) + (advice-mapc (lambda (f p) + (let ((k (or (alist-get 'name p) f))) + (push (cons + ;; "name" (string) and 'name (symbol) are + ;; considered different names so we use + ;; `prin1-to-string' even if the name is + ;; a string to distinguish between these + ;; two cases. + (prin1-to-string k) + ;; We use `k' here instead of `f' because + ;; the same advice can have multiple + ;; names. + k) + advices))) + symbol) + (list symbol (cdr (assoc-string (completing-read "Advice: " advices nil t) advices))))) (let ((f (symbol-function symbol))) (remove-function (cond ;This is `advice--symbol-function' but as a "place". ((get symbol 'advice--pending) -- 2.43.0 --=-=-=--
X-Loop: help-debbugs@HIDDEN Subject: bug#68114: [PATCH] Make 'advice-remove' interactive Resent-From: Steven Allen <steven@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Fri, 05 Jan 2024 21:44:02 +0000 Resent-Message-ID: <handler.68114.B68114.170449104017784 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 68114 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Eli Zaretskii <eliz@HIDDEN> Received: via spool by 68114-submit <at> debbugs.gnu.org id=B68114.170449104017784 (code B ref 68114); Fri, 05 Jan 2024 21:44:02 +0000 Received: (at 68114) by debbugs.gnu.org; 5 Jan 2024 21:44:00 +0000 Received: from localhost ([127.0.0.1]:58080 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rLryy-0004ck-53 for submit <at> debbugs.gnu.org; Fri, 05 Jan 2024 16:44:00 -0500 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]:48787) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <steven@HIDDEN>) id 1rLryt-0004cU-SJ for 68114 <at> debbugs.gnu.org; Fri, 05 Jan 2024 16:43:59 -0500 Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailout.west.internal (Postfix) with ESMTP id BBC3F3200AD7 for <68114 <at> debbugs.gnu.org>; Fri, 5 Jan 2024 16:43:44 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Fri, 05 Jan 2024 16:43:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stebalien.com; h=cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to :resent-date:resent-from:resent-message-id:resent-to:subject :subject:to:to; s=fm1; t=1704491024; x=1704577424; bh=au0JhpIJiq 8DNIgDnjH75Ha1dLjKlk/tCEXA5F94Zzw=; b=e7TcGHT8XxRbzNX8i1LsHQWqaa lCvgMM5aGjwjyQNWC4mb/59ujvHLsGiQsYof/KeQvVyAlmNtZ0u7sPzthe8tduI1 lh41R0qIYVBUblTmRuhJ+Mu6iukAVR7ln2Vmx4kiD9JlLvfTS6vIin+l6Mkj/0zv zdwNATi7j/GAbY+X1ua1KSK5BrIgEvS0OjTYvBMnHWi+xaCIRFd6fOyHKf1b78N0 O1CgXVe6GinI9yx4IAgA0iGY4800oouwwNhOmcuU8w6MdVlvoNHFkA6M2PYaVaUb 4wknyhNuScHwawHtwKdGugPPLVsac+SgXDFnLPf5vqgewccfhHZ3AJuwzQ4w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:resent-date :resent-from:resent-message-id:resent-to:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1704491024; x=1704577424; bh=au0JhpIJiq8DNIgDnjH75Ha1dLjK lk/tCEXA5F94Zzw=; b=BQiO8gnqijDRw6rh1R3PDsJRmRk2H/LAki2QPzwAjwwR 19iHjTIS/rmaKU9eO4gqbd1CpkHTRYxflcWjjwCAp0RKEX6DymicwJgQqdmG4jML uI65yukaZ8EKzhpnVh11gvXxe0NVUS4f/fQXgrs5PR0W9U095WZHw7FSSgRsc38Q fMXOH/rCajd7pWG7V2WrnTR6KSdT1kB9QkvjuSJreLFkCRT/Sp4WJ2HkUGKWVMn0 TmkGlJjpIo2l8c3tMDMYUVsORZMoPaKKvfLKCO/R9hR8UqvwA6nTo+oxw0rVhgBD dJ1yuR3l6qOnAIXuB/fhwaF8yY5EM3kc90Lwses6xA== X-ME-Sender: <xms:D3iYZRolX3YGBHsqSVCfXOyfRl6WJ5QWrs6lCGDGHgMToFR_ryasHw> <xme:D3iYZTpExul-R7rbXl7NLiR1i-9QL1WpytM5Sg0hvEH9dlHHjXeusdABwOO7Fm1kK BZuXNwNBKwrLcvIdzw> X-ME-Received: <xmr:D3iYZeOAj9PEUCjZmkdF3KyapME229qhpa6Cr0-GeXGNiPNTeFgyY52H-1p9ifef4dW8tcaa2kUf8jS7wOYPCbYvO6QROA> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdegledgudeglecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffujghffffkgggtsehmtderredttddtnecuhfhrohhmpefuthgvvhgv nhcutehllhgvnhcuoehsthgvvhgvnhesshhtvggsrghlihgvnhdrtghomheqnecuggftrf grthhtvghrnhepudffgffhfeehgedtffeuudejkeduleekieeufeegvefhueffhfehhfef vedvjefgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epshhtvghvvghnsehsthgvsggrlhhivghnrdgtohhm X-ME-Proxy: <xmx:D3iYZc4-DfJCsJ3-oUPLBF6Z3AHNi-DnNMAs0kinXSc6jTJTMpeptw> <xmx:D3iYZQ6WPLyRFGjfGMEAwHGBV6X5iLD0v2lfx42EzGKbW6ic_uyhWA> <xmx:D3iYZUgUa44jhN94p1sfkQiSOfR81nRWmmySsygXC7vmNqZ71MB0Og> <xmx:EHiYZVUEFZn0cdwIj_oOEQfrFssUy3pGkHY3s-fwvyYeiXFQXLG2Mg> Feedback-ID: ie8a146a7:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for <68114 <at> debbugs.gnu.org>; Fri, 5 Jan 2024 16:43:43 -0500 (EST) Resent-To: 68114 <at> debbugs.gnu.org Resent-From: Steven Allen <steven@HIDDEN> Resent-Date: Fri, 05 Jan 2024 13:43:42 -0800 Resent-Message-ID: <87wmsn8nht.fsf@HIDDEN> From: Steven Allen <steven@HIDDEN> In-Reply-To: <837ckw5gug.fsf@HIDDEN> References: <87r0j42353.fsf@HIDDEN> <83a5ps6a5e.fsf@HIDDEN> <87r0j491mx.fsf@HIDDEN> <837ckw5gug.fsf@HIDDEN> Date: Sat, 30 Dec 2023 08:37:48 -0800 Message-ID: <87r0j3hcir.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain Ah, I responded to the previous message before seeing this one. > Please mention the bug number, since it is now known, in the log > message. Done. > Two spaces between sentences, please. Fixed in the first revision (d4a07757). > Btw, what is "the 'name' of a piece of advice"? I realize that this > text was there to begin with, but I don't think I understand what it > wants to tell me, so maybe we could clarify that. The only reference > to a "name" in the preceding text uses "name" to mean a symbol, but > then what is "the name of a piece of advice"? I guess this goes back > to define-advice, which says: > > @defmac define-advice symbol (where lambda-list &optional name depth) &rest body > This macro defines a piece of advice and adds it to the function named > @var{symbol}. The advice is an anonymous function if @var{name} is > @code{nil} or a function named @code{symbol@@name}. See > @code{advice-add} for explanation of other arguments. > > which is also a bit mysterious. Does NAME used here serve as "the > name of the piece of advice"? if so, should "@code{symbol@@name}" be > "@code{symbol@@@var{name}}" instead, i.e. "name" is not a literal > string but the reference to NAME? So, those two names are actually different. The 'name' in referenced in the `advice-remove` documentation is the 'name in the advice's 'props' alist. The 'name' specified in `define-advice` is _not_ added to this alist and is only used in the advice's function name. I'm happy to resolve this in a separate patch, if that's OK with you. Something like (`define-advice` documentation): Note if NAME is nil the advice is anonymous; otherwise the advice function is named `SYMBOL@NAME' and the advice is named NAME. Then actually add NAME to the properties. > I wonder whether "Remove advice from function: " would be a better > prompt. Good point, done! > And here I wonder whether "Advice to remove: " would be a better > prompt. Also done. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment From c9dbd06fd6484227e46361e39c29798750d2470e Mon Sep 17 00:00:00 2001 From: Steven Allen <steven@HIDDEN> Date: Fri, 29 Dec 2023 09:53:05 -0800 Subject: [PATCH] Make 'advice-remove' interactive `ad-advice-remove' is already interactive, but it doesn't work with new-style advice. * lisp/emacs-lisp/nadvice.el (advice-remove): Make it interactive (Bug#67926). * doc/lispref/functions.texi (Advising Named Functions): Document that 'advice-remove' is now an interactive command. --- doc/lispref/functions.texi | 8 +++++--- etc/NEWS | 4 ++++ lisp/emacs-lisp/nadvice.el | 26 ++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi index d0c8f3e90e8..6f5c1a997e2 100644 --- a/doc/lispref/functions.texi +++ b/doc/lispref/functions.texi @@ -2077,10 +2077,12 @@ Advising Named Functions (@pxref{Core Advising Primitives}). @end defun -@defun advice-remove symbol function +@deffn Command advice-remove symbol function Remove the advice @var{function} from the named function @var{symbol}. -@var{function} can also be the @code{name} of a piece of advice. -@end defun +@var{function} can also be the @code{name} of a piece of advice. When +called interactively, prompt for both an advised @var{function} and +the advice to remove. +@end deffn @defun advice-member-p function symbol Return non-@code{nil} if the advice @var{function} is already in the named diff --git a/etc/NEWS b/etc/NEWS index c002ec33d45..553365fc7a4 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -83,6 +83,10 @@ see the variable 'url-request-extra-headers'. * Changes in Emacs 30.1 +** 'advice-remove' is now an interactive command. +When called interactively, 'advice-remove' now prompts for an advised +function to the advice to remove. + ** Emacs now supports Unicode Standard version 15.1. ** Network Security Manager diff --git a/lisp/emacs-lisp/nadvice.el b/lisp/emacs-lisp/nadvice.el index 9f2b42f5765..b1d314c0796 100644 --- a/lisp/emacs-lisp/nadvice.el +++ b/lisp/emacs-lisp/nadvice.el @@ -539,6 +539,32 @@ advice-remove or an autoload and it preserves `fboundp'. Instead of the actual function to remove, FUNCTION can also be the `name' of the piece of advice." + (interactive + (let* ((pred (lambda (sym) (advice--p (advice--symbol-function sym)))) + (default (when-let* ((f (function-called-at-point)) + ((funcall pred f))) + (symbol-name f))) + (prompt (format-prompt "Remove advice from function" default)) + (symbol (intern (completing-read prompt obarray pred t nil nil default))) + advices) + (advice-mapc (lambda (f p) + (let ((k (or (alist-get 'name p) f))) + (push (cons + ;; "name" (string) and 'name (symbol) are + ;; considered different names so we use + ;; `prin1-to-string' even if the name is + ;; a string to distinguish between these + ;; two cases. + (prin1-to-string k) + ;; We use `k' here instead of `f' because + ;; the same advice can have multiple + ;; names. + k) + advices))) + symbol) + (list symbol (cdr (assoc-string + (completing-read "Advice to remove: " advices nil t) + advices))))) (let ((f (symbol-function symbol))) (remove-function (cond ;This is `advice--symbol-function' but as a "place". ((get symbol 'advice--pending) -- 2.43.0 --=-=-=--
X-Loop: help-debbugs@HIDDEN Subject: bug#68114: [PATCH] Make 'advice-remove' interactive Resent-From: Eli Zaretskii <eliz@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Sat, 06 Jan 2024 09:04:02 +0000 Resent-Message-ID: <handler.68114.B68114.170453179727542 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 68114 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Steven Allen <steven@HIDDEN> Cc: Stefan Monnier <monnier@HIDDEN>, 68114 <at> debbugs.gnu.org Received: via spool by 68114-submit <at> debbugs.gnu.org id=B68114.170453179727542 (code B ref 68114); Sat, 06 Jan 2024 09:04:02 +0000 Received: (at 68114) by debbugs.gnu.org; 6 Jan 2024 09:03:17 +0000 Received: from localhost ([127.0.0.1]:58539 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rM2aK-0007A9-VV for submit <at> debbugs.gnu.org; Sat, 06 Jan 2024 04:03:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51838) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1rM2aI-00079r-BP for 68114 <at> debbugs.gnu.org; Sat, 06 Jan 2024 04:03:15 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1rM2a8-0005oP-3p; Sat, 06 Jan 2024 04:03:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=Rbzy9KwIo7YWS7RWVeAlEoSbLNaM5Y/50j9Wcp+uCr4=; b=Meo5trHUiVIr 27R8seTU9dMVfBZk1x2OI/WJHJuVdpuamQFZhmnMoh7t5l2gz/Ug6PH5OpstEFZrvnSSxsziX3sGC Bo69C4fXEl+CLIezP/rhxCQvKWkVoAUvqOh6Kt0/YUUiGv5UWNKIwC2SaHsq3/DjqXRP/yVHJQWOB T6VbXNrrlKMubSlicHiZgquDKc05LyUF6Oj5eVty2YJDSua85iYBFws9LcdVV85jUkV42K3UNzrcN GhrVzBH+MORhvQqi8AvXI5BAXITCbXvo6G0esyHfjBvrvrcu9oEP5hEUtQd0G+CbRgDiBctK5mTt6 V5WP1XrhVbtcagv9MSdPvg==; Date: Sat, 06 Jan 2024 11:02:53 +0200 Message-Id: <83le92u94y.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> In-Reply-To: <87r0j3hcir.fsf@HIDDEN> (message from Steven Allen on Sat, 30 Dec 2023 08:37:48 -0800) References: <87r0j42353.fsf@HIDDEN> <83a5ps6a5e.fsf@HIDDEN> <87r0j491mx.fsf@HIDDEN> <837ckw5gug.fsf@HIDDEN> <87r0j3hcir.fsf@HIDDEN> X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > From: Steven Allen <steven@HIDDEN> > Date: Sat, 30 Dec 2023 08:37:48 -0800 > > Ah, I responded to the previous message before seeing this one. > > > Please mention the bug number, since it is now known, in the log > > message. > > Done. > > > Two spaces between sentences, please. > > Fixed in the first revision (d4a07757). > > > Btw, what is "the 'name' of a piece of advice"? I realize that this > > text was there to begin with, but I don't think I understand what it > > wants to tell me, so maybe we could clarify that. The only reference > > to a "name" in the preceding text uses "name" to mean a symbol, but > > then what is "the name of a piece of advice"? I guess this goes back > > to define-advice, which says: > > > > @defmac define-advice symbol (where lambda-list &optional name depth) &rest body > > This macro defines a piece of advice and adds it to the function named > > @var{symbol}. The advice is an anonymous function if @var{name} is > > @code{nil} or a function named @code{symbol@@name}. See > > @code{advice-add} for explanation of other arguments. > > > > which is also a bit mysterious. Does NAME used here serve as "the > > name of the piece of advice"? if so, should "@code{symbol@@name}" be > > "@code{symbol@@@var{name}}" instead, i.e. "name" is not a literal > > string but the reference to NAME? > > So, those two names are actually different. The 'name' in referenced in > the `advice-remove` documentation is the 'name in the advice's 'props' > alist. The 'name' specified in `define-advice` is _not_ added to this > alist and is only used in the advice's function name. > > I'm happy to resolve this in a separate patch, if that's OK with you. > Something like (`define-advice` documentation): > > Note if NAME is nil the advice is anonymous; otherwise the advice > function is named `SYMBOL@NAME' and the advice is named NAME. > > Then actually add NAME to the properties. > > > I wonder whether "Remove advice from function: " would be a better > > prompt. > > Good point, done! > > > And here I wonder whether "Advice to remove: " would be a better > > prompt. > > Also done. Stefan, any comments to the patch below? > >From c9dbd06fd6484227e46361e39c29798750d2470e Mon Sep 17 00:00:00 2001 > From: Steven Allen <steven@HIDDEN> > Date: Fri, 29 Dec 2023 09:53:05 -0800 > Subject: [PATCH] Make 'advice-remove' interactive > > `ad-advice-remove' is already interactive, but it doesn't work with > new-style advice. > > * lisp/emacs-lisp/nadvice.el (advice-remove): Make it > interactive (Bug#67926). > > * doc/lispref/functions.texi (Advising Named Functions): Document that > 'advice-remove' is now an interactive command. > --- > doc/lispref/functions.texi | 8 +++++--- > etc/NEWS | 4 ++++ > lisp/emacs-lisp/nadvice.el | 26 ++++++++++++++++++++++++++ > 3 files changed, 35 insertions(+), 3 deletions(-) > > diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi > index d0c8f3e90e8..6f5c1a997e2 100644 > --- a/doc/lispref/functions.texi > +++ b/doc/lispref/functions.texi > @@ -2077,10 +2077,12 @@ Advising Named Functions > (@pxref{Core Advising Primitives}). > @end defun > > -@defun advice-remove symbol function > +@deffn Command advice-remove symbol function > Remove the advice @var{function} from the named function @var{symbol}. > -@var{function} can also be the @code{name} of a piece of advice. > -@end defun > +@var{function} can also be the @code{name} of a piece of advice. When > +called interactively, prompt for both an advised @var{function} and > +the advice to remove. > +@end deffn > > @defun advice-member-p function symbol > Return non-@code{nil} if the advice @var{function} is already in the named > diff --git a/etc/NEWS b/etc/NEWS > index c002ec33d45..553365fc7a4 100644 > --- a/etc/NEWS > +++ b/etc/NEWS > @@ -83,6 +83,10 @@ see the variable 'url-request-extra-headers'. > > * Changes in Emacs 30.1 > > +** 'advice-remove' is now an interactive command. > +When called interactively, 'advice-remove' now prompts for an advised > +function to the advice to remove. > + > ** Emacs now supports Unicode Standard version 15.1. > > ** Network Security Manager > diff --git a/lisp/emacs-lisp/nadvice.el b/lisp/emacs-lisp/nadvice.el > index 9f2b42f5765..b1d314c0796 100644 > --- a/lisp/emacs-lisp/nadvice.el > +++ b/lisp/emacs-lisp/nadvice.el > @@ -539,6 +539,32 @@ advice-remove > or an autoload and it preserves `fboundp'. > Instead of the actual function to remove, FUNCTION can also be the `name' > of the piece of advice." > + (interactive > + (let* ((pred (lambda (sym) (advice--p (advice--symbol-function sym)))) > + (default (when-let* ((f (function-called-at-point)) > + ((funcall pred f))) > + (symbol-name f))) > + (prompt (format-prompt "Remove advice from function" default)) > + (symbol (intern (completing-read prompt obarray pred t nil nil default))) > + advices) > + (advice-mapc (lambda (f p) > + (let ((k (or (alist-get 'name p) f))) > + (push (cons > + ;; "name" (string) and 'name (symbol) are > + ;; considered different names so we use > + ;; `prin1-to-string' even if the name is > + ;; a string to distinguish between these > + ;; two cases. > + (prin1-to-string k) > + ;; We use `k' here instead of `f' because > + ;; the same advice can have multiple > + ;; names. > + k) > + advices))) > + symbol) > + (list symbol (cdr (assoc-string > + (completing-read "Advice to remove: " advices nil t) > + advices))))) > (let ((f (symbol-function symbol))) > (remove-function (cond ;This is `advice--symbol-function' but as a "place". > ((get symbol 'advice--pending) > -- > 2.43.0 >
X-Loop: help-debbugs@HIDDEN Subject: bug#68114: [PATCH] Make 'advice-remove' interactive Resent-From: Eli Zaretskii <eliz@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Sat, 06 Jan 2024 16:49:01 +0000 Resent-Message-ID: <handler.68114.B68114.170455972531207 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 68114 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Steven Allen <steven@HIDDEN> Cc: 68114 <at> debbugs.gnu.org Received: via spool by 68114-submit <at> debbugs.gnu.org id=B68114.170455972531207 (code B ref 68114); Sat, 06 Jan 2024 16:49:01 +0000 Received: (at 68114) by debbugs.gnu.org; 6 Jan 2024 16:48:45 +0000 Received: from localhost ([127.0.0.1]:60234 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rM9qm-00087D-TB for submit <at> debbugs.gnu.org; Sat, 06 Jan 2024 11:48:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45408) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1rM9qj-00086H-7i for 68114 <at> debbugs.gnu.org; Sat, 06 Jan 2024 11:48:43 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1rM9qX-0002Xq-RS; Sat, 06 Jan 2024 11:48:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=vKtsCCTCb/ybTJBDaKWH9QCqZ2CQEUdDbfHQZNAlFdU=; b=dGaf3HLEsThQ Lb0VftWOEsOqCuHxcw0fhTtKxOSO0Pn3JzNLMs6zkoKr/NQr1Ynf5ExB283GMA484Y0c78pfX4f8t 44+Sjf1Wquu11u/sYwKJoxr3MOuxevlThMVBe/vYFUn2UbLF4qqsCxAlgsj5L6IkvkFihe+5D0PQV LlVpg7HdWzwpBfJFPP5Je0uAyyIF2S1KNpbgDFKrais3QNt09Lg224S9ZccSWQVN0Dr9ZutZaZ2R/ H5QvpJWPoWqc6hhsUoeX/PwtlINcD/uOAlHrJIvskfbOaEY17j6zrFigAVrTXxKa2ieUGon7vcl0B hq00fJhULjIIgY8HG8KnGg==; Date: Sat, 06 Jan 2024 18:48:20 +0200 Message-Id: <83o7dys90r.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> In-Reply-To: <87r0j3hcir.fsf@HIDDEN> (message from Steven Allen on Sat, 30 Dec 2023 08:37:48 -0800) References: <87r0j42353.fsf@HIDDEN> <83a5ps6a5e.fsf@HIDDEN> <87r0j491mx.fsf@HIDDEN> <837ckw5gug.fsf@HIDDEN> <87r0j3hcir.fsf@HIDDEN> X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > From: Steven Allen <steven@HIDDEN> > Date: Sat, 30 Dec 2023 08:37:48 -0800 > > Ah, I responded to the previous message before seeing this one. I installed this patch, thanks. > > Btw, what is "the 'name' of a piece of advice"? I realize that this > > text was there to begin with, but I don't think I understand what it > > wants to tell me, so maybe we could clarify that. The only reference > > to a "name" in the preceding text uses "name" to mean a symbol, but > > then what is "the name of a piece of advice"? I guess this goes back > > to define-advice, which says: > > > > @defmac define-advice symbol (where lambda-list &optional name depth) &rest body > > This macro defines a piece of advice and adds it to the function named > > @var{symbol}. The advice is an anonymous function if @var{name} is > > @code{nil} or a function named @code{symbol@@name}. See > > @code{advice-add} for explanation of other arguments. > > > > which is also a bit mysterious. Does NAME used here serve as "the > > name of the piece of advice"? if so, should "@code{symbol@@name}" be > > "@code{symbol@@@var{name}}" instead, i.e. "name" is not a literal > > string but the reference to NAME? > > So, those two names are actually different. The 'name' in referenced in > the `advice-remove` documentation is the 'name in the advice's 'props' > alist. The 'name' specified in `define-advice` is _not_ added to this > alist and is only used in the advice's function name. > > I'm happy to resolve this in a separate patch, if that's OK with you. > Something like (`define-advice` documentation): > > Note if NAME is nil the advice is anonymous; otherwise the advice > function is named `SYMBOL@NAME' and the advice is named NAME. > > Then actually add NAME to the properties. Yes, I think something like this should be installed.
Received: (at control) by debbugs.gnu.org; 10 Jan 2024 17:32:31 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jan 10 12:32:31 2024 Received: from localhost ([127.0.0.1]:42790 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rNcRL-0007tL-0F for submit <at> debbugs.gnu.org; Wed, 10 Jan 2024 12:32:31 -0500 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]:60691) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <stefankangas@HIDDEN>) id 1rNcRJ-0007t6-HX for control <at> debbugs.gnu.org; Wed, 10 Jan 2024 12:32:29 -0500 Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-557e76e1bd6so3247648a12.1 for <control <at> debbugs.gnu.org>; Wed, 10 Jan 2024 09:32:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704907945; x=1705512745; darn=debbugs.gnu.org; h=to:subject:message-id:date:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=Pe6hLFvZiSQSsd8rhb+VebkjDLM7xYUwkTL+n17ZA3s=; b=mmk/XW4NZyU+GLhlCuhPAnJZPm+mQogHjWhK/XuQufXDV4qZGx6rEZB+6DdirhwySk boVpsfgn6zkdjXt5HSX55upV4vqTI1gN6toUpkQJO3vsheNY8BJVv76uTZLqMuEoeURu 1D3GWt7LfPhybMSiUjYuGydlhQntR5ylEJvwmi0oseQDe01nm5PsA0BkQQVJt4G4aQ2h 3QJeu/7fBxrXmHLpESV0LGrCHTN7Mgy+4cBjlIWXL6niEfph4FQTQM0b/XLKK433GrhM XPfORLOA7Ktj9Q/WE6379e3viDQoXf/OP7MBfOsZjsT1qgYbZUnBReknK3RsmIqDd/+M cXhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704907945; x=1705512745; h=to:subject:message-id:date:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Pe6hLFvZiSQSsd8rhb+VebkjDLM7xYUwkTL+n17ZA3s=; b=rGDc7g3Z6sACTkLQNtajSqMtUlCmD07RGAf4tvCuEvkdV5lJGBctHULloDgYXp5Y8i yo+wwpBRT8De+meWzoLArgFbWfs/iwGmh0bZNdDtdzyPXTgp7AN8UnQTqRUmSIxKt/ts gzBA48V5TZ3ZVKErbgAzWwtCuAWHP1ztuYiN3kyEUdmgqoDAJWFPsoCdzQ9xyaIDUJed e26pG7bnbA+YHWMeCn/3k9TMAl8y8SIrOuQ1mAQeTsztQly/7SvWbjNQ3XNH0vjYFVtl 2xCEPXX2DKUxy4bhjrP/wBpt0fQugFDqJAvk+yy1aYpYLSn4i5VdYxdRfQZkQIVmP677 wUWQ== X-Gm-Message-State: AOJu0Ywl+vKw+qGUUqQYmKtugwDSnJTIvyQ7Ynla9W/mgG2+GNKscAvj veDjp92b005aMWFlsbS1hbNVzygwoKv2bzZYeCzhqzER1tTRIw== X-Google-Smtp-Source: AGHT+IHV4Ioe5WtIuS5ptw2MTx/xKnGOiY8Ov/RchFRHpqR9m/KZIHOrw2cWQ48j/AuH8kLJTa7t/mDdU4fquZeVorY= X-Received: by 2002:a50:ab12:0:b0:54c:6d39:b152 with SMTP id s18-20020a50ab12000000b0054c6d39b152mr666884edc.3.1704907944892; Wed, 10 Jan 2024 09:32:24 -0800 (PST) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Wed, 10 Jan 2024 09:32:24 -0800 From: Stefan Kangas <stefankangas@HIDDEN> MIME-Version: 1.0 Date: Wed, 10 Jan 2024 09:32:24 -0800 Message-ID: <CADwFkmmWbOysXt5HRttdDEZ7Hy1Ush=OomR+K8T3kFvommVa1g@HIDDEN> Subject: control message for bug #68114 To: control <at> debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) severity 68114 wishlist quit
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.