]> git.eshelyaron.com Git - emacs.git/commitdiff
unload-feature: Handle local hooks (bug#5293)
authorŠtěpán Němec <stepnem@gmail.com>
Mon, 6 Apr 2020 11:30:11 +0000 (13:30 +0200)
committerŠtěpán Němec <stepnem@gmail.com>
Wed, 21 Oct 2020 16:51:12 +0000 (18:51 +0200)
Buffer-local hooks were introduced in

1994-09-30T20:47:13+00:00!rms@gnu.org
0e4d378b32 (add-hook): Initialize default value and local value.

but 'unload-feature' has not been updated to handle them.

* lisp/loadhist.el (unload-feature): Handle local hooks (bug#5293).

etc/NEWS
lisp/loadhist.el

index f3e3d9a1b6e0f129c14b20a672d141c8a6a5affe..2aed5751595956d8fdb58e51a2c65fa81f5856cd 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1748,6 +1748,9 @@ to lexical binding, where dynamic (special) variables bound in one
 file can affect code in another.  For details, see the manual section
 '(Elisp) Converting to Lexical Binding'.
 
+---
+** 'unload-feature' now also tries to undo additions to buffer-local hooks.
+
 \f
 * Changes in Emacs 28.1 on Non-Free Operating Systems
 
index 60da00cceb208d06c0041ea02d72bad5e7449f91..81576679c3571fe841e35302922b8d029dc5babc 100644 (file)
@@ -300,6 +300,15 @@ something strange, such as redefining an Emacs function."
                            (memq x unload-feature-special-hooks)))
               (dolist (func removables)
                 (remove-hook x func)))))
+          (save-current-buffer
+            (dolist (buffer (buffer-list))
+              (pcase-dolist (`(,sym . ,val) (buffer-local-variables buffer))
+                (when (or (and (consp val)
+                               (string-match "-hooks?\\'" (symbol-name sym)))
+                          (memq sym unload-feature-special-hooks))
+                  (set-buffer buffer)
+                  (dolist (func removables)
+                    (remove-hook sym func t))))))
           ;; Remove any feature-symbols from auto-mode-alist as well.
           (dolist (func removables)
             (setq auto-mode-alist