diff lisp/files.el @ 90780:ec58e5c426ef

Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 653-661) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 203-206) - Merge from emacs--devo--0 - Update from CVS Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-180
author Miles Bader <miles@gnu.org>
date Sun, 04 Mar 2007 06:19:40 +0000
parents dd7c098af727 ec75921d5b7b
children 91bf6e05918b
line wrap: on
line diff
--- a/lisp/files.el	Fri Mar 02 01:43:44 2007 +0000
+++ b/lisp/files.el	Sun Mar 04 06:19:40 2007 +0000
@@ -2285,14 +2285,12 @@
 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 @@
 		      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