Commit 8875da1e authored by Chong Yidong's avatar Chong Yidong
Browse files

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.
parent 6cfd0fa2
2011-07-10 Chong Yidong <cyd@stupidchicken.com>
* modes.texi: Rename from major.texi.
(Modes): New node. Make Major Modes and Minor Modes subsections
of this. All callers changed.
* custom.texi (Minor Modes): Move to modes.texi.
2011-07-10 Chong Yidong <cyd@stupidchicken.com> 2011-07-10 Chong Yidong <cyd@stupidchicken.com>
* custom.texi (Syntax): Node deleted. * custom.texi (Syntax): Node deleted.
......
...@@ -84,7 +84,7 @@ EMACSSOURCES= \ ...@@ -84,7 +84,7 @@ EMACSSOURCES= \
${srcdir}/windows.texi \ ${srcdir}/windows.texi \
${srcdir}/frames.texi \ ${srcdir}/frames.texi \
${srcdir}/mule.texi \ ${srcdir}/mule.texi \
${srcdir}/major.texi \ ${srcdir}/modes.texi \
${srcdir}/indent.texi \ ${srcdir}/indent.texi \
${srcdir}/text.texi \ ${srcdir}/text.texi \
${srcdir}/programs.texi \ ${srcdir}/programs.texi \
......
...@@ -23,8 +23,6 @@ Reference Manual}. ...@@ -23,8 +23,6 @@ Reference Manual}.
@end ifnottex @end ifnottex
@menu @menu
* Minor Modes:: Each minor mode is a feature you can turn on
independently of any others.
* Easy Customization:: Convenient way to browse and change settings. * Easy Customization:: Convenient way to browse and change settings.
* Variables:: Many Emacs commands examine Emacs variables * Variables:: Many Emacs commands examine Emacs variables
to decide what to do; by setting variables, to decide what to do; by setting variables,
...@@ -35,155 +33,6 @@ Reference Manual}. ...@@ -35,155 +33,6 @@ Reference Manual}.
@file{.emacs} file. @file{.emacs} file.
@end menu @end menu
@node Minor Modes
@section Minor Modes
@cindex minor modes
@cindex mode, minor
Minor modes are optional features which you can turn on or off. For
example, Auto Fill mode is a minor mode in which @key{SPC} breaks
lines between words as you type. Minor modes are independent of one
another and of the selected major mode. Most minor modes say in the
mode line when they are enabled; for example, @samp{Fill} in the mode
line means that Auto Fill mode is enabled.
Each minor mode is associated with a command, called the @dfn{mode
command}, which turns it on or off. The name of this command consists
of the name of the minor mode, followed by @samp{-mode}; for instance,
the mode command for Auto Fill mode is @code{auto-fill-mode}. Calling
the minor mode command with no prefix argument @dfn{toggles} the mode,
turning it on if it was off, and off if it was on. A positive
argument always turns the mode on, and a zero or negative argument
always turns it off. Mode commands are usually invoked with
@kbd{M-x}, but you can bind keys to them if you wish (@pxref{Key
Bindings}).
Most minor modes also have a @dfn{mode variable}, with the same name
as the mode command. Its value is non-@code{nil} if the mode is
enabled, and @code{nil} if it is disabled. In some minor modes---but
not all---the value of the variable alone determines whether the mode
is active: the mode command works simply by setting the variable, and
changing the value of the variable has the same effect as calling the
mode command. Because not all minor modes work this way, we recommend
that you avoid changing the mode variables directly; use the mode
commands instead.
Some minor modes are @dfn{buffer-local}: they apply only to the
current buffer, so you can enable the mode in certain buffers and not
others. Other minor modes are @dfn{global}: while enabled, they
affect everything you do in the Emacs session, in all buffers. Some
global minor modes are enabled by default.
The following is a list of some buffer-local minor modes:
@itemize @bullet
@item
Abbrev mode automatically expands text based on pre-defined
abbreviation definitions. @xref{Abbrevs}.
@item
Auto Fill mode inserts newlines as you type to prevent lines from
becoming too long. @xref{Filling}.
@item
Auto Save mode saves the buffer contents periodically to reduce the
amount of work you can lose in case of a crash. @xref{Auto Save}.
@item
Enriched mode enables editing and saving of formatted text.
@xref{Formatted Text}.
@item
Flyspell mode automatically highlights misspelled words.
@xref{Spelling}.
@item
Font-Lock mode automatically highlights certain textual units found in
programs. It is enabled globally by default, but you can disable it
in individual buffers. @xref{Faces}.
@findex linum-mode
@cindex Linum mode
@item
Linum mode displays each line's line number in the window's left
margin. Its mode command is @code{linum-mode}.
@item
Outline minor mode provides similar facilities to the major mode
called Outline mode. @xref{Outline Mode}.
@cindex Overwrite mode
@cindex mode, Overwrite
@findex overwrite-mode
@kindex INSERT
@item
Overwrite mode causes ordinary printing characters to replace existing
text instead of shoving it to the right. For example, if point is in
front of the @samp{B} in @samp{FOOBAR}, then in Overwrite mode typing
a @kbd{G} changes it to @samp{FOOGAR}, instead of producing
@samp{FOOGBAR} as usual. In Overwrite mode, the command @kbd{C-q}
inserts the next character whatever it may be, even if it is a
digit---this gives you a way to insert a character instead of
replacing an existing character. The mode command,
@code{overwrite-mode}, is bound to the @key{Insert} key.
@findex binary-overwrite-mode
@item
Binary Overwrite mode is a variant of Overwrite mode for editing
binary files; it treats newlines and tabs like other characters, so
that they overwrite other characters and can be overwritten by them.
In Binary Overwrite mode, digits after @kbd{C-q} specify an octal
character code, as usual.
@item
Visual Line mode performs ``word wrapping'', causing long lines to be
wrapped at word boundaries. @xref{Visual Line Mode}.
@end itemize
Here are some useful global minor modes. Since Line Number mode and
Transient Mark mode can be enabled or disabled just by setting the
value of the minor mode variable, you @emph{can} set them differently
for particular buffers, by explicitly making the corresponding
variable local in those buffers. @xref{Locals}.
@itemize @bullet
@item
Column Number mode enables display of the current column number in the
mode line. @xref{Mode Line}.
@item
Delete Selection mode causes text insertion to first delete the text
in the region, if the region is active. @xref{Using Region}.
@item
Icomplete mode displays an indication of available completions when
you are in the minibuffer and completion is active. @xref{Completion
Options}.
@item
Line Number mode enables display of the current line number in the
mode line. It is enabled by default. @xref{Mode Line}.
@item
Menu Bar mode gives each frame a menu bar. It is enabled by default.
@xref{Menu Bars}.
@item
Scroll Bar mode gives each window a scroll bar. It is enabled by
default, but the scroll bar is only displayed on graphical terminals.
@xref{Scroll Bars}.
@item
Tool Bar mode gives each frame a tool bar. It is enabled by default,
but the tool bar is only displayed on graphical terminals. @xref{Tool
Bars}.
@item
Transient Mark mode highlights the region, and makes many Emacs
commands operate on the region when the mark is active. It is enabled
by default. @xref{Mark}.
@end itemize
@node Easy Customization @node Easy Customization
@section Easy Customization Interface @section Easy Customization Interface
......
...@@ -184,7 +184,7 @@ Major Structures of Emacs ...@@ -184,7 +184,7 @@ Major Structures of Emacs
* International:: Using non-@acronym{ASCII} character sets. * International:: Using non-@acronym{ASCII} character sets.
Advanced Features Advanced Features
* Major Modes:: Text mode vs. Lisp mode vs. C mode... * Modes:: Major and minor modes alter Emacs' basic behavior.
* Indentation:: Editing the white space at the beginnings of lines. * Indentation:: Editing the white space at the beginnings of lines.
* Text:: Commands and modes for editing English. * Text:: Commands and modes for editing English.
* Programs:: Commands and modes for editing programs. * Programs:: Commands and modes for editing programs.
...@@ -549,9 +549,12 @@ International Character Set Support ...@@ -549,9 +549,12 @@ International Character Set Support
to use without multibyte characters. to use without multibyte characters.
* Charsets:: How Emacs groups its internal character codes. * Charsets:: How Emacs groups its internal character codes.
Major Modes Modes
* Choosing Modes:: How major modes are specified or chosen. * Major Modes:: Text mode vs. Lisp mode vs. C mode...
* Minor Modes:: Each minor mode is a feature you can turn on
independently of any others.
* Choosing Modes:: How modes are chosen when visiting files.
Indentation Indentation
...@@ -1058,8 +1061,6 @@ Hyperlinking and Navigation Features ...@@ -1058,8 +1061,6 @@ Hyperlinking and Navigation Features
Customization Customization
* Minor Modes:: Each minor mode is a feature you can turn on
independently of any others.
* Easy Customization:: Convenient way to browse and change settings. * Easy Customization:: Convenient way to browse and change settings.
* Variables:: Many Emacs commands examine Emacs variables * Variables:: Many Emacs commands examine Emacs variables
to decide what to do; by setting variables, to decide what to do; by setting variables,
...@@ -1485,7 +1486,7 @@ Lisp programming. ...@@ -1485,7 +1486,7 @@ Lisp programming.
@include windows.texi @include windows.texi
@include frames.texi @include frames.texi
@include mule.texi @include mule.texi
@include major.texi @include modes.texi
@include indent.texi @include indent.texi
@include text.texi @include text.texi
@c Includes fortran-xtra. @c Includes fortran-xtra.
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
@c Copyright (C) 1985-1987, 1993-1995, 1997, 2001-2011 @c Copyright (C) 1985-1987, 1993-1995, 1997, 2001-2011
@c Free Software Foundation, Inc. @c Free Software Foundation, Inc.
@c See file emacs.texi for copying conditions. @c See file emacs.texi for copying conditions.
@node Indentation, Text, Major Modes, Top @node Indentation, Text, Modes, Top
@chapter Indentation @chapter Indentation
@cindex indentation @cindex indentation
@cindex tabs @cindex tabs
......
...@@ -2,35 +2,67 @@ ...@@ -2,35 +2,67 @@
@c Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2011 @c Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2011
@c Free Software Foundation, Inc. @c Free Software Foundation, Inc.
@c See file emacs.texi for copying conditions. @c See file emacs.texi for copying conditions.
@node Major Modes, Indentation, International, Top @node Modes, Indentation, International, Top
@chapter Major Modes @chapter Editing Modes
Emacs contains many @dfn{editing modes}, each of which alters its
basic behavior in useful ways. These are divided into @dfn{major
modes} and @dfn{minor modes}.
Major modes provide specialized facilities for working on a
particular file type, such as a C source file (@pxref{Programs}), or a
particular type of non-file buffer, such as a shell buffer
(@pxref{Shell}). Major modes are mutually exclusive; each buffer has
one and only one major mode at any time.
Minor modes are optional features which you can turn on or off, not
necessarily specific to a type of file or buffer. For example, Auto
Fill mode is a minor mode in which @key{SPC} breaks lines between
words as you type (@pxref{Auto Fill}). Minor modes are independent of
one another, and of the selected major mode.
@menu
* Major Modes:: Text mode vs. Lisp mode vs. C mode...
* Minor Modes:: Each minor mode is a feature you can turn on
independently of any others.
* Choosing Modes:: How modes are chosen when visiting files.
@end menu
@node Major Modes
@section Major Modes
@cindex major modes @cindex major modes
@cindex mode, major @cindex mode, major
@kindex TAB @r{(and major modes)} @kindex TAB @r{(and major modes)}
@kindex DEL @r{(and major modes)} @kindex DEL @r{(and major modes)}
@kindex C-j @r{(and major modes)} @kindex C-j @r{(and major modes)}
Emacs provides many alternative @dfn{major modes}, each of which Every buffer possesses a major mode, which determines the editing
customizes Emacs for editing text of a particular sort. The major modes behavior of Emacs while that buffer is current. The mode line
are mutually exclusive, and each buffer has one major mode at any time. normally shows the name of the current major mode, in parentheses.
The mode line normally shows the name of the current major mode, in @xref{Mode Line}.
parentheses (@pxref{Mode Line}).
Usually, the major mode is automatically set by Emacs, when you
first visit a file or create a buffer. @xref{Choosing Modes}. You
can explicitly select a new major mode by using an @kbd{M-x} command.
Take the name of the mode and add @code{-mode} to get the name of the
command to select that mode. Thus, you can enter Lisp mode with
@kbd{M-x lisp-mode}.
The least specialized major mode is called @dfn{Fundamental mode}. The least specialized major mode is called @dfn{Fundamental mode}.
This mode has no mode-specific redefinitions or variable settings, so This mode has no mode-specific redefinitions or variable settings, so
that each Emacs command behaves in its most general manner, and each that each Emacs command behaves in its most general manner, and each
user option variable is in its default state. For editing text of a user option variable is in its default state.
specific type that Emacs knows about, such as Lisp code or English
text, you should switch to the appropriate major mode, such as Lisp For editing text of a specific type that Emacs knows about, such as
mode or Text mode. Lisp code or English text, you typically use a more specialized major
mode, such as Lisp mode or Text mode. Such major modes change the
Selecting a major mode changes the meanings of a few keys to become meanings of some keys to become more specifically adapted to the
more specifically adapted to the language being edited. The ones that language being edited. The ones that are commonly changed are
are changed frequently are @key{TAB}, @key{DEL}, and @kbd{C-j}. The @key{TAB}, @key{DEL}, and @kbd{C-j}. The prefix key @kbd{C-c}
prefix key @kbd{C-c} normally contains mode-specific commands. In normally contains mode-specific commands. In addition, the commands
addition, the commands which handle comments use the mode to determine which handle comments use the mode to determine how comments are to be
how comments are to be delimited. Many major modes redefine the delimited. Many major modes redefine the syntactical properties of
syntactical properties of characters appearing in the buffer. characters appearing in the buffer.
The major modes fall into three major groups. The first group The major modes fall into three major groups. The first group
contains modes for normal text, either plain or with mark-up. It contains modes for normal text, either plain or with mark-up. It
...@@ -52,37 +84,176 @@ definition of @key{TAB} to indent the new lines it creates. This is ...@@ -52,37 +84,176 @@ definition of @key{TAB} to indent the new lines it creates. This is
because most lines in a program are usually indented because most lines in a program are usually indented
(@pxref{Indentation}). (@pxref{Indentation}).
@menu @node Minor Modes
* Choosing Modes:: How major modes are specified or chosen. @section Minor Modes
@end menu @cindex minor modes
@cindex mode, minor
@node Choosing Modes,,Major Modes,Major Modes
@section How Major Modes are Chosen A minor mode is an optional editing modes that alters the behavior
of Emacs in some well-defined way. Unlike major modes, any number of
minor modes can be in effect at any time. Some minor modes are
@dfn{buffer-local}: they apply only to the current buffer, so you can
enable the mode in certain buffers and not others. Other minor modes
are @dfn{global}: while enabled, they affect everything you do in the
Emacs session, in all buffers. Some global minor modes are enabled by
default.
Most minor modes say in the mode line when they are enabled, just
after the major mode indicator. For example, @samp{Fill} in the mode
line means that Auto Fill mode is enabled. @xref{Mode Line}.
Each minor mode is associated with a command, called the @dfn{mode
command}, which turns it on or off. The name of this command consists
of the name of the minor mode, followed by @samp{-mode}; for instance,
the mode command for Auto Fill mode is @code{auto-fill-mode}. Calling
the minor mode command with no prefix argument @dfn{toggles} the mode,
turning it on if it was off, and off if it was on. A positive
argument always turns the mode on, and a zero or negative argument
always turns it off. Mode commands are usually invoked with
@kbd{M-x}, but you can bind keys to them if you wish (@pxref{Key
Bindings}).
Most minor modes also have a @dfn{mode variable}, with the same name
as the mode command. Its value is non-@code{nil} if the mode is
enabled, and @code{nil} if it is disabled. In some minor modes---but
not all---the value of the variable alone determines whether the mode
is active: the mode command works simply by setting the variable, and
changing the value of the variable has the same effect as calling the
mode command. Because not all minor modes work this way, we recommend
that you avoid changing the mode variables directly; use the mode
commands instead.
The following is a list of some buffer-local minor modes:
@itemize @bullet
@item
Abbrev mode automatically expands text based on pre-defined
abbreviation definitions. @xref{Abbrevs}.
@item
Auto Fill mode inserts newlines as you type to prevent lines from
becoming too long. @xref{Filling}.
@item
Auto Save mode saves the buffer contents periodically to reduce the
amount of work you can lose in case of a crash. @xref{Auto Save}.
@item
Enriched mode enables editing and saving of formatted text.
@xref{Formatted Text}.
@item
Flyspell mode automatically highlights misspelled words.
@xref{Spelling}.
@item
Font-Lock mode automatically highlights certain textual units found in
programs. It is enabled globally by default, but you can disable it
in individual buffers. @xref{Faces}.
@findex linum-mode
@cindex Linum mode
@item
Linum mode displays each line's line number in the window's left
margin. Its mode command is @code{linum-mode}.
@item
Outline minor mode provides similar facilities to the major mode
called Outline mode. @xref{Outline Mode}.
@cindex Overwrite mode
@cindex mode, Overwrite
@findex overwrite-mode
@kindex INSERT
@item
Overwrite mode causes ordinary printing characters to replace existing
text instead of shoving it to the right. For example, if point is in
front of the @samp{B} in @samp{FOOBAR}, then in Overwrite mode typing
a @kbd{G} changes it to @samp{FOOGAR}, instead of producing
@samp{FOOGBAR} as usual. In Overwrite mode, the command @kbd{C-q}
inserts the next character whatever it may be, even if it is a
digit---this gives you a way to insert a character instead of
replacing an existing character. The mode command,
@code{overwrite-mode}, is bound to the @key{Insert} key.
@findex binary-overwrite-mode
@item
Binary Overwrite mode is a variant of Overwrite mode for editing
binary files; it treats newlines and tabs like other characters, so
that they overwrite other characters and can be overwritten by them.
In Binary Overwrite mode, digits after @kbd{C-q} specify an octal
character code, as usual.
@item
Visual Line mode performs ``word wrapping'', causing long lines to be
wrapped at word boundaries. @xref{Visual Line Mode}.
@end itemize
Here are some useful global minor modes. Since Line Number mode and
Transient Mark mode can be enabled or disabled just by setting the
value of the minor mode variable, you @emph{can} set them differently
for particular buffers, by explicitly making the corresponding
variable local in those buffers. @xref{Locals}.
@itemize @bullet
@item
Column Number mode enables display of the current column number in the
mode line. @xref{Mode Line}.
@item
Delete Selection mode causes text insertion to first delete the text
in the region, if the region is active. @xref{Using Region}.
@item
Icomplete mode displays an indication of available completions when
you are in the minibuffer and completion is active. @xref{Completion
Options}.
@item
Line Number mode enables display of the current line number in the
mode line. It is enabled by default. @xref{Mode Line}.
@item
Menu Bar mode gives each frame a menu bar. It is enabled by default.
@xref{Menu Bars}.
@item
Scroll Bar mode gives each window a scroll bar. It is enabled by
default, but the scroll bar is only displayed on graphical terminals.
@xref{Scroll Bars}.
@item
Tool Bar mode gives each frame a tool bar. It is enabled by default,
but the tool bar is only displayed on graphical terminals. @xref{Tool
Bars}.
@item
Transient Mark mode highlights the region, and makes many Emacs
commands operate on the region when the mark is active. It is enabled
by default. @xref{Mark}.
@end itemize
@node Choosing Modes
@section Choosing File Modes
@cindex choosing a major mode @cindex choosing a major mode
You can select a major mode explicitly for the current buffer, but @cindex choosing a minor mode
most of the time Emacs determines which mode to use based on the file
name or on special text in the file.
To explicitly select a new major, you use an @kbd{M-x} command.
Take the name of a major mode and add @code{-mode} to get the name of
the command to select that mode. Thus, you can enter Lisp mode by
executing @kbd{M-x lisp-mode}.
@vindex auto-mode-alist @vindex auto-mode-alist
When you visit a file, Emacs usually chooses the right major mode When you visit a file, Emacs chooses a major mode automatically.
automatically. Normally, it makes the choice based on the file Normally, it makes the choice based on the file name---for example,
name---for example, files whose names end in @samp{.c} are normally files whose names end in @samp{.c} are normally edited in C mode---but
edited in C mode---but sometimes it chooses the major mode based on sometimes it chooses the major mode based on special text in the file.
the contents of the file. Here is the exact procedure: This special text can also be used to enable buffer-local minor modes.
First, Emacs checks whether the file contains a file-local variable Here is the exact procedure:
that specifies the major mode. If so, it uses that major mode,
ignoring all other criteria. @xref{File Variables}. There are First, Emacs checks whether the file contains file-local mode
several methods to specify a major mode using a file-local variable; variables. @xref{File Variables}. If there is a file-local variable
the simplest is to put the mode name in the first nonblank line, that specifies a major mode, then Emacs uses that major mode, ignoring
preceded and followed by @samp{-*-}. Other text may appear on the all other criteria. There are several methods to specify a major mode
line as well. For example, using a file-local variable; the simplest is to put the mode name in
the first nonblank line, preceded and followed by @samp{-*-}. Other
text may appear on the line as well. For example,
@example @example
; -*-Lisp-*- ; -*-Lisp-*-
...@@ -104,16 +275,19 @@ this: ...@@ -104,16 +275,19 @@ this:
; -*- mode: Lisp; tab-width: 4; -*- ; -*- mode: Lisp; tab-width: 4; -*-
@end example @end example
If a file variable specifies a buffer-local minor mode, Emacs
enables that minor mode in the buffer.
@vindex interpreter-mode-alist @vindex interpreter-mode-alist
Second, Emacs checks whether the file's contents begin with Second, if there is no file variable specifying a major mode, Emacs
@samp{#!}. If so, that indicates that the file can serve as an checks whether the file's contents begin with @samp{#!}. If so, that
executable shell command, which works by running an interpreter named indicates that the file can serve as an executable shell command,
on the file's first line (the rest of the file is used as input to the which works by running an interpreter named on the file's first line
interpreter). Therefore, Emacs tries to use the interpreter name to (the rest of the file is used as input to the interpreter).
choose a mode. For instance, a file that begins with Therefore, Emacs tries to use the interpreter name to choose a mode.
@samp{#!/usr/bin/perl} is opened in Perl mode. The variable For instance, a file that begins with @samp{#!/usr/bin/perl} is opened
@code{interpreter-mode-alist} specifies the correspondence between in Perl mode. The variable @code{interpreter-mode-alist} specifies
interpreter program names and major modes. the correspondence between interpreter program names and major modes.
When the first line starts with @samp{#!}, you usually cannot use When the first line starts with @samp{#!}, you usually cannot use
the @samp{-*-} feature on the first line, because the system would get the @samp{-*-} feature on the first line, because the system would get
......
@c This is part of the Emacs manual. @c This is part of the Emacs manual.
@c Copyright (C) 1997, 1999-2011 Free Software Foundation, Inc. @c Copyright (C) 1997, 1999-2011 Free Software Foundation, Inc.
@c See file emacs.texi for copying conditions. @c See file emacs.texi for copying conditions.
@node International, Major Modes, Frames, Top @node International, Modes, Frames, Top
@chapter International Character Set Support @chapter International Character Set Support
@c This node is referenced in the tutorial. When renaming or deleting @c This node is referenced in the tutorial. When renaming or deleting
@c it, the tutorial needs to be adjusted. (TUTORIAL.de) @c it, the tutorial needs to be adjusted. (TUTORIAL.de)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment