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

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>
* custom.texi (Syntax): Node deleted.
......
......@@ -84,7 +84,7 @@ EMACSSOURCES= \
${srcdir}/windows.texi \
${srcdir}/frames.texi \
${srcdir}/mule.texi \
${srcdir}/major.texi \
${srcdir}/modes.texi \
${srcdir}/indent.texi \
${srcdir}/text.texi \
${srcdir}/programs.texi \
......
......@@ -23,8 +23,6 @@ Reference Manual}.
@end ifnottex
@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.
* Variables:: Many Emacs commands examine Emacs variables
to decide what to do; by setting variables,
......@@ -35,155 +33,6 @@ Reference Manual}.
@file{.emacs} file.
@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
@section Easy Customization Interface
......
......@@ -184,7 +184,7 @@ Major Structures of Emacs
* International:: Using non-@acronym{ASCII} character sets.
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.
* Text:: Commands and modes for editing English.
* Programs:: Commands and modes for editing programs.
......@@ -549,9 +549,12 @@ International Character Set Support
to use without multibyte characters.
* 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
......@@ -1058,8 +1061,6 @@ Hyperlinking and Navigation Features
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.
* Variables:: Many Emacs commands examine Emacs variables
to decide what to do; by setting variables,
......@@ -1485,7 +1486,7 @@ Lisp programming.
@include windows.texi
@include frames.texi
@include mule.texi
@include major.texi
@include modes.texi
@include indent.texi
@include text.texi
@c Includes fortran-xtra.
......
......@@ -2,7 +2,7 @@
@c Copyright (C) 1985-1987, 1993-1995, 1997, 2001-2011
@c Free Software Foundation, Inc.
@c See file emacs.texi for copying conditions.
@node Indentation, Text, Major Modes, Top
@node Indentation, Text, Modes, Top
@chapter Indentation
@cindex indentation
@cindex tabs
......
......@@ -2,35 +2,67 @@
@c Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2011
@c Free Software Foundation, Inc.
@c See file emacs.texi for copying conditions.
@node Major Modes, Indentation, International, Top
@chapter Major Modes
@node Modes, Indentation, International, Top
@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 mode, major
@kindex TAB @r{(and major modes)}
@kindex DEL @r{(and major modes)}
@kindex C-j @r{(and major modes)}
Emacs provides many alternative @dfn{major modes}, each of which
customizes Emacs for editing text of a particular sort. The major modes
are mutually exclusive, and each buffer has one major mode at any time.
The mode line normally shows the name of the current major mode, in
parentheses (@pxref{Mode Line}).
Every buffer possesses a major mode, which determines the editing
behavior of Emacs while that buffer is current. The mode line
normally shows the name of the current major mode, in parentheses.
@xref{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}.
This mode has no mode-specific redefinitions or variable settings, so
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
specific type that Emacs knows about, such as Lisp code or English
text, you should switch to the appropriate major mode, such as Lisp
mode or Text mode.
Selecting a major mode changes the meanings of a few keys to become
more specifically adapted to the language being edited. The ones that
are changed frequently are @key{TAB}, @key{DEL}, and @kbd{C-j}. The
prefix key @kbd{C-c} normally contains mode-specific commands. In
addition, the commands which handle comments use the mode to determine
how comments are to be delimited. Many major modes redefine the
syntactical properties of characters appearing in the buffer.
user option variable is in its default state.
For editing text of a specific type that Emacs knows about, such as
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
meanings of some keys to become more specifically adapted to the
language being edited. The ones that are commonly changed are
@key{TAB}, @key{DEL}, and @kbd{C-j}. The prefix key @kbd{C-c}
normally contains mode-specific commands. In addition, the commands
which handle comments use the mode to determine how comments are to be
delimited. Many major modes redefine the syntactical properties of
characters appearing in the buffer.
The major modes fall into three major groups. The first group
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
because most lines in a program are usually indented
(@pxref{Indentation}).
@menu
* Choosing Modes:: How major modes are specified or chosen.
@end menu
@node Choosing Modes,,Major Modes,Major Modes
@section How Major Modes are Chosen
@node Minor Modes
@section Minor Modes
@cindex minor modes
@cindex mode, minor
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
You can select a major mode explicitly for the current buffer, but
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}.
@cindex choosing a minor mode
@vindex auto-mode-alist
When you visit a file, Emacs usually chooses the right major mode
automatically. Normally, it makes the choice based on the file
name---for example, files whose names end in @samp{.c} are normally
edited in C mode---but sometimes it chooses the major mode based on
the contents of the file. Here is the exact procedure:
First, Emacs checks whether the file contains a file-local variable
that specifies the major mode. If so, it uses that major mode,
ignoring all other criteria. @xref{File Variables}. There are
several methods to specify a major mode 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,
When you visit a file, Emacs chooses a major mode automatically.
Normally, it makes the choice based on the file name---for example,
files whose names end in @samp{.c} are normally edited in C mode---but
sometimes it chooses the major mode based on special text in the file.
This special text can also be used to enable buffer-local minor modes.
Here is the exact procedure:
First, Emacs checks whether the file contains file-local mode
variables. @xref{File Variables}. If there is a file-local variable
that specifies a major mode, then Emacs uses that major mode, ignoring
all other criteria. There are several methods to specify a major mode
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
; -*-Lisp-*-
......@@ -104,16 +275,19 @@ this:
; -*- mode: Lisp; tab-width: 4; -*-
@end example
If a file variable specifies a buffer-local minor mode, Emacs
enables that minor mode in the buffer.
@vindex interpreter-mode-alist
Second, Emacs checks whether the file's contents begin with
@samp{#!}. If so, that indicates that the file can serve as an
executable shell command, which works by running an interpreter named
on the file's first line (the rest of the file is used as input to the
interpreter). Therefore, Emacs tries to use the interpreter name to
choose a mode. For instance, a file that begins with
@samp{#!/usr/bin/perl} is opened in Perl mode. The variable
@code{interpreter-mode-alist} specifies the correspondence between
interpreter program names and major modes.
Second, if there is no file variable specifying a major mode, Emacs
checks whether the file's contents begin with @samp{#!}. If so, that
indicates that the file can serve as an executable shell command,
which works by running an interpreter named on the file's first line
(the rest of the file is used as input to the interpreter).
Therefore, Emacs tries to use the interpreter name to choose a mode.
For instance, a file that begins with @samp{#!/usr/bin/perl} is opened
in Perl mode. The variable @code{interpreter-mode-alist} specifies
the correspondence between interpreter program names and major modes.
When the first line starts with @samp{#!}, you usually cannot use
the @samp{-*-} feature on the first line, because the system would get
......
@c This is part of the Emacs manual.
@c Copyright (C) 1997, 1999-2011 Free Software Foundation, Inc.
@c See file emacs.texi for copying conditions.
@node International, Major Modes, Frames, Top
@node International, Modes, Frames, Top
@chapter International Character Set Support
@c This node is referenced in the tutorial. When renaming or deleting
@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