aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/files.el24
1 files changed, 14 insertions, 10 deletions
diff --git a/lisp/files.el b/lisp/files.el
index adec33ef77b..719cda70739 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -2285,14 +2285,12 @@ only set the major mode, if that would change it."
2285If optional arg KEEP-MODE-IF-SAME is non-nil, MODE is chased of 2285If optional arg KEEP-MODE-IF-SAME is non-nil, MODE is chased of
2286any aliases and compared to current major mode. If they are the 2286any aliases and compared to current major mode. If they are the
2287same, do nothing and return nil." 2287same, do nothing and return nil."
2288 (when keep-mode-if-same 2288 (unless (and keep-mode-if-same
2289 (while (symbolp (symbol-function mode)) 2289 (eq (indirect-function mode)
2290 (setq mode (symbol-function mode))) 2290 (indirect-function major-mode)))
2291 (if (eq mode major-mode) 2291 (when mode
2292 (setq mode nil))) 2292 (funcall mode)
2293 (when mode 2293 mode)))
2294 (funcall mode)
2295 mode))
2296 2294
2297(defun set-auto-mode-1 () 2295(defun set-auto-mode-1 ()
2298 "Find the -*- spec in the buffer. 2296 "Find the -*- spec in the buffer.
@@ -2811,9 +2809,15 @@ It is dangerous if either of these conditions are met:
2811 ok))))))) 2809 ok)))))))
2812 2810
2813(defun hack-one-local-variable (var val) 2811(defun hack-one-local-variable (var val)
2814 "Set local variable VAR with value VAL." 2812 "Set local variable VAR with value VAL.
2813If VAR is `mode', call `VAL-mode' as a function unless it's
2814already the major mode."
2815 (cond ((eq var 'mode) 2815 (cond ((eq var 'mode)
2816 (funcall (intern (concat (downcase (symbol-name val)) "-mode")))) 2816 (let ((mode (intern (concat (downcase (symbol-name val))
2817 "-mode"))))
2818 (unless (eq (indirect-function mode)
2819 (indirect-function major-mode))
2820 (funcall mode))))
2817 ((eq var 'eval) 2821 ((eq var 'eval)
2818 (save-excursion (eval val))) 2822 (save-excursion (eval val)))
2819 (t 2823 (t