all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Steven Allen <steven@stebalien.com>
To: Eli Zaretskii <eliz@gnu.org>, Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 68114@debbugs.gnu.org
Subject: bug#68114: [PATCH] Make 'advice-remove' interactive
Date: Fri, 29 Dec 2023 12:47:50 -0800	[thread overview]
Message-ID: <87r0j491mx.fsf@stebalien.com> (raw)
In-Reply-To: <83a5ps6a5e.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 200 bytes --]


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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 3049 bytes --]

From e1c6ccbf22a80f9ec96a7034ef66d2d7b66e793b Mon Sep 17 00:00:00 2001
From: Steven Allen <steven@stebalien.com>
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


  reply	other threads:[~2023-12-29 20:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-29 19:57 bug#68114: [PATCH] Make 'advice-remove' interactive Steven Allen
2023-12-29 20:12 ` Eli Zaretskii
2023-12-29 20:47   ` Steven Allen [this message]
2023-12-29 21:20     ` Stefan Kangas
2023-12-29 22:43       ` Steven Allen
2023-12-30  5:06     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-30 16:22       ` Steven Allen
2023-12-30  6:45     ` Eli Zaretskii
2023-12-30 16:37       ` Steven Allen
2024-01-06  9:02         ` Eli Zaretskii
2024-01-06 16:48         ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r0j491mx.fsf@stebalien.com \
    --to=steven@stebalien.com \
    --cc=68114@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.