diff man/xemacs/major.texi @ 2522:52dc9b940348

[xemacs-hg @ 2005-01-28 00:12:32 by ben] cc-mode patch from Shyamal Prasad xemacs/programs.texi: Updated it to reflect current status of programming modes. xemacs/programs.texi: New section introduces CC Mode. Introduces customization with reference to CC Mode manual. Also introduce C/AWK modes in prog-modes package xemacs/programs.texi: Removed - it was obsolete. prog-modes package documentation now contains indentation description for old C mode xemacs/major.texi: Add description of major mode hooks. Cleaned up and updated programming mode descriptions. xemacs/xemacs.texi: Updated Detailed Node listing for new CC Mode section in programs.texi
author ben
date Fri, 28 Jan 2005 00:12:39 +0000
parents 3ecd8885ac67
children 40dc584fce16
line wrap: on
line diff
--- a/man/xemacs/major.texi	Thu Jan 27 22:51:11 2005 +0000
+++ b/man/xemacs/major.texi	Fri Jan 28 00:12:39 2005 +0000
@@ -26,14 +26,15 @@
 Many major modes redefine the syntactical properties of characters
 appearing in the buffer.  @xref{Syntax}.
 
-  The major modes fall into three major groups.  Lisp mode (which has
-several variants), C mode, and Muddle mode are for specific programming
-languages.  Text mode, Nroff mode, @TeX{} mode, and Outline mode are for
-editing English text.  The remaining major modes are not intended for use
-on users' files; they are used in buffers created by Emacs for specific
-purposes and include Dired mode for buffers made by Dired (@pxref{Dired}),
-Mail mode for buffers made by @kbd{C-x m} (@pxref{Sending Mail}), and Shell
-mode for buffers used for communicating with an inferior shell process
+  The major modes fall into three major groups.  Programming modes
+(@pxref{Programs}) are for specific programming languages.  Text modes
+(like Nroff mode, @TeX{} mode, Outline mode, XML mode, etc.@:) are for
+editing human readable text.  The remaining major modes are not intended
+for direct use in editing user files; they are used in buffers created
+by Emacs for specific purposes. Examples of such modes include Dired
+mode which is used for buffers made by Dired (@pxref{Dired}), Mail mode
+for buffers made by @kbd{C-x m} (@pxref{Sending Mail}), and Shell mode
+for buffers used for communicating with an inferior shell process
 (@pxref{Interactive Shell}).
 
   Most programming language major modes specify that only blank lines
@@ -44,9 +45,10 @@
 
 @menu
 * Choosing Modes::     How major modes are specified or chosen.
+* Mode Hooks::         Customizing a major mode
 @end menu
 
-@node Choosing Modes,,Major Modes,Major Modes
+@node Choosing Modes, Mode Hooks, Major Modes, Major Modes
 @section Choosing Major Modes
 
   You can select a major mode explicitly for the current buffer, but
@@ -111,3 +113,49 @@
 value is the symbol @code{fundamental-mode}, which specifies Fundamental
 mode.  If @code{default-major-mode} is @code{nil}, the major mode is
 taken from the previously selected buffer.
+
+@node Mode Hooks,  , Choosing Modes, Major Modes
+@section Mode Hook Variables
+
+@cindex Hook variables
+@cindex mode hook
+@findex add-hook
+@findex remove-hook
+@vindex lisp-mode-hook
+@vindex emacs-lisp-mode-hook
+@vindex lisp-interaction-mode-hook
+@vindex scheme-mode-hook
+
+  The last step taken by a major mode, by convention, is to invoke a
+list of user supplied functions that are stored in a ``hook'' variable.
+This allows a user to further customize the major mode, and is
+particularly convenient for setting up buffer local variables
+(@pxref{Locals}).
+
+  The name of the hook variable is created by appending the string
+@code{-hook} to the name of the major mode.  For example, the hook
+variable used by @code{text-mode} would be named @code{text-mode-hook}.
+By convention the mode hook function receives no arguments. If a hook
+variable does not exist, or it has the value @code{nil}, the major mode
+simply ignores it.
+
+  The recommended way to add functions to a hook variable is with the
+@code{add-hook} function.  For example, to automatically turn on the
+Auto Fill mode when Text mode is invoked the following code can be used in
+the initialization file (@pxref{Init File})
+
+@example
+(add-hook 'text-mode-hook 'turn-on-auto-fill)
+@end example
+
+The @code{add-hook} function will check that the function is not already
+listed in the hook variable before adding it. It will also create a hook
+variable with the value @code{nil} if one does not exist before adding
+the function. @code{add-hook} adds functions to the front of the hook
+variable list. This means that the last hook added is run first by the
+major mode. It is considered very poor style to write hook functions
+that depend on the order that hooks are executed.
+
+Hooks can be removed from hook variables with @code{remove-hook}.
+
+