summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChong Yidong <cyd@stupidchicken.com>2007-03-01 17:06:40 +0000
committerChong Yidong <cyd@stupidchicken.com>2007-03-01 17:06:40 +0000
commit0c7c413c0407704abca2e8d8a1afd95b25fe64df (patch)
tree572f7fe8f650086b4b516b4bbca7427cf43824b3
parentd42a3826b46d810237392951ad49eb1f6cbb3cb2 (diff)
downloademacs-0c7c413c0407704abca2e8d8a1afd95b25fe64df.tar.gz
(set-auto-mode-0): Use `indirect-function'.
(hack-one-local-variable): Don't reapply current major 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."
If optional arg KEEP-MODE-IF-SAME is non-nil, MODE is chased of
any aliases and compared to current major mode. If they are the
same, do nothing and return nil."
- (when keep-mode-if-same
- (while (symbolp (symbol-function mode))
- (setq mode (symbol-function mode)))
- (if (eq mode major-mode)
- (setq mode nil)))
- (when mode
- (funcall mode)
- mode))
+ (unless (and keep-mode-if-same
+ (eq (indirect-function mode)
+ (indirect-function major-mode)))
+ (when mode
+ (funcall mode)
+ mode)))
(defun set-auto-mode-1 ()
"Find the -*- spec in the buffer.
@@ -2811,9 +2809,15 @@ It is dangerous if either of these conditions are met:
ok)))))))
(defun hack-one-local-variable (var val)
- "Set local variable VAR with value VAL."
+ "Set local variable VAR with value VAL.
+If VAR is `mode', call `VAL-mode' as a function unless it's
+already the major mode."
(cond ((eq var 'mode)
- (funcall (intern (concat (downcase (symbol-name val)) "-mode"))))
+ (let ((mode (intern (concat (downcase (symbol-name val))
+ "-mode"))))
+ (unless (eq (indirect-function mode)
+ (indirect-function major-mode))
+ (funcall mode))))
((eq var 'eval)
(save-excursion (eval val)))
(t