92 |
@code{(@t{"\\.c\\'"} . c-mode)}, and it is responsible for selecting C |
@code{(@t{"\\.c\\'"} . c-mode)}, and it is responsible for selecting C |
93 |
mode for files whose names end in @file{.c}. (Note that @samp{\\} is |
mode for files whose names end in @file{.c}. (Note that @samp{\\} is |
94 |
needed in Lisp syntax to include a @samp{\} in the string, which must |
needed in Lisp syntax to include a @samp{\} in the string, which must |
95 |
be used to suppress the special meaning of @samp{.} in regexps.) If the |
be used to suppress the special meaning of @samp{.} in regexps.) If |
96 |
element has the form @code{(@var{regexp} @var{mode-function} |
the element has the form @code{(@var{regexp} @var{mode-function} |
97 |
@var{flag})} and @var{flag} is non-@code{nil}, then after calling |
@var{flag})} and @var{flag} is non-@code{nil}, then after calling |
98 |
@var{mode-function}, the suffix that matched @var{regexp} is discarded |
@var{mode-function}, Emacs discards the suffix that matched |
99 |
and the list is searched again for another match. |
@var{regexp} and searches the list again for another match. |
100 |
|
|
101 |
You can specify which major mode should be used for editing a certain |
You can specify the major mode to use for editing a certain file by |
102 |
file by a special sort of text in the first nonblank line of the file. The |
special text in the first nonblank line of the file. The |
103 |
mode name should appear in this line both preceded and followed by |
mode name should appear in this line both preceded and followed by |
104 |
@samp{-*-}. Other text may appear on the line as well. For example, |
@samp{-*-}. Other text may appear on the line as well. For example, |
105 |
|
|
166 |
@vindex change-major-mode-with-file-name |
@vindex change-major-mode-with-file-name |
167 |
The commands @kbd{C-x C-w} and @code{set-visited-file-name} change to |
The commands @kbd{C-x C-w} and @code{set-visited-file-name} change to |
168 |
a new major mode if the new file name implies a mode (@pxref{Saving}). |
a new major mode if the new file name implies a mode (@pxref{Saving}). |
169 |
|
(@kbd{C-x C-s} does this too, if the buffer wasn't visiting a file.) |
170 |
However, this does not happen if the buffer contents specify a major |
However, this does not happen if the buffer contents specify a major |
171 |
mode, and certain ``special'' major modes do not allow the mode to |
mode, and certain ``special'' major modes do not allow the mode to |
172 |
change. You can turn off this mode-changing feature by setting |
change. You can turn off this mode-changing feature by setting |