mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-24 07:20:37 +00:00
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 (Bug#67926). * doc/lispref/functions.texi (Advising Named Functions): Document that 'advice-remove' is now an interactive command.
This commit is contained in:
parent
6184e120c0
commit
16162e0645
@ -2077,10 +2077,12 @@ Add the advice @var{function} to the named function @var{symbol}.
|
||||
(@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
|
||||
|
4
etc/NEWS
4
etc/NEWS
@ -104,6 +104,10 @@ to your init:
|
||||
|
||||
* 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
|
||||
|
@ -539,6 +539,32 @@ Contrary to `remove-function', this also works when SYMBOL is a macro
|
||||
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* ((pred (lambda (sym) (advice--p (advice--symbol-function sym))))
|
||||
(default (when-let* ((f (function-called-at-point))
|
||||
((funcall pred f)))
|
||||
(symbol-name f)))
|
||||
(prompt (format-prompt "Remove advice from function" default))
|
||||
(symbol (intern (completing-read prompt obarray pred t nil nil default)))
|
||||
advices)
|
||||
(advice-mapc (lambda (f p)
|
||||
(let ((k (or (alist-get 'name p) f)))
|
||||
(push (cons
|
||||
;; "name" (string) and 'name (symbol) are
|
||||
;; considered different names so we use
|
||||
;; `prin1-to-string' even if the name is
|
||||
;; a string to distinguish between these
|
||||
;; two cases.
|
||||
(prin1-to-string k)
|
||||
;; We use `k' here instead of `f' because
|
||||
;; the same advice can have multiple
|
||||
;; names.
|
||||
k)
|
||||
advices)))
|
||||
symbol)
|
||||
(list symbol (cdr (assoc-string
|
||||
(completing-read "Advice to remove: " advices nil t)
|
||||
advices)))))
|
||||
(let ((f (symbol-function symbol)))
|
||||
(remove-function (cond ;This is `advice--symbol-function' but as a "place".
|
||||
((get symbol 'advice--pending)
|
||||
|
Loading…
Reference in New Issue
Block a user