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 14:43:59 -0800 Message-ID: <87wmswoci8.fsf@stebalien.com> References: <87r0j42353.fsf@stebalien.com> <83a5ps6a5e.fsf@gnu.org> <87r0j491mx.fsf@stebalien.com> 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="14306"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 68114@debbugs.gnu.org To: Stefan Kangas , Eli Zaretskii , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Dec 29 23:45: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 1rJLba-0003TB-C7 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 29 Dec 2023 23:45:27 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rJLbF-0005D2-5K; Fri, 29 Dec 2023 17:45:05 -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 1rJLbC-0005Cn-A6 for bug-gnu-emacs@gnu.org; Fri, 29 Dec 2023 17:45: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 1rJLbC-0002TR-0D for bug-gnu-emacs@gnu.org; Fri, 29 Dec 2023 17:45:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rJLbB-0004mf-Pn for bug-gnu-emacs@gnu.org; Fri, 29 Dec 2023 17:45:01 -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 22:45:01 +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.170388984918314 (code B ref 68114); Fri, 29 Dec 2023 22:45:01 +0000 Original-Received: (at 68114) by debbugs.gnu.org; 29 Dec 2023 22:44:09 +0000 Original-Received: from localhost ([127.0.0.1]:42456 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rJLaK-0004lK-E0 for submit@debbugs.gnu.org; Fri, 29 Dec 2023 17:44:08 -0500 Original-Received: from out4-smtp.messagingengine.com ([66.111.4.28]:33055) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rJLaJ-0004l7-Fq for 68114@debbugs.gnu.org; Fri, 29 Dec 2023 17:44:08 -0500 Original-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) Original-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: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdefgedgtdefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefujghffffkgggtsehmtderredttddtnecuhfhrohhmpefuthgvvhgv nhcutehllhgvnhcuoehsthgvvhgvnhesshhtvggsrghlihgvnhdrtghomheqnecuggftrf grthhtvghrnhepjedufedvieejueektddtgedugeffveejheehieeulefgfffhleffheef vefhvdegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epshhtvghvvghnsehsthgvsggrlhhivghnrdgtohhm X-ME-Proxy: Feedback-ID: ie8a146a7:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 29 Dec 2023 17:44:01 -0500 (EST) In-Reply-To: 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:277047 Archived-At: --=-=-= 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 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 --=-=-=--