@c -*-texinfo-*-
@c This is part of the GNU Emacs Lisp Reference Manual.
-@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2002,
-@c 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2001,
+@c 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
@c See the file elisp.texi for copying conditions.
@setfilename ../info/modes
@node Modes, Documentation, Keymaps, Top
@node Major Mode Conventions
@subsection Major Mode Conventions
+@cindex major mode conventions
+@cindex conventions for writing major modes
The code for existing major modes follows various coding conventions,
including conventions for local keymap and syntax table initialization,
global names, and hooks. Please follow these conventions when you
-define a new major mode.
+define a new major mode. (Fundamental mode is an exception to many
+of these conventions, because its definition is to present the global
+state of Emacs.)
This list of conventions is only partial, because each major mode
should aim for consistency in general with other Emacs major modes.
@node Auto Major Mode
@subsection How Emacs Chooses a Major Mode
+@cindex major mode, automatic selection
Based on information in the file name or in the file itself, Emacs
automatically selects a major mode for the new buffer when a file is
@code{auto-mode-alist} gets to decide the mode.
@end defvar
+@defvar file-start-mode-alist
+This works like @code{magic-mode-alist}, except that it is handled
+only if @code{auto-mode-alist} does not specify a mode for this file.
+@end defvar
+
@defvar auto-mode-alist
This variable contains an association list of file name patterns
(regular expressions) and corresponding major mode commands. Usually,
@end group
@end smallexample
- But here is how it was defined formerly, before
+@noindent
+(The last line is redundant nowadays, since @code{indent-relative} is
+the default value, and we'll delete it in a future version.)
+
+ Here is how it was defined formerly, before
@code{define-derived-mode} existed:
@smallexample
@group
(setq imenu-case-fold-search t)
(set-syntax-table lisp-mode-syntax-table)
- (run-mode-hooks 'lisp-mode-hook)) ; @r{This permits the user to use a}
+ (run-mode-hooks 'lisp-mode-hook)) ; @r{This permits the user to use a}
; @r{hook to customize the mode.}
@end group
@end smallexample
Definitions}.
@item :global @var{global}
-If non-@code{nil} specifies that the minor mode should be global. By
-default, minor modes defined with @code{define-minor-mode} are
-buffer-local.
+If non-@code{nil}, this specifies that the minor mode should be global
+rather than buffer-local. It defaults to @code{nil}.
+
+One of the effects of making a minor mode global is that the
+@var{mode} variable becomes a customization variable. Toggling it
+through the Custom interface turns the mode on and off, and its value
+can be saved for future Emacs sessions (@pxref{Saving
+Customizations,,, emacs, The GNU Emacs Manual}. For the saved
+variable to work, you should ensure that the @code{define-minor-mode}
+form is evaluated each time Emacs starts; for packages that are not
+part of Emacs, the easiest way to do this is to specify a
+@code{:require} keyword.
@item :init-value @var{init-value}
This is equivalent to specifying @var{init-value} positionally.
:group 'hunger)
@end smallexample
-@defmac define-global-minor-mode global-mode mode turn-on keyword-args@dots{}
+@defmac define-globalized-minor-mode global-mode mode turn-on keyword-args@dots{}
This defines a global toggle named @var{global-mode} whose meaning is
to enable or disable the buffer-local minor mode @var{mode} in all
buffers. To turn on the minor mode in a buffer, it uses the function
Fundamental mode; but it does not detect the creation of a new buffer
in Fundamental mode.
+This defines the customization option @var{global-mode} (@pxref{Customization}),
+which can be toggled in the Custom interface to turn the minor mode on
+and off. As with @code{define-minor-mode}, you should ensure that the
+@code{define-globalized-minor-mode} form is evaluated each time Emacs
+starts, for example by providing a @code{:require} keyword.
+
Use @code{:group @var{group}} in @var{keyword-args} to specify the
custom group for the mode variable of the global minor mode.
@end defmac
the user or by Lisp programs (such as @code{display-time} and major
modes) via changes to those variables remain effective.
-@cindex Shell mode @code{mode-line-format}
Here is an example of a @code{mode-line-format} that might be
useful for @code{shell-mode}, since it contains the host name and default
directory.
@node Font Lock Mode
@section Font Lock Mode
-@cindex Font Lock Mode
+@cindex Font Lock mode
@dfn{Font Lock mode} is a feature that automatically attaches
@code{face} properties to certain parts of the buffer based on their
@node Faces for Font Lock
@subsection Faces for Font Lock
+@cindex faces for font lock
+@cindex font lock faces
You can make Font Lock mode use any face, but several faces are
defined specifically for Font Lock mode. Each of these symbols is both
@node Syntactic Font Lock
@subsection Syntactic Font Lock
+@cindex syntactic font lock
Syntactic fontification uses the syntax table to find comments and
string constants (@pxref{Syntax Tables}). It highlights them using