103 |
* Mode Help:: Finding out how to use a mode. |
* Mode Help:: Finding out how to use a mode. |
104 |
* Derived Modes:: Defining a new major mode based on another major |
* Derived Modes:: Defining a new major mode based on another major |
105 |
mode. |
mode. |
106 |
|
* Generic Modes:: Defining a simple major mode that supports |
107 |
|
comment syntax and Font Lock mode. |
108 |
* Mode Hooks:: Hooks run at the end of major mode functions. |
* Mode Hooks:: Hooks run at the end of major mode functions. |
109 |
@end menu |
@end menu |
110 |
|
|
800 |
|
|
801 |
@node Derived Modes |
@node Derived Modes |
802 |
@subsection Defining Derived Modes |
@subsection Defining Derived Modes |
803 |
|
@cindex derived mode |
804 |
|
|
805 |
It's often useful to define a new major mode in terms of an existing |
It's often useful to define a new major mode in terms of an existing |
806 |
one. An easy way to do this is to use @code{define-derived-mode}. |
one. An easy way to do this is to use @code{define-derived-mode}. |
863 |
@code{define-derived-mode} does that automatically. |
@code{define-derived-mode} does that automatically. |
864 |
@end defmac |
@end defmac |
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 |
|
|
917 |
@node Mode Hooks |
@node Mode Hooks |
918 |
@subsection Mode Hooks |
@subsection Mode Hooks |
919 |
|
|