[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: turn-on-...

From: Miles Bader
Subject: Re: turn-on-...
Date: Sat, 28 Oct 2000 15:30:43 +0900 (JST)

Ok, I checked in the small change. `define-minor-mode' now defines
turn-on- and turn-off- functions for buffer local minor-modes (somehow
it didn't seem right to do so for global minor-modes, as they're usually
not turned on by hooks).

I also added a frob to define a `global-MODE' function for buffer-local
minor modes (using `easy-mmode-define-global-mode'), but I'm not sure
the user-interface is right.

Basically, if the value of the `:global' keyword is non-nil but also
non-t, then it makes MODE buffer-local, but defines a `global-MODE'
function too.  My reasoning for overloading the :global keyword is that
(1) they're (:global t and :global foo) both kinda global, just in
different ways, and (2) defining global-MODE function only makes sense
for buffer-local modes, so using this sort of syntax makes impossible to
specify conflicting keywords.  I also added a :conditional-turn-on
keyword for specifying a function to turn on the local mode
conditionally (since for some modes, you only want global-FOO mode to
turn on FOO mode in *some* buffers).

Comments please.


*Here's the updated doc string for define-minor-mode:

 (define-minor-mode MODE DOC &optional INIT-VALUE LIGHTER KEYMAP &rest BODY)

 Define a new minor mode MODE.
 This function defines the associated control variable MODE, keymap MODE-map,
 toggle command MODE, and hook MODE-hook.  If MODE is buffer-local, then
 turn-on-MODE and turn-off-MODE commands are also generated for use in hooks,
 and an optional global-MODE mode may also be generated.

 DOC is the documentation for the mode toggle command.
 Optional INIT-VALUE is the initial value of the mode's variable.
 Optional LIGHTER is displayed in the modeline when the mode is on.
 Optional KEYMAP is the default (defvar) keymap bound to the mode keymap.
   If it is a list, it is passed to `easy-mmode-define-keymap'
   in order to build a valid keymap.
 BODY contains code that will be executed each time the mode is (dis)activated.
   It will be executed after any toggling but before running the hooks.
   BODY can start with a list of CL-style keys specifying additional arguments.
   Currently three such keyword arguments are supported:
     :group, followed by the group name to use for any generated `defcustom'.
     :global, followed by a value, which --
       If `t' specifies that the minor mode is not meant to be
         buffer-local (by default, the variable is made buffer-local).
       If non-nil, but not `t' (for instance, `:global optionally'), then
         specifies that the minor mode should be buffer-local, but that a
         corresponding `global-MODE' function should also be added, which can
         be used to turn on MODE in every buffer.
     :conditional-turn-on, followed by a function-name which turns on MODE
         only when applicable to the current buffer.  This is used in
         conjunction with any `global-MODE' function (see :global above) when
         turning on the buffer-local minor mode.  By default, any generated
         `global-MODE' function unconditionally turns on the minor mode in
         every new buffer.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]