* lisp/files.el (hack-local-variables): Fix regression in setting
the major mode when there are mode: cookies in the file (bug#54993).
(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)))
--- /dev/null
+Local variables:
+mode: text
+end:
(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