emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 713a199705: Fix major-mode setting regression when there's a mode


From: Lars Ingebrigtsen
Subject: master 713a199705: Fix major-mode setting regression when there's a mode: cookie
Date: Mon, 18 Apr 2022 04:36:49 -0400 (EDT)

branch: master
commit 713a1997059fb823f9fa26f92cee032fb6bfdc25
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Fix major-mode setting regression when there's a mode: cookie
    
    * lisp/files.el (hack-local-variables): Fix regression in setting
    the major mode when there are mode: cookies in the file (bug#54993).
---
 lisp/files.el                       | 2 +-
 test/lisp/files-resources/file-mode | 3 +++
 test/lisp/files-tests.el            | 7 +++++++
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/lisp/files.el b/lisp/files.el
index 80180276a9..135a6177e9 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -3899,7 +3899,7 @@ inhibited."
       (with-demoted-errors "Directory-local variables error: %s"
        ;; Note this is a no-op if enable-local-variables is nil.
        (hack-dir-local-variables))
-      (let ((result (append (hack-local-variables--find-variables)
+      (let ((result (append (hack-local-variables--find-variables handle-mode)
                             (hack-local-variables-prop-line))))
         (if (and enable-local-variables
                  (not (inhibit-local-variables-p)))
diff --git a/test/lisp/files-resources/file-mode 
b/test/lisp/files-resources/file-mode
new file mode 100644
index 0000000000..92ac4c30ef
--- /dev/null
+++ b/test/lisp/files-resources/file-mode
@@ -0,0 +1,3 @@
+Local variables:
+mode: text
+end:
diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el
index e4424f3cbe..f76d047f30 100644
--- a/test/lisp/files-tests.el
+++ b/test/lisp/files-tests.el
@@ -1814,5 +1814,12 @@ Prompt users for any modified buffer with 
`buffer-offer-save' non-nil."
   (should (equal (file-name-split "/foo/bar/") '("" "foo" "bar" "")))
   (should (equal (file-name-split "foo/bar/") '("foo" "bar" ""))))
 
+(ert-deftest files-test-set-mode ()
+  (find-file (ert-resource-file "file-mode"))
+  (should (eq major-mode 'text-mode))
+  (emacs-lisp-mode)
+  ;; Check that the mode cookie doesn't override the explicit setting.
+  (should (eq major-mode 'emacs-lisp-mode)))
+
 (provide 'files-tests)
 ;;; files-tests.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]