/[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.725 by monnier, Thu Nov 11 04:52:27 2004 UTC revision 1.726 by jurta, Thu Nov 11 21:42:32 2004 UTC
# Line 1876  with that interpreter in `interpreter-mo Line 1876  with that interpreter in `interpreter-mo
1876                  "[Hh][Tt][Mm][Ll]")) . html-mode)                  "[Hh][Tt][Mm][Ll]")) . html-mode)
1877      ;; These two must come after html, because they are more general:      ;; These two must come after html, because they are more general:
1878      ("<\\?xml " . xml-mode)      ("<\\?xml " . xml-mode)
1879      ("\\s *<\\(?:!--\\(?:.\\|\n\\)*?-->\\s *<\\)*!DOCTYPE " . sgml-mode)      (,(let* ((incomment-re "\\(?:[^-]\\|-[^-]\\)")
1880                 (comment-re (concat "\\(?:!--" incomment-re "*-->\\s *<\\)")))
1881            (concat "\\s *<" comment-re "*!DOCTYPE ")) . sgml-mode)
1882      ("%![^V]" . ps-mode)      ("%![^V]" . ps-mode)
1883      ("# xmcd " . conf-unix-mode))      ("# xmcd " . conf-unix-mode))
1884    "Alist of buffer beginnings vs. corresponding major mode functions.    "Alist of buffer beginnings vs. corresponding major mode functions.
# Line 1888  called, unless it is nil (to allow `auto Line 1890  called, unless it is nil (to allow `auto
1890    
1891  This checks for a -*- mode tag in the buffer's text, checks the  This checks for a -*- mode tag in the buffer's text, checks the
1892  interpreter that runs this file against `interpreter-mode-alist',  interpreter that runs this file against `interpreter-mode-alist',
1893  compares the buffer beginning against `magic-mode-alist',  compares the buffer beginning against `magic-mode-alist', or
1894  or compares the filename against the entries in  compares the filename against the entries in `auto-mode-alist'.
 `auto-mode-alist'.  
1895    
1896  It does not check for the `mode:' local variable in the  It does not check for the `mode:' local variable in the
1897  Local Variables section of the file; for that, use `hack-local-variables'.  Local Variables section of the file; for that, use `hack-local-variables'.
# Line 1901  If `enable-local-variables' is nil, this Line 1902  If `enable-local-variables' is nil, this
1902  If the optional argument KEEP-MODE-IF-SAME is non-nil, then we  If the optional argument KEEP-MODE-IF-SAME is non-nil, then we
1903  only set the major mode, if that would change it."  only set the major mode, if that would change it."
1904    ;; Look for -*-MODENAME-*- or -*- ... mode: MODENAME; ... -*-    ;; Look for -*-MODENAME-*- or -*- ... mode: MODENAME; ... -*-
1905    (let (end done mode modes xml)    (let (end done mode modes)
1906      ;; Find a -*- mode tag      ;; Find a -*- mode tag
1907      (save-excursion      (save-excursion
1908        (goto-char (point-min))        (goto-char (point-min))
1909        (skip-chars-forward " \t\n")        (skip-chars-forward " \t\n")
       ;; While we're at this point, check xml for later.  
       (setq xml (looking-at "<\\?xml \\|<!DOCTYPE"))  
1910        (and enable-local-variables        (and enable-local-variables
1911             (setq end (set-auto-mode-1))             (setq end (set-auto-mode-1))
1912             (if (save-excursion (search-forward ":" end t))             (if (save-excursion (search-forward ":" end t))
# Line 1951  only set the major mode, if that would c Line 1950  only set the major mode, if that would c
1950              ;; same time.              ;; same time.
1951              done (assoc (file-name-nondirectory mode)              done (assoc (file-name-nondirectory mode)
1952                          interpreter-mode-alist))                          interpreter-mode-alist))
1953          ;; If we found an interpreter mode to use, invoke it now.
1954        (if done        (if done
1955            (set-auto-mode-0 (cdr done) keep-mode-if-same)))            (set-auto-mode-0 (cdr done) keep-mode-if-same)))
1956      ;; If we found an interpreter mode to use, invoke it now.      ;; If we didn't, match the buffer beginning against magic-mode-alist.
1957      (unless done      (unless done
1958        (if (setq done (save-excursion        (if (setq done (save-excursion
1959                         (goto-char (point-min))                         (goto-char (point-min))
# Line 1961  only set the major mode, if that would c Line 1961  only set the major mode, if that would c
1961                                        (lambda (re dummy)                                        (lambda (re dummy)
1962                                          (looking-at re)))))                                          (looking-at re)))))
1963            (set-auto-mode-0 done keep-mode-if-same)            (set-auto-mode-0 done keep-mode-if-same)
1964            ;; Compare the filename against the entries in auto-mode-alist.
1965          (if buffer-file-name          (if buffer-file-name
1966              (let ((name buffer-file-name))              (let ((name buffer-file-name))
1967                ;; Remove backup-suffixes from file name.                ;; Remove backup-suffixes from file name.
# Line 1970  only set the major mode, if that would c Line 1971  only set the major mode, if that would c
1971                  (let ((case-fold-search                  (let ((case-fold-search
1972                         (memq system-type '(vax-vms windows-nt cygwin))))                         (memq system-type '(vax-vms windows-nt cygwin))))
1973                    (if (and (setq mode (assoc-default name auto-mode-alist                    (if (and (setq mode (assoc-default name auto-mode-alist
1974                                                   'string-match))                                                       'string-match))
1975                             (consp mode)                             (consp mode)
1976                             (cadr mode))                             (cadr mode))
1977                        (setq mode (car mode)                        (setq mode (car mode)
# Line 1979  only set the major mode, if that would c Line 1980  only set the major mode, if that would c
1980                  (when mode                  (when mode
1981                    (set-auto-mode-0 mode keep-mode-if-same)))))))))                    (set-auto-mode-0 mode keep-mode-if-same)))))))))
1982    
   
1983  ;; When `keep-mode-if-same' is set, we are working on behalf of  ;; When `keep-mode-if-same' is set, we are working on behalf of
1984  ;; set-visited-file-name.  In that case, if the major mode specified is the  ;; set-visited-file-name.  In that case, if the major mode specified is the
1985  ;; same one we already have, don't actually reset it.  We don't want to lose  ;; same one we already have, don't actually reset it.  We don't want to lose
# Line 1998  same, do nothing and return nil." Line 1998  same, do nothing and return nil."
1998      (funcall mode)      (funcall mode)
1999      mode))      mode))
2000    
   
2001  (defun set-auto-mode-1 ()  (defun set-auto-mode-1 ()
2002    "Find the -*- spec in the buffer.    "Find the -*- spec in the buffer.
2003  Call with point at the place to start searching from.  Call with point at the place to start searching from.

Legend:
Removed from v.1.725  
changed lines
  Added in v.1.726

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