emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/files.el


From: Daniel Pfeiffer
Subject: [Emacs-diffs] Changes to emacs/lisp/files.el
Date: Tue, 26 Oct 2004 18:16:31 -0400

Index: emacs/lisp/files.el
diff -c emacs/lisp/files.el:1.711 emacs/lisp/files.el:1.712
*** emacs/lisp/files.el:1.711   Sat Sep 25 15:29:35 2004
--- emacs/lisp/files.el Tue Oct 26 21:41:17 2004
***************
*** 1646,1685 ****
     (lambda (elt)
       (cons (purecopy (car elt)) (cdr elt)))
     '(("\\.te?xt\\'" . text-mode)
!      ("\\.tex\\'" . tex-mode)
       ("\\.ins\\'" . tex-mode)         ;Installation files for TeX packages.
       ("\\.ltx\\'" . latex-mode)
       ("\\.dtx\\'" . doctex-mode)
       ("\\.el\\'" . emacs-lisp-mode)
       ("\\.\\(scm\\|stk\\|ss\\|sch\\)\\'" . scheme-mode)
       ("\\.l\\'" . lisp-mode)
!      ("\\.lisp\\'" . lisp-mode)
!      ("\\.f\\'" . fortran-mode)
!      ("\\.F\\'" . fortran-mode)
       ("\\.for\\'" . fortran-mode)
       ("\\.p\\'" . pascal-mode)
       ("\\.pas\\'" . pascal-mode)
       ("\\.ad[abs]\\'" . ada-mode)
       ("\\.ad[bs].dg\\'" . ada-mode)
!      ("\\.\\([pP]\\([Llm]\\|erl\\)\\|al\\)\\'" . perl-mode)
       ("\\.s?html?\\'" . html-mode)
       ("\\.mk\\'" . makefile-mode)
!      ("\\(M\\|m\\|GNUm\\)akefile\\'" . makefile-mode)
       ("\\.am\\'" . makefile-mode)     ;For Automake.
       ;; Less common extensions come here
       ;; so more common ones above are found faster.
       ("\\.texinfo\\'" . texinfo-mode)
       ("\\.te?xi\\'" . texinfo-mode)
!      ("\\.s\\'" . asm-mode)
!      ("\\.S\\'" . asm-mode)
       ("\\.asm\\'" . asm-mode)
!      ("ChangeLog\\'" . change-log-mode)
!      ("change\\.log\\'" . change-log-mode)
!      ("changelo\\'" . change-log-mode)
!      ("ChangeLog\\.[0-9]+\\'" . change-log-mode)
!      ;; for MSDOS and MS-Windows (which are case-insensitive)
!      ("changelog\\'" . change-log-mode)
!      ("changelog\\.[0-9]+\\'" . change-log-mode)
       ("\\$CHANGE_LOG\\$\\.TXT" . change-log-mode)
       ("\\.scm\\.[0-9]*\\'" . scheme-mode)
       ("\\.[ck]?sh\\'\\|\\.shar\\'\\|/\\.z?profile\\'" . sh-mode)
--- 1646,1678 ----
     (lambda (elt)
       (cons (purecopy (car elt)) (cdr elt)))
     '(("\\.te?xt\\'" . text-mode)
!      ("\\.[tT]e[xX]\\'" . tex-mode)
       ("\\.ins\\'" . tex-mode)         ;Installation files for TeX packages.
       ("\\.ltx\\'" . latex-mode)
       ("\\.dtx\\'" . doctex-mode)
       ("\\.el\\'" . emacs-lisp-mode)
       ("\\.\\(scm\\|stk\\|ss\\|sch\\)\\'" . scheme-mode)
       ("\\.l\\'" . lisp-mode)
!      ("\\.li?sp\\'" . lisp-mode)
!      ("\\.[fF]\\'" . fortran-mode)
       ("\\.for\\'" . fortran-mode)
       ("\\.p\\'" . pascal-mode)
       ("\\.pas\\'" . pascal-mode)
       ("\\.ad[abs]\\'" . ada-mode)
       ("\\.ad[bs].dg\\'" . ada-mode)
!      ("\\.\\([pP]\\([Llm]\\|erl\\|od\\)\\|al\\)\\'" . perl-mode)
       ("\\.s?html?\\'" . html-mode)
       ("\\.mk\\'" . makefile-mode)
!      ("\\([Mm]\\|GNUm\\)akep*file\\'" . makefile-mode)
       ("\\.am\\'" . makefile-mode)     ;For Automake.
       ;; Less common extensions come here
       ;; so more common ones above are found faster.
       ("\\.texinfo\\'" . texinfo-mode)
       ("\\.te?xi\\'" . texinfo-mode)
!      ("\\.[sS]\\'" . asm-mode)
       ("\\.asm\\'" . asm-mode)
!      ("[cC]hange\\.?[lL]og?\\'" . change-log-mode)
!      ("[cC]hange[lL]og\\.[0-9]+\\'" . change-log-mode)
       ("\\$CHANGE_LOG\\$\\.TXT" . change-log-mode)
       ("\\.scm\\.[0-9]*\\'" . scheme-mode)
       ("\\.[ck]?sh\\'\\|\\.shar\\'\\|/\\.z?profile\\'" . sh-mode)
***************
*** 1688,1723 ****
       
("\\(/\\|\\`\\)\\.\\(bash_logout\\|shrc\\|[kz]shrc\\|bashrc\\|t?cshrc\\|esrc\\)\\'"
 . sh-mode)
       ("\\(/\\|\\`\\)\\.\\([kz]shenv\\|xinitrc\\|startxrc\\|xsession\\)\\'" . 
sh-mode)
       ("\\.m?spec\\'" . sh-mode)
!      ("\\.mm\\'" . nroff-mode)
!      ("\\.me\\'" . nroff-mode)
!      ("\\.ms\\'" . nroff-mode)
       ("\\.man\\'" . nroff-mode)
-      ("\\.TeX\\'" . tex-mode)
       ("\\.sty\\'" . latex-mode)
!      ("\\.cls\\'" . latex-mode)               ;LaTeX 2e class
!      ("\\.clo\\'" . latex-mode)               ;LaTeX 2e class option
       ("\\.bbl\\'" . latex-mode)
       ("\\.bib\\'" . bibtex-mode)
       ("\\.sql\\'" . sql-mode)
!      ("\\.m4\\'" . m4-mode)
!      ("\\.mc\\'" . m4-mode)
!      ("\\.mf\\'" . metafont-mode)
!      ("\\.mp\\'" . metapost-mode)
       ("\\.vhdl?\\'" . vhdl-mode)
       ("\\.article\\'" . text-mode)
       ("\\.letter\\'" . text-mode)
!      ("\\.tcl\\'" . tcl-mode)
       ("\\.exp\\'" . tcl-mode)
-      ("\\.itcl\\'" . tcl-mode)
       ("\\.itk\\'" . tcl-mode)
       ("\\.icn\\'" . icon-mode)
       ("\\.sim\\'" . simula-mode)
       ("\\.mss\\'" . scribe-mode)
!      ("\\.f90\\'" . f90-mode)
!      ("\\.f95\\'" . f90-mode)
       ("\\.indent\\.pro\\'" . fundamental-mode) ; to avoid idlwave-mode
       ("\\.pro\\'" . idlwave-mode)
-      ("\\.lsp\\'" . lisp-mode)
       ("\\.prolog\\'" . prolog-mode)
       ("\\.tar\\'" . tar-mode)
       ("\\.\\(arc\\|zip\\|lzh\\|zoo\\|ear\\|jar\\|war\\)\\'" . archive-mode)
--- 1681,1707 ----
       
("\\(/\\|\\`\\)\\.\\(bash_logout\\|shrc\\|[kz]shrc\\|bashrc\\|t?cshrc\\|esrc\\)\\'"
 . sh-mode)
       ("\\(/\\|\\`\\)\\.\\([kz]shenv\\|xinitrc\\|startxrc\\|xsession\\)\\'" . 
sh-mode)
       ("\\.m?spec\\'" . sh-mode)
!      ("\\.m[mes]\\'" . nroff-mode)
       ("\\.man\\'" . nroff-mode)
       ("\\.sty\\'" . latex-mode)
!      ("\\.cl[so]\\'" . latex-mode)            ;LaTeX 2e class option
       ("\\.bbl\\'" . latex-mode)
       ("\\.bib\\'" . bibtex-mode)
       ("\\.sql\\'" . sql-mode)
!      ("\\.m[4c]\\'" . m4-mode)
!      ("\\.m[fp]\\'" . metapost-mode)
       ("\\.vhdl?\\'" . vhdl-mode)
       ("\\.article\\'" . text-mode)
       ("\\.letter\\'" . text-mode)
!      ("\\.i?tcl\\'" . tcl-mode)
       ("\\.exp\\'" . tcl-mode)
       ("\\.itk\\'" . tcl-mode)
       ("\\.icn\\'" . icon-mode)
       ("\\.sim\\'" . simula-mode)
       ("\\.mss\\'" . scribe-mode)
!      ("\\.f9[05]\\'" . f90-mode)
       ("\\.indent\\.pro\\'" . fundamental-mode) ; to avoid idlwave-mode
       ("\\.pro\\'" . idlwave-mode)
       ("\\.prolog\\'" . prolog-mode)
       ("\\.tar\\'" . tar-mode)
       ("\\.\\(arc\\|zip\\|lzh\\|zoo\\|ear\\|jar\\|war\\)\\'" . archive-mode)
***************
*** 1733,1742 ****
       ("\\`/tmp/fol/" . text-mode)
       ("\\.oak\\'" . scheme-mode)
       ("\\.sgml?\\'" . sgml-mode)
!      ("\\.xml\\'" . sgml-mode)
!      ("\\.xsl\\'" . sgml-mode)
       ("\\.dtd\\'" . sgml-mode)
       ("\\.ds\\(ss\\)?l\\'" . dsssl-mode)
       ;; .emacs or .gnus or .viper following a directory delimiter in
       ;; Unix, MSDOG or VMS syntax.
       ("[]>:/\\]\\..*\\(emacs\\|gnus\\|viper\\)\\'" . emacs-lisp-mode)
--- 1717,1727 ----
       ("\\`/tmp/fol/" . text-mode)
       ("\\.oak\\'" . scheme-mode)
       ("\\.sgml?\\'" . sgml-mode)
!      ("\\.x[ms]l\\'" . xml-mode)
       ("\\.dtd\\'" . sgml-mode)
       ("\\.ds\\(ss\\)?l\\'" . dsssl-mode)
+      ("\\.js\\'" . java-mode)         ; javascript-mode would be better
+      ("\\.x[bp]m\\'" . c-mode)
       ;; .emacs or .gnus or .viper following a directory delimiter in
       ;; Unix, MSDOG or VMS syntax.
       ("[]>:/\\]\\..*\\(emacs\\|gnus\\|viper\\)\\'" . emacs-lisp-mode)
***************
*** 1760,1766 ****
       ;; or .#<file>.<rev>-<rev> or VC's <file>.~<rev>~.
       ;; Using mode nil rather than `ignore' would let the search continue
       ;; through this list (with the shortened name) rather than start over.
!      ("\\.~?[0-9]+\\.[0-9][-.0-9]*~?\\'" ignore t)
       ;; The following should come after the ChangeLog pattern
       ;; for the sake of ChangeLog.1, etc.
       ;; and after the .scm.[0-9] and CVS' <file>.<rev> patterns too.
--- 1745,1751 ----
       ;; or .#<file>.<rev>-<rev> or VC's <file>.~<rev>~.
       ;; Using mode nil rather than `ignore' would let the search continue
       ;; through this list (with the shortened name) rather than start over.
!      ("\\.~?[0-9]+\\.[0-9][-.0-9]*~?\\'" nil t)
       ;; The following should come after the ChangeLog pattern
       ;; for the sake of ChangeLog.1, etc.
       ;; and after the .scm.[0-9] and CVS' <file>.<rev> patterns too.
***************
*** 1849,1860 ****
  regular expression.  The mode is then determined as the mode associated
  with that interpreter in `interpreter-mode-alist'.")
  
  (defun set-auto-mode (&optional just-from-file-name)
    "Select major mode appropriate for current buffer.
! This checks for a -*- mode tag in the buffer's text,
! compares the filename against the entries in `auto-mode-alist',
! or checks the interpreter that runs this file against
! `interpreter-mode-alist'.
  
  It does not check for the `mode:' local variable in the
  Local Variables section of the file; for that, use `hack-local-variables'.
--- 1834,1853 ----
  regular expression.  The mode is then determined as the mode associated
  with that interpreter in `interpreter-mode-alist'.")
  
+ (defvar xml-based-modes '(html-mode)
+   "Modes that override an XML declaration.
+ When `set-auto-mode' sees an <?xml or <!DOCTYPE declaration, that
+ buffer will be in some XML mode.  If `auto-mode-alist' associates
+ the file with one of the modes in this list, that mode will be
+ used.  Else `xml-mode' or `sgml-mode' is used.")
+ 
  (defun set-auto-mode (&optional just-from-file-name)
    "Select major mode appropriate for current buffer.
! This checks for a -*- mode tag in the buffer's text, checks the
! interpreter that runs this file against `interpreter-mode-alist',
! looks for an <?xml or <!DOCTYPE declaration (see
! `xml-based-modes'), or compares the filename against the entries
! in `auto-mode-alist'.
  
  It does not check for the `mode:' local variable in the
  Local Variables section of the file; for that, use `hack-local-variables'.
***************
*** 1866,1952 ****
  then we do not set anything but the major mode,
  and we don't even do that unless it would come from the file name."
    ;; Look for -*-MODENAME-*- or -*- ... mode: MODENAME; ... -*-
!   (let (end done modes)
!     (save-excursion
!       (goto-char (point-min))
!       (skip-chars-forward " \t\n")
!       (and enable-local-variables
!          (setq end (set-auto-mode-1))
!          (if (save-excursion (search-forward ":" end t))
!              ;; Find all specifications for the `mode:' variable
!              ;; and execute them left to right.
!              (while (let ((case-fold-search t))
!                       (or (and (looking-at "mode:")
!                                (goto-char (match-end 0)))
!                           (re-search-forward "[ \t;]mode:" end t)))
!                (skip-chars-forward " \t")
!                (let ((beg (point)))
!                  (if (search-forward ";" end t)
!                      (forward-char -1)
!                    (goto-char end))
!                  (skip-chars-backward " \t")
!                  (push (intern (concat (downcase (buffer-substring beg 
(point))) "-mode"))
!                        modes)))
!            ;; Simple -*-MODE-*- case.
!            (push (intern (concat (downcase (buffer-substring (point) end))
!                                  "-mode"))
!                  modes))))
!     ;; If we found modes to use, invoke them now,
!     ;; outside the save-excursion.
      (unless just-from-file-name
!       (dolist (mode (nreverse modes))
!       (if (not (functionp mode))
!           (message "Ignoring unknown mode `%s'" mode)
!         (setq done t)
!         (funcall mode))))
!     ;; If we didn't find a mode from a -*- line, try using the file name.
      (if (and (not done) buffer-file-name)
!       (let ((name buffer-file-name)
!             (keep-going t))
          ;; Remove backup-suffixes from file name.
          (setq name (file-name-sans-versions name))
!         (while keep-going
!           (setq keep-going nil)
!           (let ((alist auto-mode-alist)
!                 (mode nil))
!             ;; Find first matching alist entry.
!             (let ((case-fold-search
!                    (memq system-type '(vax-vms windows-nt cygwin))))
!               (while (and (not mode) alist)
!                 (if (string-match (car (car alist)) name)
!                     (if (and (consp (cdr (car alist)))
!                              (nth 2 (car alist)))
!                         (setq mode (car (cdr (car alist)))
!                               name (substring name 0 (match-beginning 0))
!                               keep-going t)
!                       (setq mode (cdr (car alist))
!                             keep-going nil)))
!                 (setq alist (cdr alist))))
!             (if mode
!                 ;; When JUST-FROM-FILE-NAME is set,
!                 ;; we are working on behalf of 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 (and just-from-file-name (eq mode major-mode))
!                   (funcall mode))
!               ;; If we can't deduce a mode from the file name,
!               ;; look for an interpreter specified in the first line.
!               ;; As a special case, allow for things like "#!/bin/env perl",
!               ;; which finds the interpreter anywhere in $PATH.
!               (let ((interpreter
!                      (save-excursion
!                        (goto-char (point-min))
!                        (if (looking-at auto-mode-interpreter-regexp)
!                            (match-string 2)
!                          "")))
!                     elt)
!                 ;; Map interpreter name to a mode.
!                 (setq elt (assoc (file-name-nondirectory interpreter)
!                                  interpreter-mode-alist))
!                 (unless just-from-file-name
!                   (if elt
!                       (funcall (cdr elt))))))))))))
  
  
  (defun set-auto-mode-1 ()
--- 1859,1942 ----
  then we do not set anything but the major mode,
  and we don't even do that unless it would come from the file name."
    ;; Look for -*-MODENAME-*- or -*- ... mode: MODENAME; ... -*-
!   (let (end done mode modes xml)
      (unless just-from-file-name
!       ;; Find a -*- mode tag
!       (save-excursion
!       (goto-char (point-min))
!       (skip-chars-forward " \t\n")
!       ;; While we're at this point, check xml for later.
!       (setq xml (looking-at "<\\?xml \\|<!DOCTYPE"))
!       (and enable-local-variables
!            (setq end (set-auto-mode-1))
!            (if (save-excursion (search-forward ":" end t))
!                ;; Find all specifications for the `mode:' variable
!                ;; and execute them left to right.
!                (while (let ((case-fold-search t))
!                         (or (and (looking-at "mode:")
!                                  (goto-char (match-end 0)))
!                             (re-search-forward "[ \t;]mode:" end t)))
!                  (skip-chars-forward " \t")
!                  (let ((beg (point)))
!                    (if (search-forward ";" end t)
!                        (forward-char -1)
!                      (goto-char end))
!                    (skip-chars-backward " \t")
!                    (push (intern (concat (downcase (buffer-substring beg 
(point))) "-mode"))
!                          modes)))
!              ;; Simple -*-MODE-*- case.
!              (push (intern (concat (downcase (buffer-substring (point) end))
!                                    "-mode"))
!                    modes))))
!       ;; If we found modes to use, invoke them now, outside the 
save-excursion.
!       (if modes
!         (dolist (mode (nreverse modes))
!           (if (not (functionp mode))
!               (message "Ignoring unknown mode `%s'" mode)
!             (setq done t)
!             (funcall mode)))
!       ;; If we didn't, look for an interpreter specified in the first line.
!       ;; As a special case, allow for things like "#!/bin/env perl", which
!       ;; finds the interpreter anywhere in $PATH.
!       (setq mode (save-excursion
!                    (goto-char (point-min))
!                    (if (looking-at auto-mode-interpreter-regexp)
!                        (match-string 2)
!                      ""))
!             ;; Map interpreter name to a mode, signalling we're done at the
!             ;; same time.
!             done (assoc (file-name-nondirectory mode)
!                         interpreter-mode-alist))
!       ;; If we found an interpreter mode to use, invoke it now.
!       (if done (funcall (cdr done)))))
      (if (and (not done) buffer-file-name)
!       (let ((name buffer-file-name))
          ;; Remove backup-suffixes from file name.
          (setq name (file-name-sans-versions name))
!         (while (not done)
!           ;; Find first matching alist entry.
!           (let ((case-fold-search
!                  (memq system-type '(vax-vms windows-nt cygwin))))
!             (if (and (setq mode (assoc-default name auto-mode-alist
!                                                'string-match))
!                      (consp mode)
!                      (cadr mode))
!                 (setq mode (car mode)
!                       name (substring name 0 (match-beginning 0)))
!               (setq done t)))
!           (if mode
!               ;; When JUST-FROM-FILE-NAME is set, we are working on behalf
!               ;; of 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 (and just-from-file-name (eq mode major-mode))
!                 (if (if xml (memq mode xml-based-modes) t)
!                     (funcall mode)
!                   (xml-mode)))))))
!     (and (not done)
!        xml
!        (xml-mode))))
  
  
  (defun set-auto-mode-1 ()
***************
*** 2157,2163 ****
                        (error "Local variables entry is missing the suffix")))
                  (forward-line 1))
                (goto-char (point-min))
!                 
                (while (not (eobp))
                  ;; Find the variable name; strip whitespace.
                  (skip-chars-forward " \t")
--- 2147,2153 ----
                        (error "Local variables entry is missing the suffix")))
                  (forward-line 1))
                (goto-char (point-min))
! 
                (while (not (eobp))
                  ;; Find the variable name; strip whitespace.
                  (skip-chars-forward " \t")




reply via email to

[Prev in Thread] Current Thread [Next in Thread]