36 |
;; For each mode, easy-mmode defines the following: |
;; For each mode, easy-mmode defines the following: |
37 |
;; <mode> : The minor mode predicate. A buffer-local variable. |
;; <mode> : The minor mode predicate. A buffer-local variable. |
38 |
;; <mode>-map : The keymap possibly associated to <mode>. |
;; <mode>-map : The keymap possibly associated to <mode>. |
|
;; <mode>-hook : The hook run at the end of the toggle function. |
|
39 |
;; see `define-minor-mode' documentation |
;; see `define-minor-mode' documentation |
40 |
;; |
;; |
41 |
;; eval |
;; eval |
89 |
(defmacro define-minor-mode (mode doc &optional init-value lighter keymap &rest body) |
(defmacro define-minor-mode (mode doc &optional init-value lighter keymap &rest body) |
90 |
"Define a new minor mode MODE. |
"Define a new minor mode MODE. |
91 |
This function defines the associated control variable MODE, keymap MODE-map, |
This function defines the associated control variable MODE, keymap MODE-map, |
92 |
toggle command MODE, and hook MODE-hook. |
and toggle command MODE. |
93 |
|
|
94 |
DOC is the documentation for the mode toggle command. |
DOC is the documentation for the mode toggle command. |
95 |
Optional INIT-VALUE is the initial value of the mode's variable. |
Optional INIT-VALUE is the initial value of the mode's variable. |
102 |
used (see below). |
used (see below). |
103 |
|
|
104 |
BODY contains code that will be executed each time the mode is (dis)activated. |
BODY contains code that will be executed each time the mode is (dis)activated. |
105 |
It will be executed after any toggling but before running the hooks. |
It will be executed after any toggling but before running the hook variable |
106 |
Before the actual body code, you can write |
`mode-HOOK'. |
107 |
keyword arguments (alternating keywords and values). |
Before the actual body code, you can write keyword arguments (alternating |
108 |
These following keyword arguments are supported (other keywords |
keywords and values). These following keyword arguments are supported (other |
109 |
will be passed to `defcustom' if the minor mode is global): |
keywords will be passed to `defcustom' if the minor mode is global): |
110 |
:group GROUP Custom group name to use in all generated `defcustom' forms. |
:group GROUP Custom group name to use in all generated `defcustom' forms. |
111 |
Defaults to MODE without the possible trailing \"-mode\". |
Defaults to MODE without the possible trailing \"-mode\". |
112 |
Don't use this default group name unless you have written a |
Don't use this default group name unless you have written a |
240 |
;; up-to-here. |
;; up-to-here. |
241 |
:autoload-end |
:autoload-end |
242 |
|
|
|
;; The toggle's hook. |
|
|
(defcustom ,hook nil |
|
|
,(format "Hook run at the end of function `%s'." mode-name) |
|
|
,@group |
|
|
:type 'hook) |
|
|
|
|
243 |
;; Define the minor-mode keymap. |
;; Define the minor-mode keymap. |
244 |
,(unless (symbolp keymap) ;nil is also a symbol. |
,(unless (symbolp keymap) ;nil is also a symbol. |
245 |
`(defvar ,keymap-sym |
`(defvar ,keymap-sym |
316 |
(with-current-buffer buf |
(with-current-buffer buf |
317 |
(if ,global-mode (,turn-on) (when ,mode (,mode -1)))))) |
(if ,global-mode (,turn-on) (when ,mode (,mode -1)))))) |
318 |
|
|
319 |
;; Autoloading easy-mmode-define-global-mode |
;; Autoloading define-global-minor-mode autoloads everything |
320 |
;; autoloads everything up-to-here. |
;; up-to-here. |
321 |
:autoload-end |
:autoload-end |
322 |
|
|
323 |
;; List of buffers left to process. |
;; List of buffers left to process. |