From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Steven Allen Newsgroups: gmane.emacs.bugs Subject: bug#68114: [PATCH] Make 'advice-remove' interactive Date: Fri, 29 Dec 2023 12:47:50 -0800 Message-ID: <87r0j491mx.fsf@stebalien.com> References: <87r0j42353.fsf@stebalien.com> <83a5ps6a5e.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12354"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 68114@debbugs.gnu.org To: Eli Zaretskii , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Dec 29 21:48:28 2023 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 1rJJmM-0002zN-Ok for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 29 Dec 2023 21:48:28 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rJJm0-0001kl-15; Fri, 29 Dec 2023 15:48:04 -0500 Original-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 ) id 1rJJly-0001kL-Nb for bug-gnu-emacs@gnu.org; Fri, 29 Dec 2023 15:48:02 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rJJly-0000Or-En for bug-gnu-emacs@gnu.org; Fri, 29 Dec 2023 15:48:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rJJly-0000Ur-BF for bug-gnu-emacs@gnu.org; Fri, 29 Dec 2023 15:48:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Steven Allen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 29 Dec 2023 20:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68114 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 68114-submit@debbugs.gnu.org id=B68114.17038828811900 (code B ref 68114); Fri, 29 Dec 2023 20:48:02 +0000 Original-Received: (at 68114) by debbugs.gnu.org; 29 Dec 2023 20:48:01 +0000 Original-Received: from localhost ([127.0.0.1]:42345 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rJJlw-0000UW-P4 for submit@debbugs.gnu.org; Fri, 29 Dec 2023 15:48:01 -0500 Original-Received: from out4-smtp.messagingengine.com ([66.111.4.28]:52239) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rJJlu-0000Tk-KH for 68114@debbugs.gnu.org; Fri, 29 Dec 2023 15:47:59 -0500 Original-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) Original-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: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdeffedgudegudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufgjfhffkfggtgesmhdtreertddttdenucfhrhhomhepufhtvghv vghnucetlhhlvghnuceoshhtvghvvghnsehsthgvsggrlhhivghnrdgtohhmqeenucggtf frrghtthgvrhhnpeejudefvdeijeeukedttdegudegffevjeehheeiueelgfffhfelffeh feevhfdvgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehsthgvvhgvnhesshhtvggsrghlihgvnhdrtghomh X-ME-Proxy: Feedback-ID: ie8a146a7:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 29 Dec 2023 15:47:52 -0500 (EST) In-Reply-To: <83a5ps6a5e.fsf@gnu.org> 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:277041 Archived-At: --=-=-= 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 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 --=-=-=--