mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-06-14 12:31:25 +00:00
Allow several mode: elements in the local variable section
* etc/NEWS (mode): Fall back on outline-mode in older Emacsen. * lisp/files.el (hack-local-variables--find-variables): Use the final mode: line (which is the same as having several mode: bits in the header line.
This commit is contained in:
parent
71005decb4
commit
35592141cc
4 changed files with 17 additions and 4 deletions
1
etc/NEWS
1
etc/NEWS
|
|
@ -2071,6 +2071,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
|||
|
||||
Local variables:
|
||||
coding: utf-8
|
||||
mode: outline
|
||||
mode: emacs-news
|
||||
paragraph-separate: "[ ]*$"
|
||||
end:
|
||||
|
|
|
|||
|
|
@ -3978,8 +3978,7 @@ major-mode."
|
|||
(forward-line 1))
|
||||
(goto-char (point-min))
|
||||
|
||||
(while (not (or (eobp)
|
||||
(and (eq handle-mode t) result)))
|
||||
(while (not (eobp))
|
||||
;; Find the variable name;
|
||||
(unless (looking-at hack-local-variable-regexp)
|
||||
(user-error "Malformed local variable line: %S"
|
||||
|
|
@ -4005,7 +4004,8 @@ major-mode."
|
|||
(not (string-match
|
||||
"-minor\\'"
|
||||
(setq val2 (downcase (symbol-name val)))))
|
||||
(setq result (intern (concat val2 "-mode"))))
|
||||
;; Allow several mode: elements.
|
||||
(push (intern (concat val2 "-mode")) result))
|
||||
(cond ((eq var 'coding))
|
||||
((eq var 'lexical-binding)
|
||||
(unless hack-local-variables--warned-lexical
|
||||
|
|
@ -4029,7 +4029,10 @@ major-mode."
|
|||
val)
|
||||
result))))))
|
||||
(forward-line 1)))))))
|
||||
result))
|
||||
(if (eq handle-mode t)
|
||||
;; Return the final mode: setting that's defined.
|
||||
(car (seq-filter #'fboundp result))
|
||||
result)))
|
||||
|
||||
(defun hack-local-variables-apply ()
|
||||
"Apply the elements of `file-local-variables-alist'.
|
||||
|
|
|
|||
5
test/lisp/files-resources/file-mode-multiple
Normal file
5
test/lisp/files-resources/file-mode-multiple
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
Local variables:
|
||||
mode: text
|
||||
mode: test-mode-undef
|
||||
mode: outline
|
||||
end:
|
||||
|
|
@ -1821,5 +1821,9 @@ Prompt users for any modified buffer with `buffer-offer-save' non-nil."
|
|||
;; Check that the mode cookie doesn't override the explicit setting.
|
||||
(should (eq major-mode 'emacs-lisp-mode)))
|
||||
|
||||
(ert-deftest files-test-set-mode-multiple ()
|
||||
(find-file (ert-resource-file "file-mode-multiple"))
|
||||
(should (eq major-mode 'outline-mode)))
|
||||
|
||||
(provide 'files-tests)
|
||||
;;; files-tests.el ends here
|
||||
|
|
|
|||
Loading…
Reference in a new issue