90 |
It will be executed after any toggling but before running the hooks. |
It will be executed after any toggling but before running the hooks. |
91 |
Before the actual body code, you can write |
Before the actual body code, you can write |
92 |
keyword arguments (alternating keywords and values). |
keyword arguments (alternating keywords and values). |
93 |
These following keyword arguments are supported: |
These following keyword arguments are supported (other keywords |
94 |
|
will be passed to `defcustom' if the minor mode is global): |
95 |
:group GROUP Custom group name to use in all generated `defcustom' forms. |
:group GROUP Custom group name to use in all generated `defcustom' forms. |
96 |
:global GLOBAL If non-nil specifies that the minor mode is not meant to be |
:global GLOBAL If non-nil specifies that the minor mode is not meant to be |
97 |
buffer-local, so don't make the variable MODE buffer-local. |
buffer-local, so don't make the variable MODE buffer-local. |
102 |
|
|
103 |
For example, you could write |
For example, you could write |
104 |
(define-minor-mode foo-mode \"If enabled, foo on you!\" |
(define-minor-mode foo-mode \"If enabled, foo on you!\" |
105 |
nil \"Foo \" foo-keymap |
:lighter \" Foo\" :require 'foo :global t :group 'hassle :version \"27.5\" |
|
:require 'foo :global t :group 'inconvenience |
|
106 |
...BODY CODE...)" |
...BODY CODE...)" |
107 |
|
|
108 |
;; Allow skipping the first three args. |
;; Allow skipping the first three args. |
119 |
(globalp nil) |
(globalp nil) |
120 |
(group nil) |
(group nil) |
121 |
(extra-args nil) |
(extra-args nil) |
122 |
|
(extra-keywords nil) |
123 |
(require t) |
(require t) |
124 |
(keymap-sym (if (and keymap (symbolp keymap)) keymap |
(keymap-sym (if (and keymap (symbolp keymap)) keymap |
125 |
(intern (concat mode-name "-map")))) |
(intern (concat mode-name "-map")))) |
126 |
(hook (intern (concat mode-name "-hook"))) |
(hook (intern (concat mode-name "-hook"))) |
127 |
(hook-on (intern (concat mode-name "-on-hook"))) |
(hook-on (intern (concat mode-name "-on-hook"))) |
128 |
(hook-off (intern (concat mode-name "-off-hook")))) |
(hook-off (intern (concat mode-name "-off-hook"))) |
129 |
|
keyw) |
130 |
|
|
131 |
;; Check keys. |
;; Check keys. |
132 |
(while (keywordp (car body)) |
(while (keywordp (setq keyw (car body))) |
133 |
(case (pop body) |
(setq body (cdr body)) |
134 |
|
(case keyw |
135 |
(:init-value (setq init-value (pop body))) |
(:init-value (setq init-value (pop body))) |
136 |
(:lighter (setq lighter (pop body))) |
(:lighter (setq lighter (pop body))) |
137 |
(:global (setq globalp (pop body))) |
(:global (setq globalp (pop body))) |
138 |
(:extra-args (setq extra-args (pop body))) |
(:extra-args (setq extra-args (pop body))) |
139 |
(:group (setq group (nconc group (list :group (pop body))))) |
(:group (setq group (nconc group (list :group (pop body))))) |
140 |
(:require (setq require (pop body))) |
(:require (setq require (pop body))) |
141 |
(t (pop body)))) |
(t (push keyw extra-keywords) (push (pop body) extra-keywords)))) |
142 |
|
|
143 |
(unless group |
(unless group |
144 |
;; We might as well provide a best-guess default group. |
;; We might as well provide a best-guess default group. |
164 |
Setting this variable directly does not take effect; |
Setting this variable directly does not take effect; |
165 |
use either \\[customize] or the function `%s'." |
use either \\[customize] or the function `%s'." |
166 |
pretty-name mode mode) |
pretty-name mode mode) |
167 |
:set (lambda (symbol value) (funcall symbol (or value 0))) |
:set 'custom-set-minor-mode |
168 |
:initialize 'custom-initialize-default |
:initialize 'custom-initialize-default |
169 |
,@group |
,@group |
170 |
:type 'boolean |
:type 'boolean |
173 |
((not (eq require t)) `(:require ,require)) |
((not (eq require t)) `(:require ,require)) |
174 |
(t `(:require |
(t `(:require |
175 |
',(intern (file-name-nondirectory |
',(intern (file-name-nondirectory |
176 |
(file-name-sans-extension curfile))))))))) |
(file-name-sans-extension curfile)))))) |
177 |
|
,@(nreverse extra-keywords)))) |
178 |
|
|
179 |
;; The actual function. |
;; The actual function. |
180 |
(defun ,mode (&optional arg ,@extra-args) |
(defun ,mode (&optional arg ,@extra-args) |