annotate man/major.texi @ 90964:269d87dc10d9

(Qgdi): Rename from Qw32.
author Jason Rumney <jasonr@gnu.org>
date Sun, 24 Jun 2007 20:49:24 +0000
parents 95d0cdf160ea
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
1 @c This is part of the Emacs manual.
64890
3723093a21fd Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 62366
diff changeset
2 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2000, 2001,
75348
3d45362f1d38 Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 75005
diff changeset
3 @c 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
4 @c See file emacs.texi for copying conditions.
Dave Love <fx@gnu.org>
parents:
diff changeset
5 @node Major Modes, Indentation, International, Top
Dave Love <fx@gnu.org>
parents:
diff changeset
6 @chapter Major Modes
Dave Love <fx@gnu.org>
parents:
diff changeset
7 @cindex major modes
Dave Love <fx@gnu.org>
parents:
diff changeset
8 @cindex mode, major
Dave Love <fx@gnu.org>
parents:
diff changeset
9 @kindex TAB @r{(and major modes)}
Dave Love <fx@gnu.org>
parents:
diff changeset
10 @kindex DEL @r{(and major modes)}
Dave Love <fx@gnu.org>
parents:
diff changeset
11 @kindex C-j @r{(and major modes)}
Dave Love <fx@gnu.org>
parents:
diff changeset
12
Dave Love <fx@gnu.org>
parents:
diff changeset
13 Emacs provides many alternative @dfn{major modes}, each of which
Dave Love <fx@gnu.org>
parents:
diff changeset
14 customizes Emacs for editing text of a particular sort. The major modes
Dave Love <fx@gnu.org>
parents:
diff changeset
15 are mutually exclusive, and each buffer has one major mode at any time.
Dave Love <fx@gnu.org>
parents:
diff changeset
16 The mode line normally shows the name of the current major mode, in
Dave Love <fx@gnu.org>
parents:
diff changeset
17 parentheses (@pxref{Mode Line}).
Dave Love <fx@gnu.org>
parents:
diff changeset
18
Dave Love <fx@gnu.org>
parents:
diff changeset
19 The least specialized major mode is called @dfn{Fundamental mode}.
Dave Love <fx@gnu.org>
parents:
diff changeset
20 This mode has no mode-specific redefinitions or variable settings, so
Dave Love <fx@gnu.org>
parents:
diff changeset
21 that each Emacs command behaves in its most general manner, and each
59798
0816b427495a Don't say just "option" when talking about variables.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
22 user option variable is in its default state. For editing text of a
0816b427495a Don't say just "option" when talking about variables.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
23 specific type that Emacs knows about, such as Lisp code or English
0816b427495a Don't say just "option" when talking about variables.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
24 text, you should switch to the appropriate major mode, such as Lisp
0816b427495a Don't say just "option" when talking about variables.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
25 mode or Text mode.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
26
Dave Love <fx@gnu.org>
parents:
diff changeset
27 Selecting a major mode changes the meanings of a few keys to become
Dave Love <fx@gnu.org>
parents:
diff changeset
28 more specifically adapted to the language being edited. The ones that
Dave Love <fx@gnu.org>
parents:
diff changeset
29 are changed frequently are @key{TAB}, @key{DEL}, and @kbd{C-j}. The
Dave Love <fx@gnu.org>
parents:
diff changeset
30 prefix key @kbd{C-c} normally contains mode-specific commands. In
Dave Love <fx@gnu.org>
parents:
diff changeset
31 addition, the commands which handle comments use the mode to determine
Dave Love <fx@gnu.org>
parents:
diff changeset
32 how comments are to be delimited. Many major modes redefine the
Dave Love <fx@gnu.org>
parents:
diff changeset
33 syntactical properties of characters appearing in the buffer.
Dave Love <fx@gnu.org>
parents:
diff changeset
34 @xref{Syntax}.
Dave Love <fx@gnu.org>
parents:
diff changeset
35
38461
23f63206a867 Proofreading fixes from Chris Green <chris_e_green@yahoo.com>.
Eli Zaretskii <eliz@gnu.org>
parents: 37986
diff changeset
36 The major modes fall into three major groups. The first group
38745
5464ee1ba8e2 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 38461
diff changeset
37 contains modes for normal text, either plain or with mark-up. It
5464ee1ba8e2 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 38461
diff changeset
38 includes Text mode, HTML mode, SGML mode, @TeX{} mode and Outline
5464ee1ba8e2 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 38461
diff changeset
39 mode. The second group contains modes for specific programming
5464ee1ba8e2 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 38461
diff changeset
40 languages. These include Lisp mode (which has several variants), C
5464ee1ba8e2 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 38461
diff changeset
41 mode, Fortran mode, and others. The remaining major modes are not
5464ee1ba8e2 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 38461
diff changeset
42 intended for use on users' files; they are used in buffers created for
5464ee1ba8e2 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 38461
diff changeset
43 specific purposes by Emacs, such as Dired mode for buffers made by
5464ee1ba8e2 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 38461
diff changeset
44 Dired (@pxref{Dired}), Mail mode for buffers made by @kbd{C-x m}
5464ee1ba8e2 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 38461
diff changeset
45 (@pxref{Sending Mail}), and Shell mode for buffers used for
5464ee1ba8e2 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 38461
diff changeset
46 communicating with an inferior shell process (@pxref{Interactive
5464ee1ba8e2 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 38461
diff changeset
47 Shell}).
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
48
Dave Love <fx@gnu.org>
parents:
diff changeset
49 Most programming-language major modes specify that only blank lines
Dave Love <fx@gnu.org>
parents:
diff changeset
50 separate paragraphs. This is to make the paragraph commands useful.
Dave Love <fx@gnu.org>
parents:
diff changeset
51 (@xref{Paragraphs}.) They also cause Auto Fill mode to use the
Dave Love <fx@gnu.org>
parents:
diff changeset
52 definition of @key{TAB} to indent the new lines it creates. This is
28550
ea0fd9729fa7 *** empty log message ***
Dave Love <fx@gnu.org>
parents: 25829
diff changeset
53 because most lines in a program are usually indented
ea0fd9729fa7 *** empty log message ***
Dave Love <fx@gnu.org>
parents: 25829
diff changeset
54 (@pxref{Indentation}).
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
55
Dave Love <fx@gnu.org>
parents:
diff changeset
56 @menu
Dave Love <fx@gnu.org>
parents:
diff changeset
57 * Choosing Modes:: How major modes are specified or chosen.
Dave Love <fx@gnu.org>
parents:
diff changeset
58 @end menu
Dave Love <fx@gnu.org>
parents:
diff changeset
59
Dave Love <fx@gnu.org>
parents:
diff changeset
60 @node Choosing Modes,,Major Modes,Major Modes
Dave Love <fx@gnu.org>
parents:
diff changeset
61 @section How Major Modes are Chosen
Dave Love <fx@gnu.org>
parents:
diff changeset
62
Dave Love <fx@gnu.org>
parents:
diff changeset
63 @cindex choosing a major mode
Dave Love <fx@gnu.org>
parents:
diff changeset
64 You can select a major mode explicitly for the current buffer, but
Dave Love <fx@gnu.org>
parents:
diff changeset
65 most of the time Emacs determines which mode to use based on the file
Dave Love <fx@gnu.org>
parents:
diff changeset
66 name or on special text in the file.
Dave Love <fx@gnu.org>
parents:
diff changeset
67
68547
e709385ba493 Minor clarifications.
Richard M. Stallman <rms@gnu.org>
parents: 64890
diff changeset
68 To explicitly select a new major, you use an @kbd{M-x} command.
e709385ba493 Minor clarifications.
Richard M. Stallman <rms@gnu.org>
parents: 64890
diff changeset
69 Take the name of a major mode and add @code{-mode} to get the name of
e709385ba493 Minor clarifications.
Richard M. Stallman <rms@gnu.org>
parents: 64890
diff changeset
70 the command to select that mode. Thus, you can enter Lisp mode by
e709385ba493 Minor clarifications.
Richard M. Stallman <rms@gnu.org>
parents: 64890
diff changeset
71 executing @kbd{M-x lisp-mode}.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
72
Dave Love <fx@gnu.org>
parents:
diff changeset
73 @vindex auto-mode-alist
Dave Love <fx@gnu.org>
parents:
diff changeset
74 When you visit a file, Emacs usually chooses the right major mode based
Dave Love <fx@gnu.org>
parents:
diff changeset
75 on the file's name. For example, files whose names end in @samp{.c} are
Dave Love <fx@gnu.org>
parents:
diff changeset
76 edited in C mode. The correspondence between file names and major modes is
Dave Love <fx@gnu.org>
parents:
diff changeset
77 controlled by the variable @code{auto-mode-alist}. Its value is a list in
Dave Love <fx@gnu.org>
parents:
diff changeset
78 which each element has this form,
Dave Love <fx@gnu.org>
parents:
diff changeset
79
Dave Love <fx@gnu.org>
parents:
diff changeset
80 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
81 (@var{regexp} . @var{mode-function})
Dave Love <fx@gnu.org>
parents:
diff changeset
82 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
83
Dave Love <fx@gnu.org>
parents:
diff changeset
84 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
85 or this form,
Dave Love <fx@gnu.org>
parents:
diff changeset
86
Dave Love <fx@gnu.org>
parents:
diff changeset
87 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
88 (@var{regexp} @var{mode-function} @var{flag})
Dave Love <fx@gnu.org>
parents:
diff changeset
89 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
90
Dave Love <fx@gnu.org>
parents:
diff changeset
91 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
92 For example, one element normally found in the list has the form
Dave Love <fx@gnu.org>
parents:
diff changeset
93 @code{(@t{"\\.c\\'"} . c-mode)}, and it is responsible for selecting C
Dave Love <fx@gnu.org>
parents:
diff changeset
94 mode for files whose names end in @file{.c}. (Note that @samp{\\} is
38461
23f63206a867 Proofreading fixes from Chris Green <chris_e_green@yahoo.com>.
Eli Zaretskii <eliz@gnu.org>
parents: 37986
diff changeset
95 needed in Lisp syntax to include a @samp{\} in the string, which must
60109
b38fabf04e70 (Choosing Modes): Clarify.
Richard M. Stallman <rms@gnu.org>
parents: 59798
diff changeset
96 be used to suppress the special meaning of @samp{.} in regexps.) If
b38fabf04e70 (Choosing Modes): Clarify.
Richard M. Stallman <rms@gnu.org>
parents: 59798
diff changeset
97 the element has the form @code{(@var{regexp} @var{mode-function}
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
98 @var{flag})} and @var{flag} is non-@code{nil}, then after calling
60109
b38fabf04e70 (Choosing Modes): Clarify.
Richard M. Stallman <rms@gnu.org>
parents: 59798
diff changeset
99 @var{mode-function}, Emacs discards the suffix that matched
b38fabf04e70 (Choosing Modes): Clarify.
Richard M. Stallman <rms@gnu.org>
parents: 59798
diff changeset
100 @var{regexp} and searches the list again for another match.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
101
61465
9cc4be7413fb (Choosing Modes): Document magic-mode-alist.
Richard M. Stallman <rms@gnu.org>
parents: 60109
diff changeset
102 @vindex magic-mode-alist
9cc4be7413fb (Choosing Modes): Document magic-mode-alist.
Richard M. Stallman <rms@gnu.org>
parents: 60109
diff changeset
103 Sometimes the major mode is determined from the way the file's text
9cc4be7413fb (Choosing Modes): Document magic-mode-alist.
Richard M. Stallman <rms@gnu.org>
parents: 60109
diff changeset
104 begins. The variable @code{magic-mode-alist} controls this. Its value
74741
53b637f954f2 (Choosing Modes): Describe match-function elements for
Kim F. Storm <storm@cua.dk>
parents: 68639
diff changeset
105 is a list of elements of these forms:
61465
9cc4be7413fb (Choosing Modes): Document magic-mode-alist.
Richard M. Stallman <rms@gnu.org>
parents: 60109
diff changeset
106
9cc4be7413fb (Choosing Modes): Document magic-mode-alist.
Richard M. Stallman <rms@gnu.org>
parents: 60109
diff changeset
107 @example
9cc4be7413fb (Choosing Modes): Document magic-mode-alist.
Richard M. Stallman <rms@gnu.org>
parents: 60109
diff changeset
108 (@var{regexp} . @var{mode-function})
74741
53b637f954f2 (Choosing Modes): Describe match-function elements for
Kim F. Storm <storm@cua.dk>
parents: 68639
diff changeset
109 (@var{match-function} . @var{mode-function})
61465
9cc4be7413fb (Choosing Modes): Document magic-mode-alist.
Richard M. Stallman <rms@gnu.org>
parents: 60109
diff changeset
110 @end example
9cc4be7413fb (Choosing Modes): Document magic-mode-alist.
Richard M. Stallman <rms@gnu.org>
parents: 60109
diff changeset
111
9cc4be7413fb (Choosing Modes): Document magic-mode-alist.
Richard M. Stallman <rms@gnu.org>
parents: 60109
diff changeset
112 @noindent
74741
53b637f954f2 (Choosing Modes): Describe match-function elements for
Kim F. Storm <storm@cua.dk>
parents: 68639
diff changeset
113 The first form looks like an element of @code{auto-mode-alist}, but it
53b637f954f2 (Choosing Modes): Describe match-function elements for
Kim F. Storm <storm@cua.dk>
parents: 68639
diff changeset
114 doesn't work the same: this @var{regexp} is matched against the text
53b637f954f2 (Choosing Modes): Describe match-function elements for
Kim F. Storm <storm@cua.dk>
parents: 68639
diff changeset
115 at the start of the buffer, not against the file name. Likewise, the
53b637f954f2 (Choosing Modes): Describe match-function elements for
Kim F. Storm <storm@cua.dk>
parents: 68639
diff changeset
116 second form calls @var{match-function} at the beginning of the buffer,
53b637f954f2 (Choosing Modes): Describe match-function elements for
Kim F. Storm <storm@cua.dk>
parents: 68639
diff changeset
117 and if the function returns non-@code{nil}, the @var{mode-function} is
53b637f954f2 (Choosing Modes): Describe match-function elements for
Kim F. Storm <storm@cua.dk>
parents: 68639
diff changeset
118 called. @code{magic-mode-alist} takes priority over
53b637f954f2 (Choosing Modes): Describe match-function elements for
Kim F. Storm <storm@cua.dk>
parents: 68639
diff changeset
119 @code{auto-mode-alist}.
61465
9cc4be7413fb (Choosing Modes): Document magic-mode-alist.
Richard M. Stallman <rms@gnu.org>
parents: 60109
diff changeset
120
60109
b38fabf04e70 (Choosing Modes): Clarify.
Richard M. Stallman <rms@gnu.org>
parents: 59798
diff changeset
121 You can specify the major mode to use for editing a certain file by
b38fabf04e70 (Choosing Modes): Clarify.
Richard M. Stallman <rms@gnu.org>
parents: 59798
diff changeset
122 special text in the first nonblank line of the file. The
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
123 mode name should appear in this line both preceded and followed by
Dave Love <fx@gnu.org>
parents:
diff changeset
124 @samp{-*-}. Other text may appear on the line as well. For example,
Dave Love <fx@gnu.org>
parents:
diff changeset
125
Dave Love <fx@gnu.org>
parents:
diff changeset
126 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
127 ;-*-Lisp-*-
Dave Love <fx@gnu.org>
parents:
diff changeset
128 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
129
Dave Love <fx@gnu.org>
parents:
diff changeset
130 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
131 tells Emacs to use Lisp mode. Such an explicit specification overrides
38461
23f63206a867 Proofreading fixes from Chris Green <chris_e_green@yahoo.com>.
Eli Zaretskii <eliz@gnu.org>
parents: 37986
diff changeset
132 any defaults based on the file name. Note how the semicolon is used
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
133 to make Lisp treat this line as a comment.
Dave Love <fx@gnu.org>
parents:
diff changeset
134
Dave Love <fx@gnu.org>
parents:
diff changeset
135 Another format of mode specification is
Dave Love <fx@gnu.org>
parents:
diff changeset
136
Dave Love <fx@gnu.org>
parents:
diff changeset
137 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
138 -*- mode: @var{modename};-*-
Dave Love <fx@gnu.org>
parents:
diff changeset
139 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
140
Dave Love <fx@gnu.org>
parents:
diff changeset
141 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
142 which allows you to specify local variables as well, like this:
Dave Love <fx@gnu.org>
parents:
diff changeset
143
Dave Love <fx@gnu.org>
parents:
diff changeset
144 @example
Dave Love <fx@gnu.org>
parents:
diff changeset
145 -*- mode: @var{modename}; @var{var}: @var{value}; @dots{} -*-
Dave Love <fx@gnu.org>
parents:
diff changeset
146 @end example
Dave Love <fx@gnu.org>
parents:
diff changeset
147
Dave Love <fx@gnu.org>
parents:
diff changeset
148 @noindent
Dave Love <fx@gnu.org>
parents:
diff changeset
149 @xref{File Variables}, for more information about this.
Dave Love <fx@gnu.org>
parents:
diff changeset
150
75005
eda5cae57c32 (Choosing Modes): Document auto-mode-case-fond.
Kim F. Storm <storm@cua.dk>
parents: 74741
diff changeset
151 @vindex auto-mode-case-fold
eda5cae57c32 (Choosing Modes): Document auto-mode-case-fond.
Kim F. Storm <storm@cua.dk>
parents: 74741
diff changeset
152 On systems with case-insensitive file names, only a single
eda5cae57c32 (Choosing Modes): Document auto-mode-case-fond.
Kim F. Storm <storm@cua.dk>
parents: 74741
diff changeset
153 case-insensitive search through the @code{auto-mode-alist} is made.
eda5cae57c32 (Choosing Modes): Document auto-mode-case-fond.
Kim F. Storm <storm@cua.dk>
parents: 74741
diff changeset
154 On other systems, Emacs normally performs a single case-sensitive
eda5cae57c32 (Choosing Modes): Document auto-mode-case-fond.
Kim F. Storm <storm@cua.dk>
parents: 74741
diff changeset
155 search through the alist, but if you set this variable to a
eda5cae57c32 (Choosing Modes): Document auto-mode-case-fond.
Kim F. Storm <storm@cua.dk>
parents: 74741
diff changeset
156 non-@code{nil} value, Emacs will perform a second case-insensitive
eda5cae57c32 (Choosing Modes): Document auto-mode-case-fond.
Kim F. Storm <storm@cua.dk>
parents: 74741
diff changeset
157 search if the first search fails.
eda5cae57c32 (Choosing Modes): Document auto-mode-case-fond.
Kim F. Storm <storm@cua.dk>
parents: 74741
diff changeset
158
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
159 @vindex interpreter-mode-alist
Dave Love <fx@gnu.org>
parents:
diff changeset
160 When a file's contents begin with @samp{#!}, it can serve as an
Dave Love <fx@gnu.org>
parents:
diff changeset
161 executable shell command, which works by running an interpreter named on
Dave Love <fx@gnu.org>
parents:
diff changeset
162 the file's first line. The rest of the file is used as input to the
Dave Love <fx@gnu.org>
parents:
diff changeset
163 interpreter.
Dave Love <fx@gnu.org>
parents:
diff changeset
164
Dave Love <fx@gnu.org>
parents:
diff changeset
165 When you visit such a file in Emacs, if the file's name does not
Dave Love <fx@gnu.org>
parents:
diff changeset
166 specify a major mode, Emacs uses the interpreter name on the first line
Dave Love <fx@gnu.org>
parents:
diff changeset
167 to choose a mode. If the first line is the name of a recognized
Dave Love <fx@gnu.org>
parents:
diff changeset
168 interpreter program, such as @samp{perl} or @samp{tcl}, Emacs uses a
Dave Love <fx@gnu.org>
parents:
diff changeset
169 mode appropriate for programs for that interpreter. The variable
Dave Love <fx@gnu.org>
parents:
diff changeset
170 @code{interpreter-mode-alist} specifies the correspondence between
Dave Love <fx@gnu.org>
parents:
diff changeset
171 interpreter program names and major modes.
Dave Love <fx@gnu.org>
parents:
diff changeset
172
Dave Love <fx@gnu.org>
parents:
diff changeset
173 When the first line starts with @samp{#!}, you cannot (on many
Dave Love <fx@gnu.org>
parents:
diff changeset
174 systems) use the @samp{-*-} feature on the first line, because the
Dave Love <fx@gnu.org>
parents:
diff changeset
175 system would get confused when running the interpreter. So Emacs looks
Dave Love <fx@gnu.org>
parents:
diff changeset
176 for @samp{-*-} on the second line in such files as well as on the
Dave Love <fx@gnu.org>
parents:
diff changeset
177 first line.
Dave Love <fx@gnu.org>
parents:
diff changeset
178
Dave Love <fx@gnu.org>
parents:
diff changeset
179 @vindex default-major-mode
Dave Love <fx@gnu.org>
parents:
diff changeset
180 When you visit a file that does not specify a major mode to use, or
Dave Love <fx@gnu.org>
parents:
diff changeset
181 when you create a new buffer with @kbd{C-x b}, the variable
Dave Love <fx@gnu.org>
parents:
diff changeset
182 @code{default-major-mode} specifies which major mode to use. Normally
Dave Love <fx@gnu.org>
parents:
diff changeset
183 its value is the symbol @code{fundamental-mode}, which specifies
Dave Love <fx@gnu.org>
parents:
diff changeset
184 Fundamental mode. If @code{default-major-mode} is @code{nil}, the major
37986
e11682cc1516 selected buffer => current buffer.
Richard M. Stallman <rms@gnu.org>
parents: 37421
diff changeset
185 mode is taken from the previously current buffer.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
186
Dave Love <fx@gnu.org>
parents:
diff changeset
187 @findex normal-mode
Dave Love <fx@gnu.org>
parents:
diff changeset
188 If you change the major mode of a buffer, you can go back to the major
Dave Love <fx@gnu.org>
parents:
diff changeset
189 mode Emacs would choose automatically: use the command @kbd{M-x
Dave Love <fx@gnu.org>
parents:
diff changeset
190 normal-mode} to do this. This is the same function that
Dave Love <fx@gnu.org>
parents:
diff changeset
191 @code{find-file} calls to choose the major mode. It also processes
62366
1cac74a672b0 (Choosing Modes): normal-mode processes the -*- line. Add xref.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61465
diff changeset
192 the file's @samp{-*-} line or local variables list (if any).
1cac74a672b0 (Choosing Modes): normal-mode processes the -*- line. Add xref.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61465
diff changeset
193 @xref{File Variables}.
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
194
Dave Love <fx@gnu.org>
parents:
diff changeset
195 @vindex change-major-mode-with-file-name
Dave Love <fx@gnu.org>
parents:
diff changeset
196 The commands @kbd{C-x C-w} and @code{set-visited-file-name} change to
Dave Love <fx@gnu.org>
parents:
diff changeset
197 a new major mode if the new file name implies a mode (@pxref{Saving}).
60109
b38fabf04e70 (Choosing Modes): Clarify.
Richard M. Stallman <rms@gnu.org>
parents: 59798
diff changeset
198 (@kbd{C-x C-s} does this too, if the buffer wasn't visiting a file.)
25829
Dave Love <fx@gnu.org>
parents:
diff changeset
199 However, this does not happen if the buffer contents specify a major
Dave Love <fx@gnu.org>
parents:
diff changeset
200 mode, and certain ``special'' major modes do not allow the mode to
Dave Love <fx@gnu.org>
parents:
diff changeset
201 change. You can turn off this mode-changing feature by setting
Dave Love <fx@gnu.org>
parents:
diff changeset
202 @code{change-major-mode-with-file-name} to @code{nil}.
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 38745
diff changeset
203
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 38745
diff changeset
204 @ignore
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 38745
diff changeset
205 arch-tag: f2558800-cf32-4839-8acb-7d3b4df2a155
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 38745
diff changeset
206 @end ignore