+@item :abbrev-table
+You can use this to explicitly specify an abbrev table for the new
+mode. If you specify a @code{nil} value, the new mode uses the same
+abbrev table as @var{parent}, or @code{fundamental-mode-abbrev-table}
+if @var{parent} is @code{nil}. (Again, a @code{nil} value is
+@emph{not} equivalent to not specifying this keyword.)
+
+@item :group
+If this is specified, the value should be the customization group for
+this mode. (Not all major modes have one.) Only the (still
+experimental and unadvertised) command @code{customize-mode} currently
+uses this. @code{define-derived-mode} does @emph{not} automatically
+define the specified customization group.
+@end table
+
+Here is a hypothetical example:
+
+@example
+(define-derived-mode hypertext-mode
+ text-mode "Hypertext"
+ "Major mode for hypertext.
+\\@{hypertext-mode-map@}"
+ (setq case-fold-search nil))
+
+(define-key hypertext-mode-map
+ [down-mouse-3] 'do-hyper-link)
+@end example
+
+Do not write an @code{interactive} spec in the definition;
+@code{define-derived-mode} does that automatically.
+@end defmac
+
+@node Generic Modes
+@subsection Generic Modes
+@cindex generic mode
+
+ @dfn{Generic modes} are simple major modes with basic support for
+comment syntax and Font Lock mode. To define a generic mode, use the
+macro @code{define-generic-mode}. See the file @file{generic-x.el}
+for some examples of the use of @code{define-generic-mode}.
+
+@defmac define-generic-mode mode comment-list keyword-list font-lock-list auto-mode-list function-list &optional docstring
+This macro defines a generic mode command named @var{mode} (a symbol,
+not quoted). The optional argument @var{docstring} is the
+documentation for the mode command. If you do not supply it,
+@code{define-generic-mode} generates one by default.
+
+The argument @var{comment-list} is a list in which each element is
+either a character, a string of one or two characters, or a cons cell.
+A character or a string is set up in the mode's syntax table as a
+``comment starter.'' If the entry is a cons cell, the @sc{car} is set
+up as a ``comment starter'' and the @sc{cdr} as a ``comment ender.''
+(Use @code{nil} for the latter if you want comments to end at the end
+of the line.) Note that the syntax table mechanism has limitations
+about what comment starters and enders are actually possible.
+@xref{Syntax Tables}.
+
+The argument @var{keyword-list} is a list of keywords to highlight
+with @code{font-lock-keyword-face}. Each keyword should be a string.
+Meanwhile, @var{font-lock-list} is a list of additional expressions to
+highlight. Each element of this list should have the same form as an
+element of @code{font-lock-keywords}. @xref{Search-based
+Fontification}.
+
+The argument @var{auto-mode-list} is a list of regular expressions to
+add to the variable @code{auto-mode-alist}. They are added by the execution
+of the @code{define-generic-mode} form, not by expanding the macro call.
+
+Finally, @var{function-list} is a list of functions for the mode
+command to call for additional setup. It calls these functions just
+before it runs the mode hook variable @code{@var{mode}-hook}.
+@end defmac
+
+@node Mode Hooks
+@subsection Mode Hooks
+
+ Every major mode function should finish by running its mode hook and
+the mode-independent normal hook @code{after-change-major-mode-hook}.
+It does this by calling @code{run-mode-hooks}. If the major mode is a
+derived mode, that is if it calls another major mode (the parent mode)
+in its body, it should do this inside @code{delay-mode-hooks} so that
+the parent won't run these hooks itself. Instead, the derived mode's
+call to @code{run-mode-hooks} runs the parent's mode hook too.
+@xref{Major Mode Conventions}.
+
+ Emacs versions before Emacs 22 did not have @code{delay-mode-hooks}.
+When user-implemented major modes have not been updated to use it,
+they won't entirely follow these conventions: they may run the
+parent's mode hook too early, or fail to run
+@code{after-change-major-mode-hook}. If you encounter such a major
+mode, please correct it to follow these conventions.
+
+ When you defined a major mode using @code{define-derived-mode}, it
+automatically makes sure these conventions are followed. If you
+define a major mode ``by hand,'' not using @code{define-derived-mode},
+use the following functions to handle these conventions automatically.
+
+@defun run-mode-hooks &rest hookvars
+Major modes should run their mode hook using this function. It is
+similar to @code{run-hooks} (@pxref{Hooks}), but it also runs
+@code{after-change-major-mode-hook}.
+
+When this function is called during the execution of a
+@code{delay-mode-hooks} form, it does not run the hooks immediately.
+Instead, it arranges for the next call to @code{run-mode-hooks} to run
+them.
+@end defun
+
+@defmac delay-mode-hooks body@dots{}
+When one major mode command calls another, it should do so inside of
+@code{delay-mode-hooks}.
+
+This macro executes @var{body}, but tells all @code{run-mode-hooks}
+calls during the execution of @var{body} to delay running their hooks.
+The hooks will actually run during the next call to
+@code{run-mode-hooks} after the end of the @code{delay-mode-hooks}
+construct.
+@end defmac
+
+@defvar after-change-major-mode-hook
+This is a normal hook run by @code{run-mode-hooks}. It is run at the
+very end of every properly-written major mode function.
+@end defvar
+
+@node Example Major Modes
+@subsection Major Mode Examples
+
+ Text mode is perhaps the simplest mode besides Fundamental mode.
+Here are excerpts from @file{text-mode.el} that illustrate many of
+the conventions listed above:
+
+@smallexample
+@group
+;; @r{Create the syntax table for this mode.}
+(defvar text-mode-syntax-table
+ (let ((st (make-syntax-table)))
+ (modify-syntax-entry ?\" ". " st)
+ (modify-syntax-entry ?\\ ". " st)
+ ;; Add `p' so M-c on `hello' leads to `Hello', not `hello'.
+ (modify-syntax-entry ?' "w p" st)
+ st)
+ "Syntax table used while in `text-mode'.")
+@end group
+
+;; @r{Create the keymap for this mode.}
+@group
+(defvar text-mode-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map "\e\t" 'ispell-complete-word)
+ (define-key map "\es" 'center-line)
+ (define-key map "\eS" 'center-paragraph)
+ map)
+ "Keymap for `text-mode'.
+Many other modes, such as Mail mode, Outline mode
+and Indented Text mode, inherit all the commands
+defined in this map.")
+@end group
+@end smallexample
+
+ Here is how the actual mode command is defined now:
+
+@smallexample
+@group
+(define-derived-mode text-mode nil "Text"
+ "Major mode for editing text written for humans to read.
+In this mode, paragraphs are delimited only by blank or white lines.
+You can thus get the full benefit of adaptive filling
+ (see the variable `adaptive-fill-mode').
+\\@{text-mode-map@}
+Turning on Text mode runs the normal hook `text-mode-hook'."
+@end group
+@group
+ (make-local-variable 'text-mode-variant)
+ (setq text-mode-variant t)
+ ;; @r{These two lines are a feature added recently.}
+ (set (make-local-variable 'require-final-newline)
+ mode-require-final-newline)
+ (set (make-local-variable 'indent-line-function) 'indent-relative))
+@end group
+@end smallexample
+
+@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
+;; @r{This isn't needed nowadays, since @code{define-derived-mode} does it.}
+(defvar text-mode-abbrev-table nil
+ "Abbrev table used while in text mode.")
+(define-abbrev-table 'text-mode-abbrev-table ())
+@end group
+
+@group
+(defun text-mode ()
+ "Major mode for editing text intended for humans to read...
+ Special commands: \\@{text-mode-map@}
+@end group
+@group
+Turning on text-mode runs the hook `text-mode-hook'."
+ (interactive)
+ (kill-all-local-variables)
+ (use-local-map text-mode-map)
+@end group
+@group
+ (setq local-abbrev-table text-mode-abbrev-table)
+ (set-syntax-table text-mode-syntax-table)
+@end group
+@group
+ ;; @r{These four lines are absent from the current version}
+ ;; @r{not because this is done some other way, but rather}
+ ;; @r{because nowadays Text mode uses the normal definition of paragraphs.}
+ (make-local-variable 'paragraph-start)
+ (setq paragraph-start (concat "[ \t]*$\\|" page-delimiter))
+ (make-local-variable 'paragraph-separate)
+ (setq paragraph-separate paragraph-start)
+ (make-local-variable 'indent-line-function)
+ (setq indent-line-function 'indent-relative-maybe)
+@end group
+@group
+ (setq mode-name "Text")
+ (setq major-mode 'text-mode)
+ (run-mode-hooks 'text-mode-hook)) ; @r{Finally, this permits the user to}
+ ; @r{customize the mode with a hook.}
+@end group
+@end smallexample
+
+@cindex @file{lisp-mode.el}
+ The three Lisp modes (Lisp mode, Emacs Lisp mode, and Lisp
+Interaction mode) have more features than Text mode and the code is
+correspondingly more complicated. Here are excerpts from
+@file{lisp-mode.el} that illustrate how these modes are written.