Mercurial > emacs
comparison lisp/emacs-lisp/easy-mmode.el @ 66721:67170e911864
(define-global-minor-mode): Pass all specified keyword args on to
`define-minor-mode'. Update docstring.
author | Luc Teirlinck <teirllm@auburn.edu> |
---|---|
date | Sat, 05 Nov 2005 23:03:57 +0000 |
parents | e1fcf3783add |
children | 32fa638322e0 |
comparison
equal
deleted
inserted
replaced
66720:f41b7662a7a5 | 66721:67170e911864 |
---|---|
270 ;;;###autoload | 270 ;;;###autoload |
271 (defmacro define-global-minor-mode (global-mode mode turn-on &rest keys) | 271 (defmacro define-global-minor-mode (global-mode mode turn-on &rest keys) |
272 "Make GLOBAL-MODE out of the buffer-local minor MODE. | 272 "Make GLOBAL-MODE out of the buffer-local minor MODE. |
273 TURN-ON is a function that will be called with no args in every buffer | 273 TURN-ON is a function that will be called with no args in every buffer |
274 and that should try to turn MODE on if applicable for that buffer. | 274 and that should try to turn MODE on if applicable for that buffer. |
275 KEYS is a list of CL-style keyword arguments: | 275 KEYS is a list of CL-style keyword arguments. As the minor mode |
276 :group to specify the custom group. | 276 defined by this function is always global, any :global keyword is |
277 ignored. Other keywords have the same meaning as in `define-minor-mode', | |
278 which see. In particular, :group specifies the custom group. | |
279 The most useful keywords are those that are passed on to the | |
280 `defcustom'. It normally makes no sense to pass the :lighter | |
281 or :keymap keywords to `define-global-minor-mode', since these | |
282 are usually passed to the buffer-local version of the minor mode. | |
277 | 283 |
278 If MODE's set-up depends on the major mode in effect when it was | 284 If MODE's set-up depends on the major mode in effect when it was |
279 enabled, then disabling and reenabling MODE should make MODE work | 285 enabled, then disabling and reenabling MODE should make MODE work |
280 correctly with the current major mode. This is important to | 286 correctly with the current major mode. This is important to |
281 prevent problems with derived modes, that is, major modes that | 287 prevent problems with derived modes, that is, major modes that |
283 | 289 |
284 (let* ((global-mode-name (symbol-name global-mode)) | 290 (let* ((global-mode-name (symbol-name global-mode)) |
285 (pretty-name (easy-mmode-pretty-mode-name mode)) | 291 (pretty-name (easy-mmode-pretty-mode-name mode)) |
286 (pretty-global-name (easy-mmode-pretty-mode-name global-mode)) | 292 (pretty-global-name (easy-mmode-pretty-mode-name global-mode)) |
287 (group nil) | 293 (group nil) |
288 (extra-args nil) | 294 (extra-keywords nil) |
289 (MODE-buffers (intern (concat global-mode-name "-buffers"))) | 295 (MODE-buffers (intern (concat global-mode-name "-buffers"))) |
290 (MODE-enable-in-buffers | 296 (MODE-enable-in-buffers |
291 (intern (concat global-mode-name "-enable-in-buffers"))) | 297 (intern (concat global-mode-name "-enable-in-buffers"))) |
292 (MODE-check-buffers | 298 (MODE-check-buffers |
293 (intern (concat global-mode-name "-check-buffers"))) | 299 (intern (concat global-mode-name "-check-buffers"))) |
294 (MODE-cmhh (intern (concat global-mode-name "-cmhh"))) | 300 (MODE-cmhh (intern (concat global-mode-name "-cmhh"))) |
295 (MODE-major-mode (intern (concat (symbol-name mode) "-major-mode")))) | 301 (MODE-major-mode (intern (concat (symbol-name mode) "-major-mode"))) |
302 keyw) | |
296 | 303 |
297 ;; Check keys. | 304 ;; Check keys. |
298 (while (keywordp (car keys)) | 305 (while (keywordp (setq keyw (car keys))) |
299 (case (pop keys) | 306 (setq keys (cdr keys)) |
300 (:extra-args (setq extra-args (pop keys))) | 307 (case keyw |
301 (:group (setq group (nconc group (list :group (pop keys))))) | 308 (:group (setq group (nconc group (list :group (pop keys))))) |
302 (t (setq keys (cdr keys))))) | 309 (:global (setq keys (cdr keys))) |
310 (t (push keyw extra-keywords) (push (pop keys) extra-keywords)))) | |
303 | 311 |
304 (unless group | 312 (unless group |
305 ;; We might as well provide a best-guess default group. | 313 ;; We might as well provide a best-guess default group. |
306 (setq group | 314 (setq group |
307 `(:group ',(intern (replace-regexp-in-string | 315 `(:group ',(intern (replace-regexp-in-string |
315 ,(format "Toggle %s in every buffer. | 323 ,(format "Toggle %s in every buffer. |
316 With prefix ARG, turn %s on if and only if ARG is positive. | 324 With prefix ARG, turn %s on if and only if ARG is positive. |
317 %s is actually not turned on in every buffer but only in those | 325 %s is actually not turned on in every buffer but only in those |
318 in which `%s' turns it on." | 326 in which `%s' turns it on." |
319 pretty-name pretty-global-name pretty-name turn-on) | 327 pretty-name pretty-global-name pretty-name turn-on) |
320 :global t :extra-args ,extra-args ,@group | 328 :global t ,@group ,@(nreverse extra-keywords) |
321 | 329 |
322 ;; Setup hook to handle future mode changes and new buffers. | 330 ;; Setup hook to handle future mode changes and new buffers. |
323 (if ,global-mode | 331 (if ,global-mode |
324 (progn | 332 (progn |
325 (add-hook 'after-change-major-mode-hook | 333 (add-hook 'after-change-major-mode-hook |