aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2003-03-24 17:41:43 +0000
committerStefan Monnier2003-03-24 17:41:43 +0000
commit73ceba9f1a70558433cb9962a9e5255482b561dc (patch)
treeea60a4a8f472ee5e0694317780199a11b7e85cc2
parent4a1186d3889e7cdc57ff093ef0e2af7d892cbab7 (diff)
downloademacs-73ceba9f1a70558433cb9962a9e5255482b561dc.tar.gz
emacs-73ceba9f1a70558433cb9962a9e5255482b561dc.zip
(define-minor-mode): Use custom-set-minor-mode.
Pass unknown keyword args blindly to defcustom.
-rw-r--r--lisp/emacs-lisp/easy-mmode.el22
1 files changed, 13 insertions, 9 deletions
diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el
index c0b77fcf428..c331bd744e3 100644
--- a/lisp/emacs-lisp/easy-mmode.el
+++ b/lisp/emacs-lisp/easy-mmode.el
@@ -90,7 +90,8 @@ BODY contains code that will be executed each time the mode is (dis)activated.
90 It will be executed after any toggling but before running the hooks. 90 It will be executed after any toggling but before running the hooks.
91 Before the actual body code, you can write 91 Before the actual body code, you can write
92 keyword arguments (alternating keywords and values). 92 keyword arguments (alternating keywords and values).
93 These following keyword arguments are supported: 93 These following keyword arguments are supported (other keywords
94 will be passed to `defcustom' if the minor mode is global):
94:group GROUP Custom group name to use in all generated `defcustom' forms. 95:group GROUP Custom group name to use in all generated `defcustom' forms.
95:global GLOBAL If non-nil specifies that the minor mode is not meant to be 96:global GLOBAL If non-nil specifies that the minor mode is not meant to be
96 buffer-local, so don't make the variable MODE buffer-local. 97 buffer-local, so don't make the variable MODE buffer-local.
@@ -101,8 +102,7 @@ BODY contains code that will be executed each time the mode is (dis)activated.
101 102
102For example, you could write 103For example, you could write
103 (define-minor-mode foo-mode \"If enabled, foo on you!\" 104 (define-minor-mode foo-mode \"If enabled, foo on you!\"
104 nil \"Foo \" foo-keymap 105 :lighter \" Foo\" :require 'foo :global t :group 'hassle :version \"27.5\"
105 :require 'foo :global t :group 'inconvenience
106 ...BODY CODE...)" 106 ...BODY CODE...)"
107 107
108 ;; Allow skipping the first three args. 108 ;; Allow skipping the first three args.
@@ -119,23 +119,26 @@ For example, you could write
119 (globalp nil) 119 (globalp nil)
120 (group nil) 120 (group nil)
121 (extra-args nil) 121 (extra-args nil)
122 (extra-keywords nil)
122 (require t) 123 (require t)
123 (keymap-sym (if (and keymap (symbolp keymap)) keymap 124 (keymap-sym (if (and keymap (symbolp keymap)) keymap
124 (intern (concat mode-name "-map")))) 125 (intern (concat mode-name "-map"))))
125 (hook (intern (concat mode-name "-hook"))) 126 (hook (intern (concat mode-name "-hook")))
126 (hook-on (intern (concat mode-name "-on-hook"))) 127 (hook-on (intern (concat mode-name "-on-hook")))
127 (hook-off (intern (concat mode-name "-off-hook")))) 128 (hook-off (intern (concat mode-name "-off-hook")))
129 keyw)
128 130
129 ;; Check keys. 131 ;; Check keys.
130 (while (keywordp (car body)) 132 (while (keywordp (setq keyw (car body)))
131 (case (pop body) 133 (setq body (cdr body))
134 (case keyw
132 (:init-value (setq init-value (pop body))) 135 (:init-value (setq init-value (pop body)))
133 (:lighter (setq lighter (pop body))) 136 (:lighter (setq lighter (pop body)))
134 (:global (setq globalp (pop body))) 137 (:global (setq globalp (pop body)))
135 (:extra-args (setq extra-args (pop body))) 138 (:extra-args (setq extra-args (pop body)))
136 (:group (setq group (nconc group (list :group (pop body))))) 139 (:group (setq group (nconc group (list :group (pop body)))))
137 (:require (setq require (pop body))) 140 (:require (setq require (pop body)))
138 (t (pop body)))) 141 (t (push keyw extra-keywords) (push (pop body) extra-keywords))))
139 142
140 (unless group 143 (unless group
141 ;; We might as well provide a best-guess default group. 144 ;; We might as well provide a best-guess default group.
@@ -161,7 +164,7 @@ See the command `%s' for a description of this minor-mode.
161Setting this variable directly does not take effect; 164Setting this variable directly does not take effect;
162use either \\[customize] or the function `%s'." 165use either \\[customize] or the function `%s'."
163 pretty-name mode mode) 166 pretty-name mode mode)
164 :set (lambda (symbol value) (funcall symbol (or value 0))) 167 :set 'custom-set-minor-mode
165 :initialize 'custom-initialize-default 168 :initialize 'custom-initialize-default
166 ,@group 169 ,@group
167 :type 'boolean 170 :type 'boolean
@@ -170,7 +173,8 @@ use either \\[customize] or the function `%s'."
170 ((not (eq require t)) `(:require ,require)) 173 ((not (eq require t)) `(:require ,require))
171 (t `(:require 174 (t `(:require
172 ',(intern (file-name-nondirectory 175 ',(intern (file-name-nondirectory
173 (file-name-sans-extension curfile))))))))) 176 (file-name-sans-extension curfile))))))
177 ,@(nreverse extra-keywords))))
174 178
175 ;; The actual function. 179 ;; The actual function.
176 (defun ,mode (&optional arg ,@extra-args) 180 (defun ,mode (&optional arg ,@extra-args)