Subject: [PATCH] Make 'advice-remove' interactive
From: Steven Allen <[email-masked]>
To: [email-masked]
Date: Fri, 29 Dec 2023 11:57:12 -0800
List-Id: <debbugs-submit.debbugs.gnu.org>

This patch makes 'advice-remove' interactive to match
'ad-advice-remove'. Unlike 'ad-advice-remove', 'advice-remove' works
with new-style advice as well.

From 41de95097d3e79967f4fbb417aba424e8ffce058 Mon Sep 17 00:00:00 2001
From: Steven Allen <[email-masked]>
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