(Example Major Modes): Explain last line of text-mode is redundant.
[bpt/emacs.git] / lispref / modes.texi
index b46c0c0..6d9aabe 100644 (file)
@@ -1,7 +1,7 @@
 @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
@@ -252,11 +252,15 @@ Fundamental mode.  Rmail mode is a complicated and specialized mode.
 
 @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.
@@ -493,6 +497,7 @@ Even if you never load the file more than once, someone else will.
 
 @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
@@ -611,6 +616,11 @@ the text at the beginning of the buffer matches @var{regexp} and
 @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,
@@ -946,7 +956,11 @@ Turning on Text mode runs the normal hook `text-mode-hook'."
 @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
@@ -1155,7 +1169,7 @@ if that value is non-nil."
 @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
@@ -1387,9 +1401,18 @@ written a @code{defgroup} to define that group properly.  @xref{Group
 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.
@@ -1479,7 +1502,7 @@ See the command \\[hungry-electric-delete]."
  :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
@@ -1491,6 +1514,12 @@ by visiting files, and buffers that use a major mode other than
 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
@@ -1680,7 +1709,6 @@ the information in another fashion.  This way, customizations made by
 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.
@@ -2319,7 +2347,7 @@ Setting this variable makes it buffer-local in the current buffer.
 
 @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
@@ -2838,6 +2866,8 @@ set the variable @code{font-lock-defaults}.
 
 @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
@@ -2910,6 +2940,7 @@ directives in C.
 
 @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