From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Steven Allen <steven@stebalien.com>
Cc: Eli Zaretskii <eliz@gnu.org>, 68114@debbugs.gnu.org
Subject: bug#68114: [PATCH] Make 'advice-remove' interactive
Date: Sat, 30 Dec 2023 00:06:31 -0500 [thread overview]
Message-ID: <jwv7ckwcmnv.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87r0j491mx.fsf@stebalien.com> (Steven Allen's message of "Fri, 29 Dec 2023 12:47:50 -0800")
> --- 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
next prev parent reply other threads:[~2023-12-30 5:06 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
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 [this message]
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwv7ckwcmnv.fsf-monnier+emacs@gnu.org \
--to=bug-gnu-emacs@gnu.org \
--cc=68114@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=monnier@iro.umontreal.ca \
--cc=steven@stebalien.com \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).