summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lisp/files.el2
-rw-r--r--test/lisp/files-resources/file-mode3
-rw-r--r--test/lisp/files-tests.el7
3 files changed, 11 insertions, 1 deletions
diff --git a/lisp/files.el b/lisp/files.el
index 80180276a99..135a6177e9c 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 00000000000..92ac4c30ef5
--- /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 e4424f3cbed..f76d047f302 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