Next: Text Mode, Previous: Minor Modes, Up: Modes [Index]
When you visit a file, Emacs chooses a major mode automatically. Normally, it makes the choice based on the file name. Sometimes it chooses the major mode based on special text in the file. This special text can also be used to enable buffer-local minor modes.
eval specifications.
interpreter-mode-alist specifies the correspondence between
interpreter program names and major modes.
magic-mode-alist.
auto-mode-alist.
magic-fallback-mode-alist.
auto-mode-alist.
interpreter-mode-alistAlist mapping interpreter names to major modes.
See also auto-mode-alist.
auto-mode-alistAlist of filename patterns vs corresponding major mode functions.
Each element looks like
(REGEXP . FUNCTION)
or
(REGEXP FUNCTION NON-NIL).
(‘NON-NIL’ stands for anything that is not ‘nil’; the value does not matter.)
Visiting a file whose name matches ‘REGEXP’ specifies ‘FUNCTION’ as the mode function to use. ‘FUNCTION’ will be called, unless it is ‘nil’.
If the element has the form
(REGEXP FUNCTION NON-NIL)
then after calling ‘FUNCTION’ (if it’s not nil), we delete the suffix that matched ‘REGEXP’ and search the list again for another match.
See also magic-mode-alist.
magic-mode-alistAlist of buffer beginnings vs. corresponding major mode functions. Each element looks like
(REGEXP . FUNCTION)
or
(MATCH-FUNCTION . FUNCTION).
After visiting a file, if ‘REGEXP’ matches the text at the beginning of
the buffer (case-sensitively), or calling ‘MATCH-FUNCTION’ returns
non-‘nil’, ‘normal-mode’ will call ‘FUNCTION’ rather than allowing
auto-mode-alist to decide the buffer’s major mode.
If ‘FUNCTION’ is ‘nil’, then it is not called. (That is a way of saying "allow ‘auto-mode-alist’ to decide for these files.")
It’s default value is ‘nil’.
magic-fallback-mode-alistLike ‘magic-mode-alist’ but has lower priority than auto-mode-alist.
Next: Text Mode, Previous: Minor Modes, Up: Modes [Index]