[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This chapter explains how to customize the appearance and functioning of MMM Mode however you want.
3.1 Customizing Region Coloring | Changing or removing background colors. | |
3.2 Preferred Major Modes | Choosing which major modes to use. | |
3.3 Customizing the Mode Line Display | What is displayed in the mode line. | |
3.4 Customizing the MMM Mode Key Bindings | Customizing the MMM Mode key bindings. | |
3.5 Changing Saved Local Variables | What local variables are saved for submodes. | |
3.6 Changing the Supplied Submode Classes | Changing the supplied submode classes. | |
3.7 Hooks Provided by MMM Mode | How to make MMM Mode run your code. |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
By default, MMM Mode highlights all submode regions with a background color. There are three levels of this decoration, controlled by the following variable:
No coloring means exactly that. Submode regions have the same background as the rest of the text. This produces the minimal interference with font-lock coloration. In particular, if you want to use background colors for font-lock, this may be a good idea, because the submode highlight, if present, overrides any font-lock background coloring.
Low coloring uses the same background color for all submode regions.
This color is specified with the face mmm-default-submode-face
(see section `Faces' in The Emacs Manual) which can be customized,
either through the Emacs "customize" interface or using direct Lisp
commands such as set-face-background
. Of course, other aspects
of the face can also be set, such as the foreground color, bold,
underline, etc. These are more likely to conflict with font-lock,
however, so only a background color is recommended.
High coloring uses multiple background colors, depending on the function of the submode region. The recognized functions and their meanings are as follows:
The different background colors are provided by the faces
mmm-function-submode-face
, which can be customized in the
same way as mmm-default-submode-face
.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Certain of the supplied submode classes know only the language that certain sections are written in, but not what major mode you prefer to use to edit such code. For example, many people prefer CPerl mode over Perl mode; you may have a special mode for Javascript or just use C++ mode. This variable allows you to tell submodes such as Mason (see section 4.1 Mason: Perl in HTML) and Embedded Javascript (see section 4.4 Javascript in HTML) what major mode to use for the submodes:
(language . mode)
. language should be a symbol
such as perl
, html-js
, or java
, while mode
should be the name of a major mode such as perl-mode
,
cperl-mode
, javascript-mode
, or c++-mode
.
You probably won't have to set this variable at all; MMM tries to make
intelligent guesses about what modes you prefer. For example, if a
function called javascript-mode
exists, it is chosen, otherwise
c++-mode
is used. Similarly for jde-mode
and
java-mode
.
If you do need to change the defaults, you may find the following function convenient.
Thus, for example, to use my-java-mode
for Java code, you would
use the following line:
(mmm-set-major-mode-preferences 'java 'my-java-mode) |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
By default, when in a submode region, MMM Mode changes the section of the mode line (see section `Mode Line' in The Emacs Manual) that normally displays the major mode name--for example, `HTML'---to instead show both the dominant major mode and the currently active submode--for example, `HTML[CPerl]'. You can change this format, however.
The MMM minor mode also normally displays the string `MMM' in the minor mode section of the mode line to indicate when it is active. You can customize or disable this as well.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The default MMM Mode key bindings are explained in 2.1.2 Key Bindings in MMM Mode, and in 2.4 Inserting new submode regions. There are a couple of ways to customize these bindings.
nil
, MMM Mode commands use the control
modifier and insertion keys no modifier. Any other value switches the
two, so that mmm-parse-buffer
, for example, is bound to C-c
% b, while perl-section insertion in the Mason class is bound to
C-c % C-p. This variable should be set before MMM Mode is loaded
to have an effect.
When MMM is loaded, it uses the value of mmm-use-old-command-keys
to set the values of the variables mmm-command-modifiers
and
mmm-insert-modifiers
, so if you prefer you can set these
variables instead. They should each be a list of key modifiers, such as
(control)
or ()
. The Meta modifier is used in some of the
command and insertion keys, so it should not be used, and the Shift
modifier is not particularly portable between Emacsen--if it works for
you, feel free to use it. Other modifiers, such as Hyper and Super, are
not universally available, but are valid when present.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A lot of the functionality of MMM Mode--that which makes the major mode appear to change--is implemented by saving and restoring the values of local variables, or pseudo-variables. You can customize what variables are saved, and how, with the following variable.
global
, buffer
, or
region
. If not present, the default value is global
. The
third element, if present, should be a list of major mode symbols in
which to save the variable. In the list form, the variable symbol
itself can be replaced with a cons cell of two functions, one to get the
value and one to set the value. This is called a "pseudo-variable".
Globally saved variables are the same in all (MMM-controlled) buffers
and submode regions of each major mode listed in the third argument, or
all major modes if it is t
or not present. Buffer-saved
variables are the same in all submode regions of a given major mode in
each buffer, and region-saved variables can be different for each
submode region.
Pseudo-variables are used, for example, to save and restore the syntax table (see section `Syntax' in The Emacs Manual) and mode keymaps (see section `Keymaps' in The Emacs Manual).
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
If you need to use MMM with a syntax for which a submode class is not supplied, and you have some facility with Emacs Lisp, you can write your own; see 5. Writing Submode Classes. However, sometimes you will only want to make a slight change to one of the supplied submode classes. You can do this, after that class is loaded, with the following functions.
nil
if there is no such parameter.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
MMM Mode defines several hook variables (see section `Hooks' in The Emacs Manual) which are run at different times. The most often used is
mmm-major-mode-hook
which is described in 2.7.1 The Major Mode Hook,
but there are a couple others.
Submode classes also have a :creation-hook
parameter which should
be a function to run whenever a submode region is created with that
class, with point at the beginning of the submode region. This can be
set for supplied submode classes with mmm-set-class-parameter
;
3.6 Changing the Supplied Submode Classes.
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated by XEmacs shared group account on December, 19 2009
using texi2html 1.65.