]> git.eshelyaron.com Git - emacs.git/commitdiff
(hack-one-local-variable): Fix bug#74964
authorStefan Monnier <monnier@iro.umontreal.ca>
Sun, 5 Jan 2025 15:03:40 +0000 (10:03 -0500)
committerEshel Yaron <me@eshelyaron.com>
Wed, 8 Jan 2025 08:35:02 +0000 (09:35 +0100)
* lisp/files.el (hack-local-variables--inhibit): New var.
(hack-one-local-variable): Use it to avoid infinite recursion in a more
targeted manner.

(cherry picked from commit 127fc983080a3b9a607fa693bacfcf02f19ce0b7)

lisp/files.el

index b4f24bf4d57f52acfe5bfe35d8bf113183c52fc1..0203b819797cdddae12696e93a9ae1d1744f3526 100644 (file)
@@ -4532,11 +4532,15 @@ It is dangerous if either of these conditions are met:
                      (substitute-command-keys instead)
                    (format-message "use `%s' instead" instead)))))))
 
+(defvar hack-local-variables--inhibit nil
+  "List of file/dir local variables to ignore.")
+
 (defun hack-one-local-variable (var val)
   "Set local variable VAR with value VAL.
 If VAR is `mode', call `VAL-mode' as a function unless it's
 already the major mode."
   (pcase var
+    ((guard (memq var hack-local-variables--inhibit)) nil)
     ('mode
      (let ((mode (intern (concat (downcase (symbol-name val))
                                  "-mode"))))
@@ -4544,7 +4548,8 @@ already the major mode."
     ('eval
      (pcase val
        (`(add-hook ',hook . ,_) (hack-one-local-variable--obsolete hook)))
-     (let ((enable-local-variables nil)) ;FIXME: Should be buffer-local!
+     (let ((hack-local-variables--inhibit ;; FIXME: Should be buffer-local!
+            (cons 'eval hack-local-variables--inhibit)))
        (save-excursion (eval val t))))
     (_
      (hack-one-local-variable--obsolete var)