From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#68114: [PATCH] Make 'advice-remove' interactive Date: Sat, 30 Dec 2023 00:06:31 -0500 Message-ID: References: <87r0j42353.fsf@stebalien.com> <83a5ps6a5e.fsf@gnu.org> <87r0j491mx.fsf@stebalien.com> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19955"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eli Zaretskii , 68114@debbugs.gnu.org To: Steven Allen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Dec 30 06:07:21 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 1rJRZA-00051D-LB for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 30 Dec 2023 06:07:20 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rJRYt-0000Da-I0; Sat, 30 Dec 2023 00:07:03 -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 1rJRYr-0000DL-Uo for bug-gnu-emacs@gnu.org; Sat, 30 Dec 2023 00:07:01 -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 1rJRYr-0000vy-Lv for bug-gnu-emacs@gnu.org; Sat, 30 Dec 2023 00:07:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rJRYr-0006hc-NL for bug-gnu-emacs@gnu.org; Sat, 30 Dec 2023 00:07:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 30 Dec 2023 05:07: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.170391280225740 (code B ref 68114); Sat, 30 Dec 2023 05:07:01 +0000 Original-Received: (at 68114) by debbugs.gnu.org; 30 Dec 2023 05:06:42 +0000 Original-Received: from localhost ([127.0.0.1]:42808 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rJRYY-0006h5-9e for submit@debbugs.gnu.org; Sat, 30 Dec 2023 00:06:42 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:32542) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rJRYV-0006gr-SY for 68114@debbugs.gnu.org; Sat, 30 Dec 2023 00:06:40 -0500 Original-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== Original-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) Original-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) In-Reply-To: <87r0j491mx.fsf@stebalien.com> (Steven Allen's message of "Fri, 29 Dec 2023 12:47:50 -0800") 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:277055 Archived-At: > --- 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