diff options
author | Tom Tromey <tom@tromey.com> | 2021-07-23 15:51:11 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2021-07-23 15:51:11 +0200 |
commit | ad5faa424a5d2f0d67265906d21f7af98220df26 (patch) | |
tree | 87d76eb9e3ead110b7057ecdcfdc79ae85fcdc3e /doc/emacs/modes.texi | |
parent | 6a3b89f9df85d0718e55d460164ff65e7bdd823e (diff) | |
download | emacs-ad5faa424a5d2f0d67265906d21f7af98220df26.tar.gz |
Add auto-mode-alist functionality to .dir-locals.el
* doc/emacs/custom.texi (Directory Variables): Document
auto-mode-alist in .dir-locals.el (Bug#18721)
* doc/emacs/modes.texi (Choosing Modes): Update.
* lisp/files.el (set-auto-mode--apply-alist): New function,
from set-auto-mode.
(set-auto-mode): Check directory locals for auto-mode-alist.
(dir-locals-collect-variables): Add "predicate" parameter.
(hack-dir-local--get-variables): New function, from
hack-dir-local-variables.
(hack-dir-local-variables): Call hack-dir-local--get-variables.
* test/lisp/files-resources/.dir-locals.el: New file.
* test/lisp/files-resources/whatever.quux: New file.
* test/lisp/files-tests.el (files-tests-data-dir): New variable.
(files-test-dir-locals-auto-mode-alist): New test.
Diffstat (limited to 'doc/emacs/modes.texi')
-rw-r--r-- | doc/emacs/modes.texi | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/doc/emacs/modes.texi b/doc/emacs/modes.texi index cc25d3e1e33..9014221edff 100644 --- a/doc/emacs/modes.texi +++ b/doc/emacs/modes.texi @@ -357,8 +357,12 @@ preferences. If you personally want to use a minor mode for a particular file type, it is better to enable the minor mode via a major mode hook (@pxref{Major Modes}). + Second, Emacs checks whether the file's extension matches an entry +in any directory-local @code{auto-mode-alist}. These are found using +the @file{.dir-locals.el} facility (@pxref{Directory Variables}). + @vindex interpreter-mode-alist - Second, if there is no file variable specifying a major mode, Emacs + Third, if there is no file variable specifying a major mode, Emacs checks whether the file's contents begin with @samp{#!}. If so, that indicates that the file can serve as an executable shell command, which works by running an interpreter named on the file's first line @@ -376,7 +380,7 @@ same is true for man pages which start with the magic string @samp{'\"} to specify a list of troff preprocessors. @vindex magic-mode-alist - Third, Emacs tries to determine the major mode by looking at the + Fourth, Emacs tries to determine the major mode by looking at the text at the start of the buffer, based on the variable @code{magic-mode-alist}. By default, this variable is @code{nil} (an empty list), so Emacs skips this step; however, you can customize it @@ -404,7 +408,7 @@ where @var{match-function} is a Lisp function that is called at the beginning of the buffer; if the function returns non-@code{nil}, Emacs set the major mode with @var{mode-function}. - Fourth---if Emacs still hasn't found a suitable major mode---it + Fifth---if Emacs still hasn't found a suitable major mode---it looks at the file's name. The correspondence between file names and major modes is controlled by the variable @code{auto-mode-alist}. Its value is a list in which each element has this form, |