Go to the first, previous, next, last section, table of contents.


Defining Derived Modes

It's often useful to define a new major mode in terms of an existing one. An easy way to do this is to use define-derived-mode.

Macro: define-derived-mode variant parent name docstring body...
This construct defines variant as a major mode command, using name as the string form of the mode name.

The new command variant is defined to call the function parent, then override certain aspects of that parent mode:

In addition, you can specify how to override other aspects of parent with body. The command variant evaluates the forms in body after setting up all its usual overrides, just before running variant-hook.

The argument docstring specifies the documentation string for the new mode. If you omit docstring, define-derived-mode generates a documentation string.

Here is a hypothetical 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)


Go to the first, previous, next, last section, table of contents.