define-derived-mode

define-derived-mode is an autoloaded Lisp macro in `derived.el'.

(define-derived-mode CHILD PARENT NAME &optional DOCSTRING &rest BODY)

Create a new mode as a variant of an existing mode.

The arguments to this command are as follow:

CHILD: the name of the command for the derived mode.
PARENT: the name of the command for the parent mode (e.g. `text-mode')
or nil if there is no parent.
NAME: a string which will appear in the status line (e.g. "Hypertext")
DOCSTRING: an optional documentation string--if you do not supply one,
the function will attempt to invent something useful.
BODY: forms to execute just before running the
hooks for the new mode. Do not use `interactive' here.

BODY can start with a bunch of keyword arguments. The following keyword
arguments are currently understood:
:group GROUP
Declare the customization group that corresponds to this mode.
The command `customize-mode' uses this.
:syntax-table TABLE
Use TABLE instead of the default (CHILD-syntax-table).
A nil value means to simply use the same syntax-table as the parent.
:abbrev-table TABLE
Use TABLE instead of the default (CHILD-abbrev-table).
A nil value means to simply use the same abbrev-table as the parent.

Here is how you could define LaTeX-Thesis mode as a variant of LaTeX mode:

(define-derived-mode LaTeX-thesis-mode LaTeX-mode "LaTeX-Thesis")

You could then make new key bindings for `LaTeX-thesis-mode-map'
without changing regular LaTeX mode. In this example, BODY is empty,
and DOCSTRING is generated by default.

On a more complicated level, the following command uses `sgml-mode' as
the parent, and then sets the variable `case-fold-search' to nil:

(define-derived-mode article-mode sgml-mode "Article"
"Major mode for editing technical articles."
(setq case-fold-search nil))

Note that if the documentation string had been left out, it would have
been generated automatically, with a reference to the keymap.

The new mode runs the hook constructed by the function
`derived-mode-hook-name'.

See Info node `(elisp)Derived Modes' for more details.