[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#5293: 23.1; unload-feature on buffer-local hooks
From: |
Lars Ingebrigtsen |
Subject: |
bug#5293: 23.1; unload-feature on buffer-local hooks |
Date: |
Wed, 30 Sep 2020 20:44:04 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Štěpán Němec <stepnem@gmail.com> writes:
> So I guess my defeatism will not prevail after all. Updated [2/3] attached.
The patch no longer applied to the trunk, and it referred to a variable
called `removables' that I couldn't find. So I've respun it (included
below), but not tested.
Any comments?
diff --git a/etc/NEWS b/etc/NEWS
index b4f29ab783..993cb3ca85 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -215,6 +215,9 @@ preserving markers, properties and overlays. The new
variable
number of seconds that 'revert-buffer-with-fine-grain' should spend
trying to be non-destructive.
+---
+** 'unload-feature' now also tries to undo additions to buffer-local hooks.
+
* Changes in Specialized Modes and Packages in Emacs 28.1
diff --git a/lisp/loadhist.el b/lisp/loadhist.el
index a1ff2f6270..6f2e313f71 100644
--- a/lisp/loadhist.el
+++ b/lisp/loadhist.el
@@ -297,6 +297,16 @@ unload-feature
(when (and (eq (car-safe y) 'defun)
(not (get (cdr y) 'autoload)))
(remove-hook x (cdr y)))))))
+ ;; Handle buffer-local hooks.
+ (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 unload-function-defs-list)
+ (remove-hook sym func t))))))
;; Remove any feature-symbols from auto-mode-alist as well.
(dolist (y unload-function-defs-list)
(when (and (eq (car-safe y) 'defun)
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- bug#5293: 23.1; unload-feature on buffer-local hooks,
Lars Ingebrigtsen <=