/[emacs]/emacs/lisp/files.el
ViewVC logotype

Diff of /emacs/lisp/files.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.714 by pfeiffer, Wed Oct 27 21:44:35 2004 UTC revision 1.715 by pfeiffer, Thu Oct 28 06:05:17 2004 UTC
# Line 1857  Local Variables section of the file; for Line 1857  Local Variables section of the file; for
1857  If `enable-local-variables' is nil, this function does not check for a  If `enable-local-variables' is nil, this function does not check for a
1858  -*- mode tag.  -*- mode tag.
1859    
1860  If the optional argument KEEP-MODE-IF-SAME is non-nil,  If the optional argument KEEP-MODE-IF-SAME is non-nil, then we
1861  then we do not set anything but the major mode,  only set the major mode, if that would change it."
 and we don't even do that unless it would come from the file name."  
1862    ;; Look for -*-MODENAME-*- or -*- ... mode: MODENAME; ... -*-    ;; Look for -*-MODENAME-*- or -*- ... mode: MODENAME; ... -*-
1863    (let (end done mode modes xml)    (let (end done mode modes xml)
1864      ;; Find a -*- mode tag      ;; Find a -*- mode tag
# Line 1891  and we don't even do that unless it woul Line 1890  and we don't even do that unless it woul
1890                     modes))))                     modes))))
1891      ;; If we found modes to use, invoke them now, outside the save-excursion.      ;; If we found modes to use, invoke them now, outside the save-excursion.
1892      (if modes      (if modes
1893          (dolist (mode (nreverse modes))          (catch 'nop
1894            (if (not (functionp mode))            (dolist (mode (nreverse modes))
1895                (message "Ignoring unknown mode `%s'" mode)              (if (not (functionp mode))
1896              (setq done t)                  (message "Ignoring unknown mode `%s'" mode)
1897              (unless (if keep-mode-if-same (eq mode major-mode))                (setq done t)
1898                (funcall mode))))                (or (set-auto-mode-0 mode)
1899                      (throw 'nop)))))
1900        ;; If we didn't, look for an interpreter specified in the first line.        ;; If we didn't, look for an interpreter specified in the first line.
1901        ;; As a special case, allow for things like "#!/bin/env perl", which        ;; As a special case, allow for things like "#!/bin/env perl", which
1902        ;; finds the interpreter anywhere in $PATH.        ;; finds the interpreter anywhere in $PATH.
# Line 1910  and we don't even do that unless it woul Line 1910  and we don't even do that unless it woul
1910              done (assoc (file-name-nondirectory mode)              done (assoc (file-name-nondirectory mode)
1911                          interpreter-mode-alist))                          interpreter-mode-alist))
1912        ;; If we found an interpreter mode to use, invoke it now.        ;; If we found an interpreter mode to use, invoke it now.
1913        (and done        (if done (set-auto-mode-0 (cdr done))))
            (not (if keep-mode-if-same (eq mode major-mode)))  
            (funcall (cdr done))))  
1914      (if (and (not done) buffer-file-name)      (if (and (not done) buffer-file-name)
1915          (let ((name buffer-file-name))          (let ((name buffer-file-name))
1916            ;; Remove backup-suffixes from file name.            ;; Remove backup-suffixes from file name.
# Line 1930  and we don't even do that unless it woul Line 1928  and we don't even do that unless it woul
1928                  (setq name)))                  (setq name)))
1929              (when mode              (when mode
1930                (if xml (or (memq mode xml-based-modes)                (if xml (or (memq mode xml-based-modes)
1931                            (setq mode 'sgml-mode))) ; alias to xml-mode for `eq'                            (setq mode 'xml-mode)))
1932                ;; When KEEP-MODE-IF-SAME is set, we are working on behalf of                (set-auto-mode-0 mode)
               ;; set-visited-file-name.  In that case, if the major mode  
               ;; specified is the same one we already have, don't actually  
               ;; reset it.  We don't want to lose minor modes such as Font  
               ;; Lock.  
               (unless (if keep-mode-if-same (eq mode major-mode))  
                 (funcall mode))  
1933                (setq done t)))))                (setq done t)))))
1934      (and (not done)      (and xml
1935           xml           (not done)
1936           (not (if keep-mode-if-same (eq 'sgml-mode major-mode)))           (set-auto-mode-0 'xml-mode))))
1937           (xml-mode))))  
1938    
1939    ;; When `keep-mode-if-same' is set, we are working on behalf of
1940    ;; set-visited-file-name.  In that case, if the major mode specified is the
1941    ;; same one we already have, don't actually reset it.  We don't want to lose
1942    ;; minor modes such as Font Lock.
1943    (defun set-auto-mode-0 (mode)
1944      "Apply MODE and return it.
1945    If `keep-mode-if-same' is non-nil MODE is chased of any aliases and
1946    compared to current major mode.  If they are the same, do nothing
1947    and return nil."
1948      (when keep-mode-if-same
1949        (while (symbolp (symbol-function mode))
1950          (setq mode (symbol-function mode)))
1951        (if (eq mode major-mode)
1952            (setq mode)))
1953      (when mode
1954        (funcall mode)
1955        mode))
1956    
1957    
1958  (defun set-auto-mode-1 ()  (defun set-auto-mode-1 ()

Legend:
Removed from v.1.714  
changed lines
  Added in v.1.715

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26