diff options
| -rw-r--r-- | lispref/modes.texi | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/lispref/modes.texi b/lispref/modes.texi index e0494d4e7d9..12c4493b36f 100644 --- a/lispref/modes.texi +++ b/lispref/modes.texi | |||
| @@ -103,6 +103,8 @@ Fundamental mode. Rmail mode is a complicated and specialized mode. | |||
| 103 | * Mode Help:: Finding out how to use a mode. | 103 | * Mode Help:: Finding out how to use a mode. |
| 104 | * Derived Modes:: Defining a new major mode based on another major | 104 | * Derived Modes:: Defining a new major mode based on another major |
| 105 | mode. | 105 | mode. |
| 106 | * Generic Modes:: Defining a simple major mode that supports | ||
| 107 | comment syntax and Font Lock mode. | ||
| 106 | * Mode Hooks:: Hooks run at the end of major mode functions. | 108 | * Mode Hooks:: Hooks run at the end of major mode functions. |
| 107 | @end menu | 109 | @end menu |
| 108 | 110 | ||
| @@ -798,6 +800,7 @@ mode. | |||
| 798 | 800 | ||
| 799 | @node Derived Modes | 801 | @node Derived Modes |
| 800 | @subsection Defining Derived Modes | 802 | @subsection Defining Derived Modes |
| 803 | @cindex derived mode | ||
| 801 | 804 | ||
| 802 | It's often useful to define a new major mode in terms of an existing | 805 | It's often useful to define a new major mode in terms of an existing |
| 803 | one. An easy way to do this is to use @code{define-derived-mode}. | 806 | one. An easy way to do this is to use @code{define-derived-mode}. |
| @@ -860,6 +863,57 @@ Do not write an @code{interactive} spec in the definition; | |||
| 860 | @code{define-derived-mode} does that automatically. | 863 | @code{define-derived-mode} does that automatically. |
| 861 | @end defmac | 864 | @end defmac |
| 862 | 865 | ||
| 866 | @node Generic Modes | ||
| 867 | @subsection Generic Modes | ||
| 868 | @cindex generic mode | ||
| 869 | |||
| 870 | @dfn{Generic modes} are simple major modes with basic support for | ||
| 871 | comment syntax and Font Lock mode. They are primarily useful for | ||
| 872 | configuration files. To define a generic mode, use the macro | ||
| 873 | @code{define-generic-mode}. See the file @file{generic-x.el} for some | ||
| 874 | examples of the use of @code{define-generic-mode}. | ||
| 875 | |||
| 876 | @defmac define-generic-mode mode comment-list keyword-list font-lock-list auto-mode-list function-list &optional docstring &rest custom-keyword-args | ||
| 877 | This macro creates a new generic mode. The argument @var{mode} (an | ||
| 878 | unquoted symbol) is the major mode command. The optional argument | ||
| 879 | @var{docstring} is the documentation for the mode command. If you do | ||
| 880 | not supply it, @code{define-generic-mode} uses a default documentation | ||
| 881 | string instead. | ||
| 882 | |||
| 883 | @var{comment-list} is a list in which each element is either a | ||
| 884 | character, a string of one or two characters, or a cons cell. A | ||
| 885 | character or a string is set up in the mode's syntax table as a | ||
| 886 | ``comment starter.'' If the entry is a cons cell, the @sc{car} is set | ||
| 887 | up as a ``comment starter'' and the @sc{cdr} as a ``comment ender.'' | ||
| 888 | (Use @code{nil} for the latter if you want comments to end at the end | ||
| 889 | of the line.) Note that the syntax table has limitations about what | ||
| 890 | comment starters and enders are actually possible. @xref{Syntax | ||
| 891 | Tables}. | ||
| 892 | |||
| 893 | @var{keyword-list} is a list of keywords to highlight with | ||
| 894 | @code{font-lock-keyword-face}. Each keyword should be a string. | ||
| 895 | @var{font-lock-list} is a list of additional expressions to highlight. | ||
| 896 | Each element of this list should have the same form as an element of | ||
| 897 | @code{font-lock-keywords}. @xref{Search-based Fontification}. | ||
| 898 | |||
| 899 | @var{auto-mode-list} is a list of regular expressions to add to the | ||
| 900 | variable @code{auto-mode-alist}. These regular expressions are added | ||
| 901 | when Emacs runs the macro expansion. | ||
| 902 | |||
| 903 | @var{function-list} is a list of functions to call to do some | ||
| 904 | additional setup. The mode command calls these functions just before | ||
| 905 | it runs the mode hook. | ||
| 906 | |||
| 907 | The optional @var{custom-keyword-args} are pairs of keywords and | ||
| 908 | values to include in the generated @code{defcustom} form for the mode | ||
| 909 | hook variable @code{@var{mode}-hook}. The default value for the | ||
| 910 | @samp{:group} keyword is @var{mode} with the final @samp{-mode} (if | ||
| 911 | any) removed. Don't use this default group name unless you have | ||
| 912 | written a @code{defgroup} to define that group properly (@pxref{Group | ||
| 913 | Definitions}). You can specify keyword arguments without specifying a | ||
| 914 | docstring. | ||
| 915 | @end defmac | ||
| 916 | |||
| 863 | @node Mode Hooks | 917 | @node Mode Hooks |
| 864 | @subsection Mode Hooks | 918 | @subsection Mode Hooks |
| 865 | 919 | ||