(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"
(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
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'.
;; 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