diff options
| author | Daniel Pfeiffer | 2004-10-26 21:44:20 +0000 |
|---|---|---|
| committer | Daniel Pfeiffer | 2004-10-26 21:44:20 +0000 |
| commit | bbc67516227ac13bf1988b8a51e69bac7461e2fb (patch) | |
| tree | 417d1e72c52b5339d0a67f2333ecbcd45309e87f | |
| parent | 71796940395596955d99bf4fa385aeaebd7d6138 (diff) | |
| download | emacs-bbc67516227ac13bf1988b8a51e69bac7461e2fb.tar.gz emacs-bbc67516227ac13bf1988b8a51e69bac7461e2fb.zip | |
(auto-mode-alist): Add pod, js, xbm and xpm and group trivial variants to shorten the list.
(xml-based-modes): New var.
(set-auto-mode): Give interpreter-mode-alist or <?xml or <!DOCTYPE declaration higher priority than auto-mode-alist.
| -rw-r--r-- | lisp/ChangeLog | 22 | ||||
| -rw-r--r-- | lisp/files.el | 220 |
2 files changed, 124 insertions, 118 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5fae5de22db..bc2223cddb2 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | 2004-10-26 Daniel Pfeiffer <occitan@esperanto.org> | ||
| 2 | |||
| 3 | * files.el (auto-mode-alist): Add pod, js, xbm and xpm and group | ||
| 4 | trivial variants to shorten the list. | ||
| 5 | (xml-based-modes): New var. | ||
| 6 | (set-auto-mode): Give interpreter-mode-alist or <?xml or <!DOCTYPE | ||
| 7 | declaration higher priority than auto-mode-alist. | ||
| 8 | |||
| 9 | * find-file.el (cc-other-file-alist): Bring it in line with | ||
| 10 | cc-mode's auto-mode-alist entries and use \' instead of $. | ||
| 11 | |||
| 12 | * textmodes/sgml-mode.el (sgml-mode): Fix imenu-generic-expression | ||
| 13 | and add "Id" and "Name" submenus to it. | ||
| 14 | |||
| 15 | * imenu.el (imenu--generic-function): Skip matches in comments. | ||
| 16 | |||
| 1 | 2004-10-26 Jay Belanger <belanger@truman.edu> | 17 | 2004-10-26 Jay Belanger <belanger@truman.edu> |
| 2 | 18 | ||
| 3 | * calc/calc.el (calc,full-calc, calc-quit, calc-keypad) | 19 | * calc/calc.el (calc,full-calc, calc-quit, calc-keypad) |
| @@ -5,10 +21,10 @@ | |||
| 5 | instead of `interactive-p'. | 21 | instead of `interactive-p'. |
| 6 | 22 | ||
| 7 | * calc/calc-misc.el (calc-other-window): Use an extra argument | 23 | * calc/calc-misc.el (calc-other-window): Use an extra argument |
| 8 | instead of `interactive-p'. | 24 | instead of `interactive-p'. |
| 9 | 25 | ||
| 10 | * calc/calc-rewr.el (calc-match): Use an extra argument instead of | 26 | * calc/calc-rewr.el (calc-match): Use an extra argument instead of |
| 11 | `interactive-p'. | 27 | `interactive-p'. |
| 12 | 28 | ||
| 13 | 2004-10-26 Kim F. Storm <storm@cua.dk> | 29 | 2004-10-26 Kim F. Storm <storm@cua.dk> |
| 14 | 30 | ||
diff --git a/lisp/files.el b/lisp/files.el index ee6793bec71..d14c4625352 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -1646,40 +1646,33 @@ in that case, this function acts as if `enable-local-variables' were t." | |||
| 1646 | (lambda (elt) | 1646 | (lambda (elt) |
| 1647 | (cons (purecopy (car elt)) (cdr elt))) | 1647 | (cons (purecopy (car elt)) (cdr elt))) |
| 1648 | '(("\\.te?xt\\'" . text-mode) | 1648 | '(("\\.te?xt\\'" . text-mode) |
| 1649 | ("\\.tex\\'" . tex-mode) | 1649 | ("\\.[tT]e[xX]\\'" . tex-mode) |
| 1650 | ("\\.ins\\'" . tex-mode) ;Installation files for TeX packages. | 1650 | ("\\.ins\\'" . tex-mode) ;Installation files for TeX packages. |
| 1651 | ("\\.ltx\\'" . latex-mode) | 1651 | ("\\.ltx\\'" . latex-mode) |
| 1652 | ("\\.dtx\\'" . doctex-mode) | 1652 | ("\\.dtx\\'" . doctex-mode) |
| 1653 | ("\\.el\\'" . emacs-lisp-mode) | 1653 | ("\\.el\\'" . emacs-lisp-mode) |
| 1654 | ("\\.\\(scm\\|stk\\|ss\\|sch\\)\\'" . scheme-mode) | 1654 | ("\\.\\(scm\\|stk\\|ss\\|sch\\)\\'" . scheme-mode) |
| 1655 | ("\\.l\\'" . lisp-mode) | 1655 | ("\\.l\\'" . lisp-mode) |
| 1656 | ("\\.lisp\\'" . lisp-mode) | 1656 | ("\\.li?sp\\'" . lisp-mode) |
| 1657 | ("\\.f\\'" . fortran-mode) | 1657 | ("\\.[fF]\\'" . fortran-mode) |
| 1658 | ("\\.F\\'" . fortran-mode) | ||
| 1659 | ("\\.for\\'" . fortran-mode) | 1658 | ("\\.for\\'" . fortran-mode) |
| 1660 | ("\\.p\\'" . pascal-mode) | 1659 | ("\\.p\\'" . pascal-mode) |
| 1661 | ("\\.pas\\'" . pascal-mode) | 1660 | ("\\.pas\\'" . pascal-mode) |
| 1662 | ("\\.ad[abs]\\'" . ada-mode) | 1661 | ("\\.ad[abs]\\'" . ada-mode) |
| 1663 | ("\\.ad[bs].dg\\'" . ada-mode) | 1662 | ("\\.ad[bs].dg\\'" . ada-mode) |
| 1664 | ("\\.\\([pP]\\([Llm]\\|erl\\)\\|al\\)\\'" . perl-mode) | 1663 | ("\\.\\([pP]\\([Llm]\\|erl\\|od\\)\\|al\\)\\'" . perl-mode) |
| 1665 | ("\\.s?html?\\'" . html-mode) | 1664 | ("\\.s?html?\\'" . html-mode) |
| 1666 | ("\\.mk\\'" . makefile-mode) | 1665 | ("\\.mk\\'" . makefile-mode) |
| 1667 | ("\\(M\\|m\\|GNUm\\)akefile\\'" . makefile-mode) | 1666 | ("\\([Mm]\\|GNUm\\)akep*file\\'" . makefile-mode) |
| 1668 | ("\\.am\\'" . makefile-mode) ;For Automake. | 1667 | ("\\.am\\'" . makefile-mode) ;For Automake. |
| 1669 | ;; Less common extensions come here | 1668 | ;; Less common extensions come here |
| 1670 | ;; so more common ones above are found faster. | 1669 | ;; so more common ones above are found faster. |
| 1671 | ("\\.texinfo\\'" . texinfo-mode) | 1670 | ("\\.texinfo\\'" . texinfo-mode) |
| 1672 | ("\\.te?xi\\'" . texinfo-mode) | 1671 | ("\\.te?xi\\'" . texinfo-mode) |
| 1673 | ("\\.s\\'" . asm-mode) | 1672 | ("\\.[sS]\\'" . asm-mode) |
| 1674 | ("\\.S\\'" . asm-mode) | ||
| 1675 | ("\\.asm\\'" . asm-mode) | 1673 | ("\\.asm\\'" . asm-mode) |
| 1676 | ("ChangeLog\\'" . change-log-mode) | 1674 | ("[cC]hange\\.?[lL]og?\\'" . change-log-mode) |
| 1677 | ("change\\.log\\'" . change-log-mode) | 1675 | ("[cC]hange[lL]og\\.[0-9]+\\'" . change-log-mode) |
| 1678 | ("changelo\\'" . change-log-mode) | ||
| 1679 | ("ChangeLog\\.[0-9]+\\'" . change-log-mode) | ||
| 1680 | ;; for MSDOS and MS-Windows (which are case-insensitive) | ||
| 1681 | ("changelog\\'" . change-log-mode) | ||
| 1682 | ("changelog\\.[0-9]+\\'" . change-log-mode) | ||
| 1683 | ("\\$CHANGE_LOG\\$\\.TXT" . change-log-mode) | 1676 | ("\\$CHANGE_LOG\\$\\.TXT" . change-log-mode) |
| 1684 | ("\\.scm\\.[0-9]*\\'" . scheme-mode) | 1677 | ("\\.scm\\.[0-9]*\\'" . scheme-mode) |
| 1685 | ("\\.[ck]?sh\\'\\|\\.shar\\'\\|/\\.z?profile\\'" . sh-mode) | 1678 | ("\\.[ck]?sh\\'\\|\\.shar\\'\\|/\\.z?profile\\'" . sh-mode) |
| @@ -1688,36 +1681,27 @@ in that case, this function acts as if `enable-local-variables' were t." | |||
| 1688 | ("\\(/\\|\\`\\)\\.\\(bash_logout\\|shrc\\|[kz]shrc\\|bashrc\\|t?cshrc\\|esrc\\)\\'" . sh-mode) | 1681 | ("\\(/\\|\\`\\)\\.\\(bash_logout\\|shrc\\|[kz]shrc\\|bashrc\\|t?cshrc\\|esrc\\)\\'" . sh-mode) |
| 1689 | ("\\(/\\|\\`\\)\\.\\([kz]shenv\\|xinitrc\\|startxrc\\|xsession\\)\\'" . sh-mode) | 1682 | ("\\(/\\|\\`\\)\\.\\([kz]shenv\\|xinitrc\\|startxrc\\|xsession\\)\\'" . sh-mode) |
| 1690 | ("\\.m?spec\\'" . sh-mode) | 1683 | ("\\.m?spec\\'" . sh-mode) |
| 1691 | ("\\.mm\\'" . nroff-mode) | 1684 | ("\\.m[mes]\\'" . nroff-mode) |
| 1692 | ("\\.me\\'" . nroff-mode) | ||
| 1693 | ("\\.ms\\'" . nroff-mode) | ||
| 1694 | ("\\.man\\'" . nroff-mode) | 1685 | ("\\.man\\'" . nroff-mode) |
| 1695 | ("\\.TeX\\'" . tex-mode) | ||
| 1696 | ("\\.sty\\'" . latex-mode) | 1686 | ("\\.sty\\'" . latex-mode) |
| 1697 | ("\\.cls\\'" . latex-mode) ;LaTeX 2e class | 1687 | ("\\.cl[so]\\'" . latex-mode) ;LaTeX 2e class option |
| 1698 | ("\\.clo\\'" . latex-mode) ;LaTeX 2e class option | ||
| 1699 | ("\\.bbl\\'" . latex-mode) | 1688 | ("\\.bbl\\'" . latex-mode) |
| 1700 | ("\\.bib\\'" . bibtex-mode) | 1689 | ("\\.bib\\'" . bibtex-mode) |
| 1701 | ("\\.sql\\'" . sql-mode) | 1690 | ("\\.sql\\'" . sql-mode) |
| 1702 | ("\\.m4\\'" . m4-mode) | 1691 | ("\\.m[4c]\\'" . m4-mode) |
| 1703 | ("\\.mc\\'" . m4-mode) | 1692 | ("\\.m[fp]\\'" . metapost-mode) |
| 1704 | ("\\.mf\\'" . metafont-mode) | ||
| 1705 | ("\\.mp\\'" . metapost-mode) | ||
| 1706 | ("\\.vhdl?\\'" . vhdl-mode) | 1693 | ("\\.vhdl?\\'" . vhdl-mode) |
| 1707 | ("\\.article\\'" . text-mode) | 1694 | ("\\.article\\'" . text-mode) |
| 1708 | ("\\.letter\\'" . text-mode) | 1695 | ("\\.letter\\'" . text-mode) |
| 1709 | ("\\.tcl\\'" . tcl-mode) | 1696 | ("\\.i?tcl\\'" . tcl-mode) |
| 1710 | ("\\.exp\\'" . tcl-mode) | 1697 | ("\\.exp\\'" . tcl-mode) |
| 1711 | ("\\.itcl\\'" . tcl-mode) | ||
| 1712 | ("\\.itk\\'" . tcl-mode) | 1698 | ("\\.itk\\'" . tcl-mode) |
| 1713 | ("\\.icn\\'" . icon-mode) | 1699 | ("\\.icn\\'" . icon-mode) |
| 1714 | ("\\.sim\\'" . simula-mode) | 1700 | ("\\.sim\\'" . simula-mode) |
| 1715 | ("\\.mss\\'" . scribe-mode) | 1701 | ("\\.mss\\'" . scribe-mode) |
| 1716 | ("\\.f90\\'" . f90-mode) | 1702 | ("\\.f9[05]\\'" . f90-mode) |
| 1717 | ("\\.f95\\'" . f90-mode) | ||
| 1718 | ("\\.indent\\.pro\\'" . fundamental-mode) ; to avoid idlwave-mode | 1703 | ("\\.indent\\.pro\\'" . fundamental-mode) ; to avoid idlwave-mode |
| 1719 | ("\\.pro\\'" . idlwave-mode) | 1704 | ("\\.pro\\'" . idlwave-mode) |
| 1720 | ("\\.lsp\\'" . lisp-mode) | ||
| 1721 | ("\\.prolog\\'" . prolog-mode) | 1705 | ("\\.prolog\\'" . prolog-mode) |
| 1722 | ("\\.tar\\'" . tar-mode) | 1706 | ("\\.tar\\'" . tar-mode) |
| 1723 | ("\\.\\(arc\\|zip\\|lzh\\|zoo\\|ear\\|jar\\|war\\)\\'" . archive-mode) | 1707 | ("\\.\\(arc\\|zip\\|lzh\\|zoo\\|ear\\|jar\\|war\\)\\'" . archive-mode) |
| @@ -1733,10 +1717,11 @@ in that case, this function acts as if `enable-local-variables' were t." | |||
| 1733 | ("\\`/tmp/fol/" . text-mode) | 1717 | ("\\`/tmp/fol/" . text-mode) |
| 1734 | ("\\.oak\\'" . scheme-mode) | 1718 | ("\\.oak\\'" . scheme-mode) |
| 1735 | ("\\.sgml?\\'" . sgml-mode) | 1719 | ("\\.sgml?\\'" . sgml-mode) |
| 1736 | ("\\.xml\\'" . sgml-mode) | 1720 | ("\\.x[ms]l\\'" . xml-mode) |
| 1737 | ("\\.xsl\\'" . sgml-mode) | ||
| 1738 | ("\\.dtd\\'" . sgml-mode) | 1721 | ("\\.dtd\\'" . sgml-mode) |
| 1739 | ("\\.ds\\(ss\\)?l\\'" . dsssl-mode) | 1722 | ("\\.ds\\(ss\\)?l\\'" . dsssl-mode) |
| 1723 | ("\\.js\\'" . java-mode) ; javascript-mode would be better | ||
| 1724 | ("\\.x[bp]m\\'" . c-mode) | ||
| 1740 | ;; .emacs or .gnus or .viper following a directory delimiter in | 1725 | ;; .emacs or .gnus or .viper following a directory delimiter in |
| 1741 | ;; Unix, MSDOG or VMS syntax. | 1726 | ;; Unix, MSDOG or VMS syntax. |
| 1742 | ("[]>:/\\]\\..*\\(emacs\\|gnus\\|viper\\)\\'" . emacs-lisp-mode) | 1727 | ("[]>:/\\]\\..*\\(emacs\\|gnus\\|viper\\)\\'" . emacs-lisp-mode) |
| @@ -1760,7 +1745,7 @@ in that case, this function acts as if `enable-local-variables' were t." | |||
| 1760 | ;; or .#<file>.<rev>-<rev> or VC's <file>.~<rev>~. | 1745 | ;; or .#<file>.<rev>-<rev> or VC's <file>.~<rev>~. |
| 1761 | ;; Using mode nil rather than `ignore' would let the search continue | 1746 | ;; Using mode nil rather than `ignore' would let the search continue |
| 1762 | ;; through this list (with the shortened name) rather than start over. | 1747 | ;; through this list (with the shortened name) rather than start over. |
| 1763 | ("\\.~?[0-9]+\\.[0-9][-.0-9]*~?\\'" ignore t) | 1748 | ("\\.~?[0-9]+\\.[0-9][-.0-9]*~?\\'" nil t) |
| 1764 | ;; The following should come after the ChangeLog pattern | 1749 | ;; The following should come after the ChangeLog pattern |
| 1765 | ;; for the sake of ChangeLog.1, etc. | 1750 | ;; for the sake of ChangeLog.1, etc. |
| 1766 | ;; and after the .scm.[0-9] and CVS' <file>.<rev> patterns too. | 1751 | ;; and after the .scm.[0-9] and CVS' <file>.<rev> patterns too. |
| @@ -1849,12 +1834,20 @@ be interpreted by the interpreter matched by the second group of the | |||
| 1849 | regular expression. The mode is then determined as the mode associated | 1834 | regular expression. The mode is then determined as the mode associated |
| 1850 | with that interpreter in `interpreter-mode-alist'.") | 1835 | with that interpreter in `interpreter-mode-alist'.") |
| 1851 | 1836 | ||
| 1837 | (defvar xml-based-modes '(html-mode) | ||
| 1838 | "Modes that override an XML declaration. | ||
| 1839 | When `set-auto-mode' sees an <?xml or <!DOCTYPE declaration, that | ||
| 1840 | buffer will be in some XML mode. If `auto-mode-alist' associates | ||
| 1841 | the file with one of the modes in this list, that mode will be | ||
| 1842 | used. Else `xml-mode' or `sgml-mode' is used.") | ||
| 1843 | |||
| 1852 | (defun set-auto-mode (&optional just-from-file-name) | 1844 | (defun set-auto-mode (&optional just-from-file-name) |
| 1853 | "Select major mode appropriate for current buffer. | 1845 | "Select major mode appropriate for current buffer. |
| 1854 | This checks for a -*- mode tag in the buffer's text, | 1846 | This checks for a -*- mode tag in the buffer's text, checks the |
| 1855 | compares the filename against the entries in `auto-mode-alist', | 1847 | interpreter that runs this file against `interpreter-mode-alist', |
| 1856 | or checks the interpreter that runs this file against | 1848 | looks for an <?xml or <!DOCTYPE declaration (see |
| 1857 | `interpreter-mode-alist'. | 1849 | `xml-based-modes'), or compares the filename against the entries |
| 1850 | in `auto-mode-alist'. | ||
| 1858 | 1851 | ||
| 1859 | It does not check for the `mode:' local variable in the | 1852 | It does not check for the `mode:' local variable in the |
| 1860 | Local Variables section of the file; for that, use `hack-local-variables'. | 1853 | Local Variables section of the file; for that, use `hack-local-variables'. |
| @@ -1866,87 +1859,84 @@ If the optional argument JUST-FROM-FILE-NAME is non-nil, | |||
| 1866 | then we do not set anything but the major mode, | 1859 | then we do not set anything but the major mode, |
| 1867 | and we don't even do that unless it would come from the file name." | 1860 | and we don't even do that unless it would come from the file name." |
| 1868 | ;; Look for -*-MODENAME-*- or -*- ... mode: MODENAME; ... -*- | 1861 | ;; Look for -*-MODENAME-*- or -*- ... mode: MODENAME; ... -*- |
| 1869 | (let (end done modes) | 1862 | (let (end done mode modes xml) |
| 1870 | (save-excursion | ||
| 1871 | (goto-char (point-min)) | ||
| 1872 | (skip-chars-forward " \t\n") | ||
| 1873 | (and enable-local-variables | ||
| 1874 | (setq end (set-auto-mode-1)) | ||
| 1875 | (if (save-excursion (search-forward ":" end t)) | ||
| 1876 | ;; Find all specifications for the `mode:' variable | ||
| 1877 | ;; and execute them left to right. | ||
| 1878 | (while (let ((case-fold-search t)) | ||
| 1879 | (or (and (looking-at "mode:") | ||
| 1880 | (goto-char (match-end 0))) | ||
| 1881 | (re-search-forward "[ \t;]mode:" end t))) | ||
| 1882 | (skip-chars-forward " \t") | ||
| 1883 | (let ((beg (point))) | ||
| 1884 | (if (search-forward ";" end t) | ||
| 1885 | (forward-char -1) | ||
| 1886 | (goto-char end)) | ||
| 1887 | (skip-chars-backward " \t") | ||
| 1888 | (push (intern (concat (downcase (buffer-substring beg (point))) "-mode")) | ||
| 1889 | modes))) | ||
| 1890 | ;; Simple -*-MODE-*- case. | ||
| 1891 | (push (intern (concat (downcase (buffer-substring (point) end)) | ||
| 1892 | "-mode")) | ||
| 1893 | modes)))) | ||
| 1894 | ;; If we found modes to use, invoke them now, | ||
| 1895 | ;; outside the save-excursion. | ||
| 1896 | (unless just-from-file-name | 1863 | (unless just-from-file-name |
| 1897 | (dolist (mode (nreverse modes)) | 1864 | ;; Find a -*- mode tag |
| 1898 | (if (not (functionp mode)) | 1865 | (save-excursion |
| 1899 | (message "Ignoring unknown mode `%s'" mode) | 1866 | (goto-char (point-min)) |
| 1900 | (setq done t) | 1867 | (skip-chars-forward " \t\n") |
| 1901 | (funcall mode)))) | 1868 | ;; While we're at this point, check xml for later. |
| 1902 | ;; If we didn't find a mode from a -*- line, try using the file name. | 1869 | (setq xml (looking-at "<\\?xml \\|<!DOCTYPE")) |
| 1870 | (and enable-local-variables | ||
| 1871 | (setq end (set-auto-mode-1)) | ||
| 1872 | (if (save-excursion (search-forward ":" end t)) | ||
| 1873 | ;; Find all specifications for the `mode:' variable | ||
| 1874 | ;; and execute them left to right. | ||
| 1875 | (while (let ((case-fold-search t)) | ||
| 1876 | (or (and (looking-at "mode:") | ||
| 1877 | (goto-char (match-end 0))) | ||
| 1878 | (re-search-forward "[ \t;]mode:" end t))) | ||
| 1879 | (skip-chars-forward " \t") | ||
| 1880 | (let ((beg (point))) | ||
| 1881 | (if (search-forward ";" end t) | ||
| 1882 | (forward-char -1) | ||
| 1883 | (goto-char end)) | ||
| 1884 | (skip-chars-backward " \t") | ||
| 1885 | (push (intern (concat (downcase (buffer-substring beg (point))) "-mode")) | ||
| 1886 | modes))) | ||
| 1887 | ;; Simple -*-MODE-*- case. | ||
| 1888 | (push (intern (concat (downcase (buffer-substring (point) end)) | ||
| 1889 | "-mode")) | ||
| 1890 | modes)))) | ||
| 1891 | ;; If we found modes to use, invoke them now, outside the save-excursion. | ||
| 1892 | (if modes | ||
| 1893 | (dolist (mode (nreverse modes)) | ||
| 1894 | (if (not (functionp mode)) | ||
| 1895 | (message "Ignoring unknown mode `%s'" mode) | ||
| 1896 | (setq done t) | ||
| 1897 | (funcall mode))) | ||
| 1898 | ;; If we didn't, look for an interpreter specified in the first line. | ||
| 1899 | ;; As a special case, allow for things like "#!/bin/env perl", which | ||
| 1900 | ;; finds the interpreter anywhere in $PATH. | ||
| 1901 | (setq mode (save-excursion | ||
| 1902 | (goto-char (point-min)) | ||
| 1903 | (if (looking-at auto-mode-interpreter-regexp) | ||
| 1904 | (match-string 2) | ||
| 1905 | "")) | ||
| 1906 | ;; Map interpreter name to a mode, signalling we're done at the | ||
| 1907 | ;; same time. | ||
| 1908 | done (assoc (file-name-nondirectory mode) | ||
| 1909 | interpreter-mode-alist)) | ||
| 1910 | ;; If we found an interpreter mode to use, invoke it now. | ||
| 1911 | (if done (funcall (cdr done))))) | ||
| 1903 | (if (and (not done) buffer-file-name) | 1912 | (if (and (not done) buffer-file-name) |
| 1904 | (let ((name buffer-file-name) | 1913 | (let ((name buffer-file-name)) |
| 1905 | (keep-going t)) | ||
| 1906 | ;; Remove backup-suffixes from file name. | 1914 | ;; Remove backup-suffixes from file name. |
| 1907 | (setq name (file-name-sans-versions name)) | 1915 | (setq name (file-name-sans-versions name)) |
| 1908 | (while keep-going | 1916 | (while (not done) |
| 1909 | (setq keep-going nil) | 1917 | ;; Find first matching alist entry. |
| 1910 | (let ((alist auto-mode-alist) | 1918 | (let ((case-fold-search |
| 1911 | (mode nil)) | 1919 | (memq system-type '(vax-vms windows-nt cygwin)))) |
| 1912 | ;; Find first matching alist entry. | 1920 | (if (and (setq mode (assoc-default name auto-mode-alist |
| 1913 | (let ((case-fold-search | 1921 | 'string-match)) |
| 1914 | (memq system-type '(vax-vms windows-nt cygwin)))) | 1922 | (consp mode) |
| 1915 | (while (and (not mode) alist) | 1923 | (cadr mode)) |
| 1916 | (if (string-match (car (car alist)) name) | 1924 | (setq mode (car mode) |
| 1917 | (if (and (consp (cdr (car alist))) | 1925 | name (substring name 0 (match-beginning 0))) |
| 1918 | (nth 2 (car alist))) | 1926 | (setq done t))) |
| 1919 | (setq mode (car (cdr (car alist))) | 1927 | (if mode |
| 1920 | name (substring name 0 (match-beginning 0)) | 1928 | ;; When JUST-FROM-FILE-NAME is set, we are working on behalf |
| 1921 | keep-going t) | 1929 | ;; of set-visited-file-name. In that case, if the major mode |
| 1922 | (setq mode (cdr (car alist)) | 1930 | ;; specified is the same one we already have, don't actually |
| 1923 | keep-going nil))) | 1931 | ;; reset it. We don't want to lose minor modes such as Font |
| 1924 | (setq alist (cdr alist)))) | 1932 | ;; Lock. |
| 1925 | (if mode | 1933 | (unless (and just-from-file-name (eq mode major-mode)) |
| 1926 | ;; When JUST-FROM-FILE-NAME is set, | 1934 | (if (if xml (memq mode xml-based-modes) t) |
| 1927 | ;; we are working on behalf of set-visited-file-name. | 1935 | (funcall mode) |
| 1928 | ;; In that case, if the major mode specified is the | 1936 | (xml-mode))))))) |
| 1929 | ;; same one we already have, don't actually reset it. | 1937 | (and (not done) |
| 1930 | ;; We don't want to lose minor modes such as Font Lock. | 1938 | xml |
| 1931 | (unless (and just-from-file-name (eq mode major-mode)) | 1939 | (xml-mode)))) |
| 1932 | (funcall mode)) | ||
| 1933 | ;; If we can't deduce a mode from the file name, | ||
| 1934 | ;; look for an interpreter specified in the first line. | ||
| 1935 | ;; As a special case, allow for things like "#!/bin/env perl", | ||
| 1936 | ;; which finds the interpreter anywhere in $PATH. | ||
| 1937 | (let ((interpreter | ||
| 1938 | (save-excursion | ||
| 1939 | (goto-char (point-min)) | ||
| 1940 | (if (looking-at auto-mode-interpreter-regexp) | ||
| 1941 | (match-string 2) | ||
| 1942 | ""))) | ||
| 1943 | elt) | ||
| 1944 | ;; Map interpreter name to a mode. | ||
| 1945 | (setq elt (assoc (file-name-nondirectory interpreter) | ||
| 1946 | interpreter-mode-alist)) | ||
| 1947 | (unless just-from-file-name | ||
| 1948 | (if elt | ||
| 1949 | (funcall (cdr elt)))))))))))) | ||
| 1950 | 1940 | ||
| 1951 | 1941 | ||
| 1952 | (defun set-auto-mode-1 () | 1942 | (defun set-auto-mode-1 () |
| @@ -2157,7 +2147,7 @@ is specified, returning t if it is specified." | |||
| 2157 | (error "Local variables entry is missing the suffix"))) | 2147 | (error "Local variables entry is missing the suffix"))) |
| 2158 | (forward-line 1)) | 2148 | (forward-line 1)) |
| 2159 | (goto-char (point-min)) | 2149 | (goto-char (point-min)) |
| 2160 | 2150 | ||
| 2161 | (while (not (eobp)) | 2151 | (while (not (eobp)) |
| 2162 | ;; Find the variable name; strip whitespace. | 2152 | ;; Find the variable name; strip whitespace. |
| 2163 | (skip-chars-forward " \t") | 2153 | (skip-chars-forward " \t") |