GNU bug report logs - #5293
23.1; unload-feature on buffer-local hooks

Previous Next

Package: emacs;

Reported by: Kevin Ryde <user42 <at> zip.com.au>

Date: Sat, 2 Jan 2010 21:07:02 UTC

Severity: minor

Merged with 34686

Found in version 26.1

Done: Štěpán Němec <stepnem <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #62 received at 5293 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Štěpán Němec <stepnem <at> gmail.com>
Cc: Juanma Barranquero <lekktu <at> gmail.com>, Kevin Ryde <user42 <at> zip.com.au>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>, 5293 <at> debbugs.gnu.org
Subject: Re: bug#5293: 23.1; unload-feature on buffer-local hooks
Date: Wed, 30 Sep 2020 20:44:04 +0200
Štěpán Němec <stepnem <at> 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




This bug report was last modified 4 years and 214 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.