Make `remove-hook' interactive
* lisp/subr.el (remove-hook): Make `remove-hook' interactive (bug#45393).
This commit is contained in:
parent
af359de917
commit
174327cefa
2 changed files with 29 additions and 1 deletions
3
etc/NEWS
3
etc/NEWS
|
@ -1460,6 +1460,9 @@ that makes it a valid button.
|
|||
|
||||
** Miscellaneous
|
||||
|
||||
---
|
||||
*** 'remove-hook' is now an interactive command.
|
||||
|
||||
---
|
||||
*** New user option 'authinfo-hide-elements'.
|
||||
This can be set to nil to inhibit hiding passwords in .authinfo files.
|
||||
|
|
27
lisp/subr.el
27
lisp/subr.el
|
@ -1742,7 +1742,32 @@ FUNCTION isn't the value of HOOK, or, if FUNCTION doesn't appear in the
|
|||
list of hooks to run in HOOK, then nothing is done. See `add-hook'.
|
||||
|
||||
The optional third argument, LOCAL, if non-nil, says to modify
|
||||
the hook's buffer-local value rather than its default value."
|
||||
the hook's buffer-local value rather than its default value.
|
||||
|
||||
Interactively, prompt for the various arguments (skipping local
|
||||
unless HOOK has both local and global functions). If multiple
|
||||
functions have the same representation under `princ', the first
|
||||
one will be removed."
|
||||
(interactive
|
||||
(let* ((hook (intern (completing-read "Hook variable: " obarray #'boundp t)))
|
||||
(local
|
||||
(and
|
||||
(local-variable-p hook)
|
||||
(symbol-value hook)
|
||||
;; No need to prompt if there's nothing global
|
||||
(or (not (default-value hook))
|
||||
(y-or-n-p (format "%s has a buffer-local binding, use that? "
|
||||
hook)))))
|
||||
(fn-alist (mapcar
|
||||
(lambda (x) (cons (with-output-to-string (prin1 x)) x))
|
||||
(if local (symbol-value hook) (default-value hook))))
|
||||
(function (alist-get (completing-read
|
||||
(format "%s hook to remove: "
|
||||
(if local "Buffer-local" "Global"))
|
||||
fn-alist
|
||||
nil t)
|
||||
fn-alist nil nil 'string=)))
|
||||
(list hook function local)))
|
||||
(or (boundp hook) (set hook nil))
|
||||
(or (default-boundp hook) (set-default hook nil))
|
||||
;; Do nothing if LOCAL is t but this hook has no local binding.
|
||||
|
|
Loading…
Add table
Reference in a new issue