Make `kill-all-local-variables' also remove lambda from hooks
authorjakanakaevangeli <jakanakaevangeli@chiru.no>
Tue, 20 Jul 2021 14:31:24 +0000 (16:31 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Tue, 20 Jul 2021 14:31:24 +0000 (16:31 +0200)
* src/buffer.c (reset_buffer_local_variables): Also remove
non-symbol elements from hook variables (bug#46407).

etc/NEWS
src/buffer.c

index df09d81bcfee8695500f5dd8b8928f3ce7216413..8fa43b83b540a174585a38db798ce2b3c512c46d 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2829,6 +2829,14 @@ This is to keep the same behavior as Eshell.
 \f
 * Incompatible Lisp Changes in Emacs 28.1
 
+---
+** 'kill-all-local-variables' has changed how it handles non-symbol hooks.
+The function is documented to eliminated all buffer-local bindings
+except variables with a 'permanent-local' property, or hooks that
+have elements with a 'permanent-local-hook' property.  In addition, it
+would also keep lambda expressions in hooks sometimes.  The latter has
+now been changed: The function will now also remove these.
+
 ---
 ** Some floating-point numbers are now handled differently by the Lisp reader.
 In previous versions of Emacs, numbers with a trailing dot and an exponent
index 335523de604dd0bbab4a57f036a89aba889cf669..b177c5eaa7f7285ae73335a05b442cf54e87ee9a 100644 (file)
@@ -1084,12 +1084,12 @@ reset_buffer_local_variables (struct buffer *b, bool permanent_too)
                     for (newlist = Qnil; CONSP (list); list = XCDR (list))
                       {
                         Lisp_Object elt = XCAR (list);
-                        /* Preserve element ELT if it's t,
-                           if it is a function with a `permanent-local-hook' property,
-                           or if it's not a symbol.  */
-                        if (! SYMBOLP (elt)
-                            || EQ (elt, Qt)
-                            || !NILP (Fget (elt, Qpermanent_local_hook)))
+                        /* Preserve element ELT if it's t, or if it is a
+                           function with a `permanent-local-hook'
+                           property. */
+                        if (EQ (elt, Qt)
+                            || (SYMBOLP (elt)
+                                && !NILP (Fget (elt, Qpermanent_local_hook))))
                           newlist = Fcons (elt, newlist);
                       }
                   newlist = Fnreverse (newlist);