aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim F. Storm2004-11-01 23:16:42 +0000
committerKim F. Storm2004-11-01 23:16:42 +0000
commit3467488ee7d0b3eb3b4c34da94eee2243636bc5b (patch)
tree73fcca8c5d5957835b29ca673fe5331ead3e68ab
parentad8d994cbecb75742754f1a9d56e5f1b11950e78 (diff)
downloademacs-3467488ee7d0b3eb3b4c34da94eee2243636bc5b.tar.gz
emacs-3467488ee7d0b3eb3b4c34da94eee2243636bc5b.zip
(set-auto-mode-0): Don't rely on dynamic binding of
keep-mode-if-same variable. Add it as optional arg instead. (set-auto-mode): Call set-auto-mode-0 with keep-mode-if-same.
-rw-r--r--lisp/files.el18
1 files changed, 9 insertions, 9 deletions
diff --git a/lisp/files.el b/lisp/files.el
index 5ff80615050..f10281a0d10 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -1896,7 +1896,7 @@ only set the major mode, if that would change it."
1896 (if (not (functionp mode)) 1896 (if (not (functionp mode))
1897 (message "Ignoring unknown mode `%s'" mode) 1897 (message "Ignoring unknown mode `%s'" mode)
1898 (setq done t) 1898 (setq done t)
1899 (or (set-auto-mode-0 mode) 1899 (or (set-auto-mode-0 mode keep-mode-if-same)
1900 (throw 'nop nil))))) 1900 (throw 'nop nil)))))
1901 ;; If we didn't, look for an interpreter specified in the first line. 1901 ;; If we didn't, look for an interpreter specified in the first line.
1902 ;; As a special case, allow for things like "#!/bin/env perl", which 1902 ;; As a special case, allow for things like "#!/bin/env perl", which
@@ -1911,7 +1911,7 @@ only set the major mode, if that would change it."
1911 done (assoc (file-name-nondirectory mode) 1911 done (assoc (file-name-nondirectory mode)
1912 interpreter-mode-alist)) 1912 interpreter-mode-alist))
1913 ;; If we found an interpreter mode to use, invoke it now. 1913 ;; If we found an interpreter mode to use, invoke it now.
1914 (if done (set-auto-mode-0 (cdr done)))) 1914 (if done (set-auto-mode-0 (cdr done) keep-mode-if-same)))
1915 (if (and (not done) buffer-file-name) 1915 (if (and (not done) buffer-file-name)
1916 (let ((name buffer-file-name)) 1916 (let ((name buffer-file-name))
1917 ;; Remove backup-suffixes from file name. 1917 ;; Remove backup-suffixes from file name.
@@ -1930,27 +1930,27 @@ only set the major mode, if that would change it."
1930 (when mode 1930 (when mode
1931 (if xml (or (memq mode xml-based-modes) 1931 (if xml (or (memq mode xml-based-modes)
1932 (setq mode 'xml-mode))) 1932 (setq mode 'xml-mode)))
1933 (set-auto-mode-0 mode) 1933 (set-auto-mode-0 mode keep-mode-if-same)
1934 (setq done t))))) 1934 (setq done t)))))
1935 (and xml 1935 (and xml
1936 (not done) 1936 (not done)
1937 (set-auto-mode-0 'xml-mode)))) 1937 (set-auto-mode-0 'xml-mode keep-mode-if-same))))
1938 1938
1939 1939
1940;; When `keep-mode-if-same' is set, we are working on behalf of 1940;; When `keep-mode-if-same' is set, we are working on behalf of
1941;; set-visited-file-name. In that case, if the major mode specified is the 1941;; set-visited-file-name. In that case, if the major mode specified is the
1942;; same one we already have, don't actually reset it. We don't want to lose 1942;; same one we already have, don't actually reset it. We don't want to lose
1943;; minor modes such as Font Lock. 1943;; minor modes such as Font Lock.
1944(defun set-auto-mode-0 (mode) 1944(defun set-auto-mode-0 (mode &optional keep-mode-if-same)
1945 "Apply MODE and return it. 1945 "Apply MODE and return it.
1946If `keep-mode-if-same' is non-nil MODE is chased of any aliases and 1946If optional arg KEEP-MODE-IF-SAME is non-nil, MODE is chased of
1947compared to current major mode. If they are the same, do nothing 1947any aliases and compared to current major mode. If they are the
1948and return nil." 1948same, do nothing and return nil."
1949 (when keep-mode-if-same 1949 (when keep-mode-if-same
1950 (while (symbolp (symbol-function mode)) 1950 (while (symbolp (symbol-function mode))
1951 (setq mode (symbol-function mode))) 1951 (setq mode (symbol-function mode)))
1952 (if (eq mode major-mode) 1952 (if (eq mode major-mode)
1953 (setq mode))) 1953 (setq mode nil)))
1954 (when mode 1954 (when mode
1955 (funcall mode) 1955 (funcall mode)
1956 mode)) 1956 mode))