diff options
| author | Chong Yidong | 2011-07-10 00:05:33 -0400 |
|---|---|---|
| committer | Chong Yidong | 2011-07-10 00:05:33 -0400 |
| commit | 8875da1e9284e108386c4e58c638b483f4ced9b5 (patch) | |
| tree | 82b3a15e339697ada5ddadf39fd7a722179a971c | |
| parent | 6cfd0fa2de12047b5f29963ae5c7dc2ea481100d (diff) | |
| download | emacs-8875da1e9284e108386c4e58c638b483f4ced9b5.tar.gz emacs-8875da1e9284e108386c4e58c638b483f4ced9b5.zip | |
Move Minor Modes node of Emacs manual next to the Major Modes node
and out of the Customizations chapter.
* doc/emacs/modes.texi: Rename from major.texi.
(Modes): New node. Make Major Modes and Minor Modes subsections
of this. All callers changed.
* doc/emacs/custom.texi (Minor Modes): Move to modes.texi.
| -rw-r--r-- | doc/emacs/ChangeLog | 8 | ||||
| -rw-r--r-- | doc/emacs/Makefile.in | 2 | ||||
| -rw-r--r-- | doc/emacs/custom.texi | 151 | ||||
| -rw-r--r-- | doc/emacs/emacs.texi | 13 | ||||
| -rw-r--r-- | doc/emacs/indent.texi | 2 | ||||
| -rw-r--r-- | doc/emacs/major.texi | 236 | ||||
| -rw-r--r-- | doc/emacs/modes.texi | 410 | ||||
| -rw-r--r-- | doc/emacs/mule.texi | 2 |
8 files changed, 428 insertions, 396 deletions
diff --git a/doc/emacs/ChangeLog b/doc/emacs/ChangeLog index 1b2588fec58..6bc8c7312db 100644 --- a/doc/emacs/ChangeLog +++ b/doc/emacs/ChangeLog | |||
| @@ -1,5 +1,13 @@ | |||
| 1 | 2011-07-10 Chong Yidong <cyd@stupidchicken.com> | 1 | 2011-07-10 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 2 | ||
| 3 | * modes.texi: Rename from major.texi. | ||
| 4 | (Modes): New node. Make Major Modes and Minor Modes subsections | ||
| 5 | of this. All callers changed. | ||
| 6 | |||
| 7 | * custom.texi (Minor Modes): Move to modes.texi. | ||
| 8 | |||
| 9 | 2011-07-10 Chong Yidong <cyd@stupidchicken.com> | ||
| 10 | |||
| 3 | * custom.texi (Syntax): Node deleted. | 11 | * custom.texi (Syntax): Node deleted. |
| 4 | 12 | ||
| 5 | * help.texi (Help Summary): | 13 | * help.texi (Help Summary): |
diff --git a/doc/emacs/Makefile.in b/doc/emacs/Makefile.in index aca17ce817d..9465c726eba 100644 --- a/doc/emacs/Makefile.in +++ b/doc/emacs/Makefile.in | |||
| @@ -84,7 +84,7 @@ EMACSSOURCES= \ | |||
| 84 | ${srcdir}/windows.texi \ | 84 | ${srcdir}/windows.texi \ |
| 85 | ${srcdir}/frames.texi \ | 85 | ${srcdir}/frames.texi \ |
| 86 | ${srcdir}/mule.texi \ | 86 | ${srcdir}/mule.texi \ |
| 87 | ${srcdir}/major.texi \ | 87 | ${srcdir}/modes.texi \ |
| 88 | ${srcdir}/indent.texi \ | 88 | ${srcdir}/indent.texi \ |
| 89 | ${srcdir}/text.texi \ | 89 | ${srcdir}/text.texi \ |
| 90 | ${srcdir}/programs.texi \ | 90 | ${srcdir}/programs.texi \ |
diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi index 4ecbb0c42cc..8465dd93519 100644 --- a/doc/emacs/custom.texi +++ b/doc/emacs/custom.texi | |||
| @@ -23,8 +23,6 @@ Reference Manual}. | |||
| 23 | @end ifnottex | 23 | @end ifnottex |
| 24 | 24 | ||
| 25 | @menu | 25 | @menu |
| 26 | * Minor Modes:: Each minor mode is a feature you can turn on | ||
| 27 | independently of any others. | ||
| 28 | * Easy Customization:: Convenient way to browse and change settings. | 26 | * Easy Customization:: Convenient way to browse and change settings. |
| 29 | * Variables:: Many Emacs commands examine Emacs variables | 27 | * Variables:: Many Emacs commands examine Emacs variables |
| 30 | to decide what to do; by setting variables, | 28 | to decide what to do; by setting variables, |
| @@ -35,155 +33,6 @@ Reference Manual}. | |||
| 35 | @file{.emacs} file. | 33 | @file{.emacs} file. |
| 36 | @end menu | 34 | @end menu |
| 37 | 35 | ||
| 38 | @node Minor Modes | ||
| 39 | @section Minor Modes | ||
| 40 | @cindex minor modes | ||
| 41 | @cindex mode, minor | ||
| 42 | |||
| 43 | Minor modes are optional features which you can turn on or off. For | ||
| 44 | example, Auto Fill mode is a minor mode in which @key{SPC} breaks | ||
| 45 | lines between words as you type. Minor modes are independent of one | ||
| 46 | another and of the selected major mode. Most minor modes say in the | ||
| 47 | mode line when they are enabled; for example, @samp{Fill} in the mode | ||
| 48 | line means that Auto Fill mode is enabled. | ||
| 49 | |||
| 50 | Each minor mode is associated with a command, called the @dfn{mode | ||
| 51 | command}, which turns it on or off. The name of this command consists | ||
| 52 | of the name of the minor mode, followed by @samp{-mode}; for instance, | ||
| 53 | the mode command for Auto Fill mode is @code{auto-fill-mode}. Calling | ||
| 54 | the minor mode command with no prefix argument @dfn{toggles} the mode, | ||
| 55 | turning it on if it was off, and off if it was on. A positive | ||
| 56 | argument always turns the mode on, and a zero or negative argument | ||
| 57 | always turns it off. Mode commands are usually invoked with | ||
| 58 | @kbd{M-x}, but you can bind keys to them if you wish (@pxref{Key | ||
| 59 | Bindings}). | ||
| 60 | |||
| 61 | Most minor modes also have a @dfn{mode variable}, with the same name | ||
| 62 | as the mode command. Its value is non-@code{nil} if the mode is | ||
| 63 | enabled, and @code{nil} if it is disabled. In some minor modes---but | ||
| 64 | not all---the value of the variable alone determines whether the mode | ||
| 65 | is active: the mode command works simply by setting the variable, and | ||
| 66 | changing the value of the variable has the same effect as calling the | ||
| 67 | mode command. Because not all minor modes work this way, we recommend | ||
| 68 | that you avoid changing the mode variables directly; use the mode | ||
| 69 | commands instead. | ||
| 70 | |||
| 71 | Some minor modes are @dfn{buffer-local}: they apply only to the | ||
| 72 | current buffer, so you can enable the mode in certain buffers and not | ||
| 73 | others. Other minor modes are @dfn{global}: while enabled, they | ||
| 74 | affect everything you do in the Emacs session, in all buffers. Some | ||
| 75 | global minor modes are enabled by default. | ||
| 76 | |||
| 77 | The following is a list of some buffer-local minor modes: | ||
| 78 | |||
| 79 | @itemize @bullet | ||
| 80 | @item | ||
| 81 | Abbrev mode automatically expands text based on pre-defined | ||
| 82 | abbreviation definitions. @xref{Abbrevs}. | ||
| 83 | |||
| 84 | @item | ||
| 85 | Auto Fill mode inserts newlines as you type to prevent lines from | ||
| 86 | becoming too long. @xref{Filling}. | ||
| 87 | |||
| 88 | @item | ||
| 89 | Auto Save mode saves the buffer contents periodically to reduce the | ||
| 90 | amount of work you can lose in case of a crash. @xref{Auto Save}. | ||
| 91 | |||
| 92 | @item | ||
| 93 | Enriched mode enables editing and saving of formatted text. | ||
| 94 | @xref{Formatted Text}. | ||
| 95 | |||
| 96 | @item | ||
| 97 | Flyspell mode automatically highlights misspelled words. | ||
| 98 | @xref{Spelling}. | ||
| 99 | |||
| 100 | @item | ||
| 101 | Font-Lock mode automatically highlights certain textual units found in | ||
| 102 | programs. It is enabled globally by default, but you can disable it | ||
| 103 | in individual buffers. @xref{Faces}. | ||
| 104 | |||
| 105 | @findex linum-mode | ||
| 106 | @cindex Linum mode | ||
| 107 | @item | ||
| 108 | Linum mode displays each line's line number in the window's left | ||
| 109 | margin. Its mode command is @code{linum-mode}. | ||
| 110 | |||
| 111 | @item | ||
| 112 | Outline minor mode provides similar facilities to the major mode | ||
| 113 | called Outline mode. @xref{Outline Mode}. | ||
| 114 | |||
| 115 | @cindex Overwrite mode | ||
| 116 | @cindex mode, Overwrite | ||
| 117 | @findex overwrite-mode | ||
| 118 | @kindex INSERT | ||
| 119 | @item | ||
| 120 | Overwrite mode causes ordinary printing characters to replace existing | ||
| 121 | text instead of shoving it to the right. For example, if point is in | ||
| 122 | front of the @samp{B} in @samp{FOOBAR}, then in Overwrite mode typing | ||
| 123 | a @kbd{G} changes it to @samp{FOOGAR}, instead of producing | ||
| 124 | @samp{FOOGBAR} as usual. In Overwrite mode, the command @kbd{C-q} | ||
| 125 | inserts the next character whatever it may be, even if it is a | ||
| 126 | digit---this gives you a way to insert a character instead of | ||
| 127 | replacing an existing character. The mode command, | ||
| 128 | @code{overwrite-mode}, is bound to the @key{Insert} key. | ||
| 129 | |||
| 130 | @findex binary-overwrite-mode | ||
| 131 | @item | ||
| 132 | Binary Overwrite mode is a variant of Overwrite mode for editing | ||
| 133 | binary files; it treats newlines and tabs like other characters, so | ||
| 134 | that they overwrite other characters and can be overwritten by them. | ||
| 135 | In Binary Overwrite mode, digits after @kbd{C-q} specify an octal | ||
| 136 | character code, as usual. | ||
| 137 | |||
| 138 | @item | ||
| 139 | Visual Line mode performs ``word wrapping'', causing long lines to be | ||
| 140 | wrapped at word boundaries. @xref{Visual Line Mode}. | ||
| 141 | @end itemize | ||
| 142 | |||
| 143 | Here are some useful global minor modes. Since Line Number mode and | ||
| 144 | Transient Mark mode can be enabled or disabled just by setting the | ||
| 145 | value of the minor mode variable, you @emph{can} set them differently | ||
| 146 | for particular buffers, by explicitly making the corresponding | ||
| 147 | variable local in those buffers. @xref{Locals}. | ||
| 148 | |||
| 149 | @itemize @bullet | ||
| 150 | @item | ||
| 151 | Column Number mode enables display of the current column number in the | ||
| 152 | mode line. @xref{Mode Line}. | ||
| 153 | |||
| 154 | @item | ||
| 155 | Delete Selection mode causes text insertion to first delete the text | ||
| 156 | in the region, if the region is active. @xref{Using Region}. | ||
| 157 | |||
| 158 | @item | ||
| 159 | Icomplete mode displays an indication of available completions when | ||
| 160 | you are in the minibuffer and completion is active. @xref{Completion | ||
| 161 | Options}. | ||
| 162 | |||
| 163 | @item | ||
| 164 | Line Number mode enables display of the current line number in the | ||
| 165 | mode line. It is enabled by default. @xref{Mode Line}. | ||
| 166 | |||
| 167 | @item | ||
| 168 | Menu Bar mode gives each frame a menu bar. It is enabled by default. | ||
| 169 | @xref{Menu Bars}. | ||
| 170 | |||
| 171 | @item | ||
| 172 | Scroll Bar mode gives each window a scroll bar. It is enabled by | ||
| 173 | default, but the scroll bar is only displayed on graphical terminals. | ||
| 174 | @xref{Scroll Bars}. | ||
| 175 | |||
| 176 | @item | ||
| 177 | Tool Bar mode gives each frame a tool bar. It is enabled by default, | ||
| 178 | but the tool bar is only displayed on graphical terminals. @xref{Tool | ||
| 179 | Bars}. | ||
| 180 | |||
| 181 | @item | ||
| 182 | Transient Mark mode highlights the region, and makes many Emacs | ||
| 183 | commands operate on the region when the mark is active. It is enabled | ||
| 184 | by default. @xref{Mark}. | ||
| 185 | @end itemize | ||
| 186 | |||
| 187 | @node Easy Customization | 36 | @node Easy Customization |
| 188 | @section Easy Customization Interface | 37 | @section Easy Customization Interface |
| 189 | 38 | ||
diff --git a/doc/emacs/emacs.texi b/doc/emacs/emacs.texi index c0f1712bada..902de8318b8 100644 --- a/doc/emacs/emacs.texi +++ b/doc/emacs/emacs.texi | |||
| @@ -184,7 +184,7 @@ Major Structures of Emacs | |||
| 184 | * International:: Using non-@acronym{ASCII} character sets. | 184 | * International:: Using non-@acronym{ASCII} character sets. |
| 185 | 185 | ||
| 186 | Advanced Features | 186 | Advanced Features |
| 187 | * Major Modes:: Text mode vs. Lisp mode vs. C mode... | 187 | * Modes:: Major and minor modes alter Emacs' basic behavior. |
| 188 | * Indentation:: Editing the white space at the beginnings of lines. | 188 | * Indentation:: Editing the white space at the beginnings of lines. |
| 189 | * Text:: Commands and modes for editing English. | 189 | * Text:: Commands and modes for editing English. |
| 190 | * Programs:: Commands and modes for editing programs. | 190 | * Programs:: Commands and modes for editing programs. |
| @@ -549,9 +549,12 @@ International Character Set Support | |||
| 549 | to use without multibyte characters. | 549 | to use without multibyte characters. |
| 550 | * Charsets:: How Emacs groups its internal character codes. | 550 | * Charsets:: How Emacs groups its internal character codes. |
| 551 | 551 | ||
| 552 | Major Modes | 552 | Modes |
| 553 | 553 | ||
| 554 | * Choosing Modes:: How major modes are specified or chosen. | 554 | * Major Modes:: Text mode vs. Lisp mode vs. C mode... |
| 555 | * Minor Modes:: Each minor mode is a feature you can turn on | ||
| 556 | independently of any others. | ||
| 557 | * Choosing Modes:: How modes are chosen when visiting files. | ||
| 555 | 558 | ||
| 556 | Indentation | 559 | Indentation |
| 557 | 560 | ||
| @@ -1058,8 +1061,6 @@ Hyperlinking and Navigation Features | |||
| 1058 | 1061 | ||
| 1059 | Customization | 1062 | Customization |
| 1060 | 1063 | ||
| 1061 | * Minor Modes:: Each minor mode is a feature you can turn on | ||
| 1062 | independently of any others. | ||
| 1063 | * Easy Customization:: Convenient way to browse and change settings. | 1064 | * Easy Customization:: Convenient way to browse and change settings. |
| 1064 | * Variables:: Many Emacs commands examine Emacs variables | 1065 | * Variables:: Many Emacs commands examine Emacs variables |
| 1065 | to decide what to do; by setting variables, | 1066 | to decide what to do; by setting variables, |
| @@ -1485,7 +1486,7 @@ Lisp programming. | |||
| 1485 | @include windows.texi | 1486 | @include windows.texi |
| 1486 | @include frames.texi | 1487 | @include frames.texi |
| 1487 | @include mule.texi | 1488 | @include mule.texi |
| 1488 | @include major.texi | 1489 | @include modes.texi |
| 1489 | @include indent.texi | 1490 | @include indent.texi |
| 1490 | @include text.texi | 1491 | @include text.texi |
| 1491 | @c Includes fortran-xtra. | 1492 | @c Includes fortran-xtra. |
diff --git a/doc/emacs/indent.texi b/doc/emacs/indent.texi index c4ef4781aaf..e13b2808f09 100644 --- a/doc/emacs/indent.texi +++ b/doc/emacs/indent.texi | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | @c Copyright (C) 1985-1987, 1993-1995, 1997, 2001-2011 | 2 | @c Copyright (C) 1985-1987, 1993-1995, 1997, 2001-2011 |
| 3 | @c Free Software Foundation, Inc. | 3 | @c Free Software Foundation, Inc. |
| 4 | @c See file emacs.texi for copying conditions. | 4 | @c See file emacs.texi for copying conditions. |
| 5 | @node Indentation, Text, Major Modes, Top | 5 | @node Indentation, Text, Modes, Top |
| 6 | @chapter Indentation | 6 | @chapter Indentation |
| 7 | @cindex indentation | 7 | @cindex indentation |
| 8 | @cindex tabs | 8 | @cindex tabs |
diff --git a/doc/emacs/major.texi b/doc/emacs/major.texi deleted file mode 100644 index ff73e568311..00000000000 --- a/doc/emacs/major.texi +++ /dev/null | |||
| @@ -1,236 +0,0 @@ | |||
| 1 | @c This is part of the Emacs manual. | ||
| 2 | @c Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2011 | ||
| 3 | @c Free Software Foundation, Inc. | ||
| 4 | @c See file emacs.texi for copying conditions. | ||
| 5 | @node Major Modes, Indentation, International, Top | ||
| 6 | @chapter Major Modes | ||
| 7 | @cindex major modes | ||
| 8 | @cindex mode, major | ||
| 9 | @kindex TAB @r{(and major modes)} | ||
| 10 | @kindex DEL @r{(and major modes)} | ||
| 11 | @kindex C-j @r{(and major modes)} | ||
| 12 | |||
| 13 | Emacs provides many alternative @dfn{major modes}, each of which | ||
| 14 | customizes Emacs for editing text of a particular sort. The major modes | ||
| 15 | are mutually exclusive, and each buffer has one major mode at any time. | ||
| 16 | The mode line normally shows the name of the current major mode, in | ||
| 17 | parentheses (@pxref{Mode Line}). | ||
| 18 | |||
| 19 | The least specialized major mode is called @dfn{Fundamental mode}. | ||
| 20 | This mode has no mode-specific redefinitions or variable settings, so | ||
| 21 | that each Emacs command behaves in its most general manner, and each | ||
| 22 | user option variable is in its default state. For editing text of a | ||
| 23 | specific type that Emacs knows about, such as Lisp code or English | ||
| 24 | text, you should switch to the appropriate major mode, such as Lisp | ||
| 25 | mode or Text mode. | ||
| 26 | |||
| 27 | Selecting a major mode changes the meanings of a few keys to become | ||
| 28 | more specifically adapted to the language being edited. The ones that | ||
| 29 | are changed frequently are @key{TAB}, @key{DEL}, and @kbd{C-j}. The | ||
| 30 | prefix key @kbd{C-c} normally contains mode-specific commands. In | ||
| 31 | addition, the commands which handle comments use the mode to determine | ||
| 32 | how comments are to be delimited. Many major modes redefine the | ||
| 33 | syntactical properties of characters appearing in the buffer. | ||
| 34 | |||
| 35 | The major modes fall into three major groups. The first group | ||
| 36 | contains modes for normal text, either plain or with mark-up. It | ||
| 37 | includes Text mode, HTML mode, SGML mode, @TeX{} mode and Outline | ||
| 38 | mode. The second group contains modes for specific programming | ||
| 39 | languages. These include Lisp mode (which has several variants), C | ||
| 40 | mode, Fortran mode, and others. The remaining major modes are not | ||
| 41 | intended for use on users' files; they are used in buffers created for | ||
| 42 | specific purposes by Emacs, such as Dired mode for buffers made by | ||
| 43 | Dired (@pxref{Dired}), Message mode for buffers made by @kbd{C-x m} | ||
| 44 | (@pxref{Sending Mail}), and Shell mode for buffers used for | ||
| 45 | communicating with an inferior shell process (@pxref{Interactive | ||
| 46 | Shell}). | ||
| 47 | |||
| 48 | Most programming-language major modes specify that only blank lines | ||
| 49 | separate paragraphs. This is to make the paragraph commands useful. | ||
| 50 | (@xref{Paragraphs}.) They also cause Auto Fill mode to use the | ||
| 51 | definition of @key{TAB} to indent the new lines it creates. This is | ||
| 52 | because most lines in a program are usually indented | ||
| 53 | (@pxref{Indentation}). | ||
| 54 | |||
| 55 | @menu | ||
| 56 | * Choosing Modes:: How major modes are specified or chosen. | ||
| 57 | @end menu | ||
| 58 | |||
| 59 | @node Choosing Modes,,Major Modes,Major Modes | ||
| 60 | @section How Major Modes are Chosen | ||
| 61 | |||
| 62 | @cindex choosing a major mode | ||
| 63 | You can select a major mode explicitly for the current buffer, but | ||
| 64 | most of the time Emacs determines which mode to use based on the file | ||
| 65 | name or on special text in the file. | ||
| 66 | |||
| 67 | To explicitly select a new major, you use an @kbd{M-x} command. | ||
| 68 | Take the name of a major mode and add @code{-mode} to get the name of | ||
| 69 | the command to select that mode. Thus, you can enter Lisp mode by | ||
| 70 | executing @kbd{M-x lisp-mode}. | ||
| 71 | |||
| 72 | @vindex auto-mode-alist | ||
| 73 | When you visit a file, Emacs usually chooses the right major mode | ||
| 74 | automatically. Normally, it makes the choice based on the file | ||
| 75 | name---for example, files whose names end in @samp{.c} are normally | ||
| 76 | edited in C mode---but sometimes it chooses the major mode based on | ||
| 77 | the contents of the file. Here is the exact procedure: | ||
| 78 | |||
| 79 | First, Emacs checks whether the file contains a file-local variable | ||
| 80 | that specifies the major mode. If so, it uses that major mode, | ||
| 81 | ignoring all other criteria. @xref{File Variables}. There are | ||
| 82 | several methods to specify a major mode using a file-local variable; | ||
| 83 | the simplest is to put the mode name in the first nonblank line, | ||
| 84 | preceded and followed by @samp{-*-}. Other text may appear on the | ||
| 85 | line as well. For example, | ||
| 86 | |||
| 87 | @example | ||
| 88 | ; -*-Lisp-*- | ||
| 89 | @end example | ||
| 90 | |||
| 91 | @noindent | ||
| 92 | tells Emacs to use Lisp mode. Note how the semicolon is used to make | ||
| 93 | Lisp treat this line as a comment. Alternatively, you could write | ||
| 94 | |||
| 95 | @example | ||
| 96 | ; -*- mode: Lisp;-*- | ||
| 97 | @end example | ||
| 98 | |||
| 99 | @noindent | ||
| 100 | The latter format allows you to specify local variables as well, like | ||
| 101 | this: | ||
| 102 | |||
| 103 | @example | ||
| 104 | ; -*- mode: Lisp; tab-width: 4; -*- | ||
| 105 | @end example | ||
| 106 | |||
| 107 | @vindex interpreter-mode-alist | ||
| 108 | Second, Emacs checks whether the file's contents begin with | ||
| 109 | @samp{#!}. If so, that indicates that the file can serve as an | ||
| 110 | executable shell command, which works by running an interpreter named | ||
| 111 | on the file's first line (the rest of the file is used as input to the | ||
| 112 | interpreter). Therefore, Emacs tries to use the interpreter name to | ||
| 113 | choose a mode. For instance, a file that begins with | ||
| 114 | @samp{#!/usr/bin/perl} is opened in Perl mode. The variable | ||
| 115 | @code{interpreter-mode-alist} specifies the correspondence between | ||
| 116 | interpreter program names and major modes. | ||
| 117 | |||
| 118 | When the first line starts with @samp{#!}, you usually cannot use | ||
| 119 | the @samp{-*-} feature on the first line, because the system would get | ||
| 120 | confused when running the interpreter. So Emacs looks for @samp{-*-} | ||
| 121 | on the second line in such files as well as on the first line. The | ||
| 122 | same is true for man pages which start with the magic string | ||
| 123 | @samp{'\"} to specify a list of troff preprocessors. | ||
| 124 | |||
| 125 | @vindex magic-mode-alist | ||
| 126 | Third, Emacs tries to determine the major mode by looking at the | ||
| 127 | text at the start of the buffer, based on the variable | ||
| 128 | @code{magic-mode-alist}. By default, this variable is @code{nil} (an | ||
| 129 | empty list), so Emacs skips this step; however, you can customize it | ||
| 130 | in your init file (@pxref{Init File}). The value should be a list of | ||
| 131 | elements of the form | ||
| 132 | |||
| 133 | @example | ||
| 134 | (@var{regexp} . @var{mode-function}) | ||
| 135 | @end example | ||
| 136 | |||
| 137 | @noindent | ||
| 138 | where @var{regexp} is a regular expression (@pxref{Regexps}), and | ||
| 139 | @var{mode-function} is a Lisp function that toggles a major mode. If | ||
| 140 | the text at the beginning of the file matches @var{regexp}, Emacs | ||
| 141 | chooses the major mode specified by @var{mode-function}. | ||
| 142 | |||
| 143 | Alternatively, an element of @code{magic-mode-alist} may have the form | ||
| 144 | |||
| 145 | @example | ||
| 146 | (@var{match-function} . @var{mode-function}) | ||
| 147 | @end example | ||
| 148 | |||
| 149 | @noindent | ||
| 150 | where @var{match-function} is a Lisp function that is called at the | ||
| 151 | beginning of the buffer; if the function returns non-@code{nil}, Emacs | ||
| 152 | set the major mode wit @var{mode-function}. | ||
| 153 | |||
| 154 | Fourth---if Emacs still hasn't found a suitable major mode---it | ||
| 155 | looks at the file's name. The correspondence between file names and | ||
| 156 | major modes is controlled by the variable @code{auto-mode-alist}. Its | ||
| 157 | value is a list in which each element has this form, | ||
| 158 | |||
| 159 | @example | ||
| 160 | (@var{regexp} . @var{mode-function}) | ||
| 161 | @end example | ||
| 162 | |||
| 163 | @noindent | ||
| 164 | or this form, | ||
| 165 | |||
| 166 | @example | ||
| 167 | (@var{regexp} @var{mode-function} @var{flag}) | ||
| 168 | @end example | ||
| 169 | |||
| 170 | @noindent | ||
| 171 | For example, one element normally found in the list has the form | ||
| 172 | @code{(@t{"\\.c\\'"} . c-mode)}, and it is responsible for selecting C | ||
| 173 | mode for files whose names end in @file{.c}. (Note that @samp{\\} is | ||
| 174 | needed in Lisp syntax to include a @samp{\} in the string, which must | ||
| 175 | be used to suppress the special meaning of @samp{.} in regexps.) If | ||
| 176 | the element has the form @code{(@var{regexp} @var{mode-function} | ||
| 177 | @var{flag})} and @var{flag} is non-@code{nil}, then after calling | ||
| 178 | @var{mode-function}, Emacs discards the suffix that matched | ||
| 179 | @var{regexp} and searches the list again for another match. | ||
| 180 | |||
| 181 | @vindex auto-mode-case-fold | ||
| 182 | On systems with case-insensitive file names, such as Microsoft | ||
| 183 | Windows, Emacs performs a single case-insensitive search through | ||
| 184 | @code{auto-mode-alist}. On other systems, Emacs normally performs a | ||
| 185 | single case-sensitive search through the alist. However, if you | ||
| 186 | change the variable @code{auto-mode-case-fold} to @code{t}, Emacs | ||
| 187 | performs a second case-insensitive search if the first search fails. | ||
| 188 | |||
| 189 | @vindex magic-fallback-mode-alist | ||
| 190 | Finally, if Emacs @emph{still} hasn't found a major mode to use, it | ||
| 191 | compares the text at the start of the buffer to the variable | ||
| 192 | @code{magic-fallback-mode-alist}. This variable works like | ||
| 193 | @code{magic-mode-alist}, described above, except that is consulted | ||
| 194 | only after @code{auto-mode-alist}. By default, | ||
| 195 | @code{magic-fallback-mode-alist} contains forms that check for image | ||
| 196 | files, HTML/XML/SGML files, and Postscript files. | ||
| 197 | |||
| 198 | @vindex major-mode | ||
| 199 | Once a major mode is chosen, Emacs sets the value of the variable | ||
| 200 | @code{major-mode} to the symbol for that major mode (e.g., | ||
| 201 | @code{text-mode} for Text mode). This is a per-buffer variable | ||
| 202 | (@pxref{Locals}); its buffer-local value is set automatically, and you | ||
| 203 | should not change it yourself. | ||
| 204 | |||
| 205 | The default value of @code{major-mode} determines the major mode to | ||
| 206 | use for files that do not specify a major mode, and for new buffers | ||
| 207 | created with @kbd{C-x b}. Normally, this default value is the symbol | ||
| 208 | @code{fundamental-mode}, which specifies Fundamental mode. You can | ||
| 209 | change it via the Customization interface (@pxref{Easy | ||
| 210 | Customization}), or by adding a line like this to your init file | ||
| 211 | (@pxref{Init File}): | ||
| 212 | |||
| 213 | @smallexample | ||
| 214 | (setq-default major-mode 'text-mode) | ||
| 215 | @end smallexample | ||
| 216 | |||
| 217 | @noindent | ||
| 218 | If the default value of @code{major-mode} is @code{nil}, the major | ||
| 219 | mode is taken from the previously current buffer. | ||
| 220 | |||
| 221 | @findex normal-mode | ||
| 222 | If you have changed the major mode of a buffer, you can return to | ||
| 223 | the major mode Emacs would have chosen automatically, by typing | ||
| 224 | @kbd{M-x normal-mode}. This is the same function that | ||
| 225 | @code{find-file} calls to choose the major mode. It also processes | ||
| 226 | the file's @samp{-*-} line or local variables list (if any). | ||
| 227 | @xref{File Variables}. | ||
| 228 | |||
| 229 | @vindex change-major-mode-with-file-name | ||
| 230 | The commands @kbd{C-x C-w} and @code{set-visited-file-name} change to | ||
| 231 | a new major mode if the new file name implies a mode (@pxref{Saving}). | ||
| 232 | (@kbd{C-x C-s} does this too, if the buffer wasn't visiting a file.) | ||
| 233 | However, this does not happen if the buffer contents specify a major | ||
| 234 | mode, and certain ``special'' major modes do not allow the mode to | ||
| 235 | change. You can turn off this mode-changing feature by setting | ||
| 236 | @code{change-major-mode-with-file-name} to @code{nil}. | ||
diff --git a/doc/emacs/modes.texi b/doc/emacs/modes.texi new file mode 100644 index 00000000000..314d5d4347e --- /dev/null +++ b/doc/emacs/modes.texi | |||
| @@ -0,0 +1,410 @@ | |||
| 1 | @c This is part of the Emacs manual. | ||
| 2 | @c Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2011 | ||
| 3 | @c Free Software Foundation, Inc. | ||
| 4 | @c See file emacs.texi for copying conditions. | ||
| 5 | @node Modes, Indentation, International, Top | ||
| 6 | @chapter Editing Modes | ||
| 7 | |||
| 8 | Emacs contains many @dfn{editing modes}, each of which alters its | ||
| 9 | basic behavior in useful ways. These are divided into @dfn{major | ||
| 10 | modes} and @dfn{minor modes}. | ||
| 11 | |||
| 12 | Major modes provide specialized facilities for working on a | ||
| 13 | particular file type, such as a C source file (@pxref{Programs}), or a | ||
| 14 | particular type of non-file buffer, such as a shell buffer | ||
| 15 | (@pxref{Shell}). Major modes are mutually exclusive; each buffer has | ||
| 16 | one and only one major mode at any time. | ||
| 17 | |||
| 18 | Minor modes are optional features which you can turn on or off, not | ||
| 19 | necessarily specific to a type of file or buffer. For example, Auto | ||
| 20 | Fill mode is a minor mode in which @key{SPC} breaks lines between | ||
| 21 | words as you type (@pxref{Auto Fill}). Minor modes are independent of | ||
| 22 | one another, and of the selected major mode. | ||
| 23 | |||
| 24 | @menu | ||
| 25 | * Major Modes:: Text mode vs. Lisp mode vs. C mode... | ||
| 26 | * Minor Modes:: Each minor mode is a feature you can turn on | ||
| 27 | independently of any others. | ||
| 28 | * Choosing Modes:: How modes are chosen when visiting files. | ||
| 29 | @end menu | ||
| 30 | |||
| 31 | @node Major Modes | ||
| 32 | @section Major Modes | ||
| 33 | @cindex major modes | ||
| 34 | @cindex mode, major | ||
| 35 | @kindex TAB @r{(and major modes)} | ||
| 36 | @kindex DEL @r{(and major modes)} | ||
| 37 | @kindex C-j @r{(and major modes)} | ||
| 38 | |||
| 39 | Every buffer possesses a major mode, which determines the editing | ||
| 40 | behavior of Emacs while that buffer is current. The mode line | ||
| 41 | normally shows the name of the current major mode, in parentheses. | ||
| 42 | @xref{Mode Line}. | ||
| 43 | |||
| 44 | Usually, the major mode is automatically set by Emacs, when you | ||
| 45 | first visit a file or create a buffer. @xref{Choosing Modes}. You | ||
| 46 | can explicitly select a new major mode by using an @kbd{M-x} command. | ||
| 47 | Take the name of the mode and add @code{-mode} to get the name of the | ||
| 48 | command to select that mode. Thus, you can enter Lisp mode with | ||
| 49 | @kbd{M-x lisp-mode}. | ||
| 50 | |||
| 51 | The least specialized major mode is called @dfn{Fundamental mode}. | ||
| 52 | This mode has no mode-specific redefinitions or variable settings, so | ||
| 53 | that each Emacs command behaves in its most general manner, and each | ||
| 54 | user option variable is in its default state. | ||
| 55 | |||
| 56 | For editing text of a specific type that Emacs knows about, such as | ||
| 57 | Lisp code or English text, you typically use a more specialized major | ||
| 58 | mode, such as Lisp mode or Text mode. Such major modes change the | ||
| 59 | meanings of some keys to become more specifically adapted to the | ||
| 60 | language being edited. The ones that are commonly changed are | ||
| 61 | @key{TAB}, @key{DEL}, and @kbd{C-j}. The prefix key @kbd{C-c} | ||
| 62 | normally contains mode-specific commands. In addition, the commands | ||
| 63 | which handle comments use the mode to determine how comments are to be | ||
| 64 | delimited. Many major modes redefine the syntactical properties of | ||
| 65 | characters appearing in the buffer. | ||
| 66 | |||
| 67 | The major modes fall into three major groups. The first group | ||
| 68 | contains modes for normal text, either plain or with mark-up. It | ||
| 69 | includes Text mode, HTML mode, SGML mode, @TeX{} mode and Outline | ||
| 70 | mode. The second group contains modes for specific programming | ||
| 71 | languages. These include Lisp mode (which has several variants), C | ||
| 72 | mode, Fortran mode, and others. The remaining major modes are not | ||
| 73 | intended for use on users' files; they are used in buffers created for | ||
| 74 | specific purposes by Emacs, such as Dired mode for buffers made by | ||
| 75 | Dired (@pxref{Dired}), Message mode for buffers made by @kbd{C-x m} | ||
| 76 | (@pxref{Sending Mail}), and Shell mode for buffers used for | ||
| 77 | communicating with an inferior shell process (@pxref{Interactive | ||
| 78 | Shell}). | ||
| 79 | |||
| 80 | Most programming-language major modes specify that only blank lines | ||
| 81 | separate paragraphs. This is to make the paragraph commands useful. | ||
| 82 | (@xref{Paragraphs}.) They also cause Auto Fill mode to use the | ||
| 83 | definition of @key{TAB} to indent the new lines it creates. This is | ||
| 84 | because most lines in a program are usually indented | ||
| 85 | (@pxref{Indentation}). | ||
| 86 | |||
| 87 | @node Minor Modes | ||
| 88 | @section Minor Modes | ||
| 89 | @cindex minor modes | ||
| 90 | @cindex mode, minor | ||
| 91 | |||
| 92 | A minor mode is an optional editing modes that alters the behavior | ||
| 93 | of Emacs in some well-defined way. Unlike major modes, any number of | ||
| 94 | minor modes can be in effect at any time. Some minor modes are | ||
| 95 | @dfn{buffer-local}: they apply only to the current buffer, so you can | ||
| 96 | enable the mode in certain buffers and not others. Other minor modes | ||
| 97 | are @dfn{global}: while enabled, they affect everything you do in the | ||
| 98 | Emacs session, in all buffers. Some global minor modes are enabled by | ||
| 99 | default. | ||
| 100 | |||
| 101 | Most minor modes say in the mode line when they are enabled, just | ||
| 102 | after the major mode indicator. For example, @samp{Fill} in the mode | ||
| 103 | line means that Auto Fill mode is enabled. @xref{Mode Line}. | ||
| 104 | |||
| 105 | Each minor mode is associated with a command, called the @dfn{mode | ||
| 106 | command}, which turns it on or off. The name of this command consists | ||
| 107 | of the name of the minor mode, followed by @samp{-mode}; for instance, | ||
| 108 | the mode command for Auto Fill mode is @code{auto-fill-mode}. Calling | ||
| 109 | the minor mode command with no prefix argument @dfn{toggles} the mode, | ||
| 110 | turning it on if it was off, and off if it was on. A positive | ||
| 111 | argument always turns the mode on, and a zero or negative argument | ||
| 112 | always turns it off. Mode commands are usually invoked with | ||
| 113 | @kbd{M-x}, but you can bind keys to them if you wish (@pxref{Key | ||
| 114 | Bindings}). | ||
| 115 | |||
| 116 | Most minor modes also have a @dfn{mode variable}, with the same name | ||
| 117 | as the mode command. Its value is non-@code{nil} if the mode is | ||
| 118 | enabled, and @code{nil} if it is disabled. In some minor modes---but | ||
| 119 | not all---the value of the variable alone determines whether the mode | ||
| 120 | is active: the mode command works simply by setting the variable, and | ||
| 121 | changing the value of the variable has the same effect as calling the | ||
| 122 | mode command. Because not all minor modes work this way, we recommend | ||
| 123 | that you avoid changing the mode variables directly; use the mode | ||
| 124 | commands instead. | ||
| 125 | |||
| 126 | The following is a list of some buffer-local minor modes: | ||
| 127 | |||
| 128 | @itemize @bullet | ||
| 129 | @item | ||
| 130 | Abbrev mode automatically expands text based on pre-defined | ||
| 131 | abbreviation definitions. @xref{Abbrevs}. | ||
| 132 | |||
| 133 | @item | ||
| 134 | Auto Fill mode inserts newlines as you type to prevent lines from | ||
| 135 | becoming too long. @xref{Filling}. | ||
| 136 | |||
| 137 | @item | ||
| 138 | Auto Save mode saves the buffer contents periodically to reduce the | ||
| 139 | amount of work you can lose in case of a crash. @xref{Auto Save}. | ||
| 140 | |||
| 141 | @item | ||
| 142 | Enriched mode enables editing and saving of formatted text. | ||
| 143 | @xref{Formatted Text}. | ||
| 144 | |||
| 145 | @item | ||
| 146 | Flyspell mode automatically highlights misspelled words. | ||
| 147 | @xref{Spelling}. | ||
| 148 | |||
| 149 | @item | ||
| 150 | Font-Lock mode automatically highlights certain textual units found in | ||
| 151 | programs. It is enabled globally by default, but you can disable it | ||
| 152 | in individual buffers. @xref{Faces}. | ||
| 153 | |||
| 154 | @findex linum-mode | ||
| 155 | @cindex Linum mode | ||
| 156 | @item | ||
| 157 | Linum mode displays each line's line number in the window's left | ||
| 158 | margin. Its mode command is @code{linum-mode}. | ||
| 159 | |||
| 160 | @item | ||
| 161 | Outline minor mode provides similar facilities to the major mode | ||
| 162 | called Outline mode. @xref{Outline Mode}. | ||
| 163 | |||
| 164 | @cindex Overwrite mode | ||
| 165 | @cindex mode, Overwrite | ||
| 166 | @findex overwrite-mode | ||
| 167 | @kindex INSERT | ||
| 168 | @item | ||
| 169 | Overwrite mode causes ordinary printing characters to replace existing | ||
| 170 | text instead of shoving it to the right. For example, if point is in | ||
| 171 | front of the @samp{B} in @samp{FOOBAR}, then in Overwrite mode typing | ||
| 172 | a @kbd{G} changes it to @samp{FOOGAR}, instead of producing | ||
| 173 | @samp{FOOGBAR} as usual. In Overwrite mode, the command @kbd{C-q} | ||
| 174 | inserts the next character whatever it may be, even if it is a | ||
| 175 | digit---this gives you a way to insert a character instead of | ||
| 176 | replacing an existing character. The mode command, | ||
| 177 | @code{overwrite-mode}, is bound to the @key{Insert} key. | ||
| 178 | |||
| 179 | @findex binary-overwrite-mode | ||
| 180 | @item | ||
| 181 | Binary Overwrite mode is a variant of Overwrite mode for editing | ||
| 182 | binary files; it treats newlines and tabs like other characters, so | ||
| 183 | that they overwrite other characters and can be overwritten by them. | ||
| 184 | In Binary Overwrite mode, digits after @kbd{C-q} specify an octal | ||
| 185 | character code, as usual. | ||
| 186 | |||
| 187 | @item | ||
| 188 | Visual Line mode performs ``word wrapping'', causing long lines to be | ||
| 189 | wrapped at word boundaries. @xref{Visual Line Mode}. | ||
| 190 | @end itemize | ||
| 191 | |||
| 192 | Here are some useful global minor modes. Since Line Number mode and | ||
| 193 | Transient Mark mode can be enabled or disabled just by setting the | ||
| 194 | value of the minor mode variable, you @emph{can} set them differently | ||
| 195 | for particular buffers, by explicitly making the corresponding | ||
| 196 | variable local in those buffers. @xref{Locals}. | ||
| 197 | |||
| 198 | @itemize @bullet | ||
| 199 | @item | ||
| 200 | Column Number mode enables display of the current column number in the | ||
| 201 | mode line. @xref{Mode Line}. | ||
| 202 | |||
| 203 | @item | ||
| 204 | Delete Selection mode causes text insertion to first delete the text | ||
| 205 | in the region, if the region is active. @xref{Using Region}. | ||
| 206 | |||
| 207 | @item | ||
| 208 | Icomplete mode displays an indication of available completions when | ||
| 209 | you are in the minibuffer and completion is active. @xref{Completion | ||
| 210 | Options}. | ||
| 211 | |||
| 212 | @item | ||
| 213 | Line Number mode enables display of the current line number in the | ||
| 214 | mode line. It is enabled by default. @xref{Mode Line}. | ||
| 215 | |||
| 216 | @item | ||
| 217 | Menu Bar mode gives each frame a menu bar. It is enabled by default. | ||
| 218 | @xref{Menu Bars}. | ||
| 219 | |||
| 220 | @item | ||
| 221 | Scroll Bar mode gives each window a scroll bar. It is enabled by | ||
| 222 | default, but the scroll bar is only displayed on graphical terminals. | ||
| 223 | @xref{Scroll Bars}. | ||
| 224 | |||
| 225 | @item | ||
| 226 | Tool Bar mode gives each frame a tool bar. It is enabled by default, | ||
| 227 | but the tool bar is only displayed on graphical terminals. @xref{Tool | ||
| 228 | Bars}. | ||
| 229 | |||
| 230 | @item | ||
| 231 | Transient Mark mode highlights the region, and makes many Emacs | ||
| 232 | commands operate on the region when the mark is active. It is enabled | ||
| 233 | by default. @xref{Mark}. | ||
| 234 | @end itemize | ||
| 235 | |||
| 236 | @node Choosing Modes | ||
| 237 | @section Choosing File Modes | ||
| 238 | |||
| 239 | @cindex choosing a major mode | ||
| 240 | @cindex choosing a minor mode | ||
| 241 | @vindex auto-mode-alist | ||
| 242 | When you visit a file, Emacs chooses a major mode automatically. | ||
| 243 | Normally, it makes the choice based on the file name---for example, | ||
| 244 | files whose names end in @samp{.c} are normally edited in C mode---but | ||
| 245 | sometimes it chooses the major mode based on special text in the file. | ||
| 246 | This special text can also be used to enable buffer-local minor modes. | ||
| 247 | |||
| 248 | Here is the exact procedure: | ||
| 249 | |||
| 250 | First, Emacs checks whether the file contains file-local mode | ||
| 251 | variables. @xref{File Variables}. If there is a file-local variable | ||
| 252 | that specifies a major mode, then Emacs uses that major mode, ignoring | ||
| 253 | all other criteria. There are several methods to specify a major mode | ||
| 254 | using a file-local variable; the simplest is to put the mode name in | ||
| 255 | the first nonblank line, preceded and followed by @samp{-*-}. Other | ||
| 256 | text may appear on the line as well. For example, | ||
| 257 | |||
| 258 | @example | ||
| 259 | ; -*-Lisp-*- | ||
| 260 | @end example | ||
| 261 | |||
| 262 | @noindent | ||
| 263 | tells Emacs to use Lisp mode. Note how the semicolon is used to make | ||
| 264 | Lisp treat this line as a comment. Alternatively, you could write | ||
| 265 | |||
| 266 | @example | ||
| 267 | ; -*- mode: Lisp;-*- | ||
| 268 | @end example | ||
| 269 | |||
| 270 | @noindent | ||
| 271 | The latter format allows you to specify local variables as well, like | ||
| 272 | this: | ||
| 273 | |||
| 274 | @example | ||
| 275 | ; -*- mode: Lisp; tab-width: 4; -*- | ||
| 276 | @end example | ||
| 277 | |||
| 278 | If a file variable specifies a buffer-local minor mode, Emacs | ||
| 279 | enables that minor mode in the buffer. | ||
| 280 | |||
| 281 | @vindex interpreter-mode-alist | ||
| 282 | Second, if there is no file variable specifying a major mode, Emacs | ||
| 283 | checks whether the file's contents begin with @samp{#!}. If so, that | ||
| 284 | indicates that the file can serve as an executable shell command, | ||
| 285 | which works by running an interpreter named on the file's first line | ||
| 286 | (the rest of the file is used as input to the interpreter). | ||
| 287 | Therefore, Emacs tries to use the interpreter name to choose a mode. | ||
| 288 | For instance, a file that begins with @samp{#!/usr/bin/perl} is opened | ||
| 289 | in Perl mode. The variable @code{interpreter-mode-alist} specifies | ||
| 290 | the correspondence between interpreter program names and major modes. | ||
| 291 | |||
| 292 | When the first line starts with @samp{#!}, you usually cannot use | ||
| 293 | the @samp{-*-} feature on the first line, because the system would get | ||
| 294 | confused when running the interpreter. So Emacs looks for @samp{-*-} | ||
| 295 | on the second line in such files as well as on the first line. The | ||
| 296 | same is true for man pages which start with the magic string | ||
| 297 | @samp{'\"} to specify a list of troff preprocessors. | ||
| 298 | |||
| 299 | @vindex magic-mode-alist | ||
| 300 | Third, Emacs tries to determine the major mode by looking at the | ||
| 301 | text at the start of the buffer, based on the variable | ||
| 302 | @code{magic-mode-alist}. By default, this variable is @code{nil} (an | ||
| 303 | empty list), so Emacs skips this step; however, you can customize it | ||
| 304 | in your init file (@pxref{Init File}). The value should be a list of | ||
| 305 | elements of the form | ||
| 306 | |||
| 307 | @example | ||
| 308 | (@var{regexp} . @var{mode-function}) | ||
| 309 | @end example | ||
| 310 | |||
| 311 | @noindent | ||
| 312 | where @var{regexp} is a regular expression (@pxref{Regexps}), and | ||
| 313 | @var{mode-function} is a Lisp function that toggles a major mode. If | ||
| 314 | the text at the beginning of the file matches @var{regexp}, Emacs | ||
| 315 | chooses the major mode specified by @var{mode-function}. | ||
| 316 | |||
| 317 | Alternatively, an element of @code{magic-mode-alist} may have the form | ||
| 318 | |||
| 319 | @example | ||
| 320 | (@var{match-function} . @var{mode-function}) | ||
| 321 | @end example | ||
| 322 | |||
| 323 | @noindent | ||
| 324 | where @var{match-function} is a Lisp function that is called at the | ||
| 325 | beginning of the buffer; if the function returns non-@code{nil}, Emacs | ||
| 326 | set the major mode wit @var{mode-function}. | ||
| 327 | |||
| 328 | Fourth---if Emacs still hasn't found a suitable major mode---it | ||
| 329 | looks at the file's name. The correspondence between file names and | ||
| 330 | major modes is controlled by the variable @code{auto-mode-alist}. Its | ||
| 331 | value is a list in which each element has this form, | ||
| 332 | |||
| 333 | @example | ||
| 334 | (@var{regexp} . @var{mode-function}) | ||
| 335 | @end example | ||
| 336 | |||
| 337 | @noindent | ||
| 338 | or this form, | ||
| 339 | |||
| 340 | @example | ||
| 341 | (@var{regexp} @var{mode-function} @var{flag}) | ||
| 342 | @end example | ||
| 343 | |||
| 344 | @noindent | ||
| 345 | For example, one element normally found in the list has the form | ||
| 346 | @code{(@t{"\\.c\\'"} . c-mode)}, and it is responsible for selecting C | ||
| 347 | mode for files whose names end in @file{.c}. (Note that @samp{\\} is | ||
| 348 | needed in Lisp syntax to include a @samp{\} in the string, which must | ||
| 349 | be used to suppress the special meaning of @samp{.} in regexps.) If | ||
| 350 | the element has the form @code{(@var{regexp} @var{mode-function} | ||
| 351 | @var{flag})} and @var{flag} is non-@code{nil}, then after calling | ||
| 352 | @var{mode-function}, Emacs discards the suffix that matched | ||
| 353 | @var{regexp} and searches the list again for another match. | ||
| 354 | |||
| 355 | @vindex auto-mode-case-fold | ||
| 356 | On systems with case-insensitive file names, such as Microsoft | ||
| 357 | Windows, Emacs performs a single case-insensitive search through | ||
| 358 | @code{auto-mode-alist}. On other systems, Emacs normally performs a | ||
| 359 | single case-sensitive search through the alist. However, if you | ||
| 360 | change the variable @code{auto-mode-case-fold} to @code{t}, Emacs | ||
| 361 | performs a second case-insensitive search if the first search fails. | ||
| 362 | |||
| 363 | @vindex magic-fallback-mode-alist | ||
| 364 | Finally, if Emacs @emph{still} hasn't found a major mode to use, it | ||
| 365 | compares the text at the start of the buffer to the variable | ||
| 366 | @code{magic-fallback-mode-alist}. This variable works like | ||
| 367 | @code{magic-mode-alist}, described above, except that is consulted | ||
| 368 | only after @code{auto-mode-alist}. By default, | ||
| 369 | @code{magic-fallback-mode-alist} contains forms that check for image | ||
| 370 | files, HTML/XML/SGML files, and Postscript files. | ||
| 371 | |||
| 372 | @vindex major-mode | ||
| 373 | Once a major mode is chosen, Emacs sets the value of the variable | ||
| 374 | @code{major-mode} to the symbol for that major mode (e.g., | ||
| 375 | @code{text-mode} for Text mode). This is a per-buffer variable | ||
| 376 | (@pxref{Locals}); its buffer-local value is set automatically, and you | ||
| 377 | should not change it yourself. | ||
| 378 | |||
| 379 | The default value of @code{major-mode} determines the major mode to | ||
| 380 | use for files that do not specify a major mode, and for new buffers | ||
| 381 | created with @kbd{C-x b}. Normally, this default value is the symbol | ||
| 382 | @code{fundamental-mode}, which specifies Fundamental mode. You can | ||
| 383 | change it via the Customization interface (@pxref{Easy | ||
| 384 | Customization}), or by adding a line like this to your init file | ||
| 385 | (@pxref{Init File}): | ||
| 386 | |||
| 387 | @smallexample | ||
| 388 | (setq-default major-mode 'text-mode) | ||
| 389 | @end smallexample | ||
| 390 | |||
| 391 | @noindent | ||
| 392 | If the default value of @code{major-mode} is @code{nil}, the major | ||
| 393 | mode is taken from the previously current buffer. | ||
| 394 | |||
| 395 | @findex normal-mode | ||
| 396 | If you have changed the major mode of a buffer, you can return to | ||
| 397 | the major mode Emacs would have chosen automatically, by typing | ||
| 398 | @kbd{M-x normal-mode}. This is the same function that | ||
| 399 | @code{find-file} calls to choose the major mode. It also processes | ||
| 400 | the file's @samp{-*-} line or local variables list (if any). | ||
| 401 | @xref{File Variables}. | ||
| 402 | |||
| 403 | @vindex change-major-mode-with-file-name | ||
| 404 | The commands @kbd{C-x C-w} and @code{set-visited-file-name} change to | ||
| 405 | a new major mode if the new file name implies a mode (@pxref{Saving}). | ||
| 406 | (@kbd{C-x C-s} does this too, if the buffer wasn't visiting a file.) | ||
| 407 | However, this does not happen if the buffer contents specify a major | ||
| 408 | mode, and certain ``special'' major modes do not allow the mode to | ||
| 409 | change. You can turn off this mode-changing feature by setting | ||
| 410 | @code{change-major-mode-with-file-name} to @code{nil}. | ||
diff --git a/doc/emacs/mule.texi b/doc/emacs/mule.texi index 3f3da503769..3c970ecb12c 100644 --- a/doc/emacs/mule.texi +++ b/doc/emacs/mule.texi | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | @c This is part of the Emacs manual. | 1 | @c This is part of the Emacs manual. |
| 2 | @c Copyright (C) 1997, 1999-2011 Free Software Foundation, Inc. | 2 | @c Copyright (C) 1997, 1999-2011 Free Software Foundation, Inc. |
| 3 | @c See file emacs.texi for copying conditions. | 3 | @c See file emacs.texi for copying conditions. |
| 4 | @node International, Major Modes, Frames, Top | 4 | @node International, Modes, Frames, Top |
| 5 | @chapter International Character Set Support | 5 | @chapter International Character Set Support |
| 6 | @c This node is referenced in the tutorial. When renaming or deleting | 6 | @c This node is referenced in the tutorial. When renaming or deleting |
| 7 | @c it, the tutorial needs to be adjusted. (TUTORIAL.de) | 7 | @c it, the tutorial needs to be adjusted. (TUTORIAL.de) |