changeset 50300:7e4e15b857f3

(define-minor-mode): Use custom-set-minor-mode. Pass unknown keyword args blindly to defcustom.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 24 Mar 2003 17:41:43 +0000
parents c17e35df0d3e
children c0f3ec529c05
files lisp/emacs-lisp/easy-mmode.el
diffstat 1 files changed, 13 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/emacs-lisp/easy-mmode.el	Mon Mar 24 17:29:20 2003 +0000
+++ b/lisp/emacs-lisp/easy-mmode.el	Mon Mar 24 17:41:43 2003 +0000
@@ -90,7 +90,8 @@
   It will be executed after any toggling but before running the hooks.
   Before the actual body code, you can write
   keyword arguments (alternating keywords and values).
-  These following keyword arguments are supported:
+  These following keyword arguments are supported (other keywords
+  will be passed to `defcustom' if the minor mode is global):
 :group GROUP	Custom group name to use in all generated `defcustom' forms.
 :global GLOBAL	If non-nil specifies that the minor mode is not meant to be
               	buffer-local, so don't make the variable MODE buffer-local.
@@ -101,8 +102,7 @@
 
 For example, you could write
   (define-minor-mode foo-mode \"If enabled, foo on you!\"
-    nil \"Foo \" foo-keymap
-    :require 'foo :global t :group 'inconvenience
+    :lighter \" Foo\" :require 'foo :global t :group 'hassle :version \"27.5\"
     ...BODY CODE...)"
 
   ;; Allow skipping the first three args.
@@ -119,23 +119,26 @@
 	 (globalp nil)
 	 (group nil)
 	 (extra-args nil)
+	 (extra-keywords nil)
 	 (require t)
 	 (keymap-sym (if (and keymap (symbolp keymap)) keymap
 		       (intern (concat mode-name "-map"))))
 	 (hook (intern (concat mode-name "-hook")))
 	 (hook-on (intern (concat mode-name "-on-hook")))
-	 (hook-off (intern (concat mode-name "-off-hook"))))
+	 (hook-off (intern (concat mode-name "-off-hook")))
+	 keyw)
 
     ;; Check keys.
-    (while (keywordp (car body))
-      (case (pop body)
+    (while (keywordp (setq keyw (car body)))
+      (setq body (cdr body))
+      (case keyw
 	(:init-value (setq init-value (pop body)))
 	(:lighter (setq lighter (pop body)))
 	(:global (setq globalp (pop body)))
 	(:extra-args (setq extra-args (pop body)))
 	(:group (setq group (nconc group (list :group (pop body)))))
 	(:require (setq require (pop body)))
-	(t (pop body))))
+	(t (push keyw extra-keywords) (push (pop body) extra-keywords))))
 
     (unless group
       ;; We might as well provide a best-guess default group.
@@ -161,7 +164,7 @@
 Setting this variable directly does not take effect;
 use either \\[customize] or the function `%s'."
 			pretty-name mode mode)
-	       :set (lambda (symbol value) (funcall symbol (or value 0)))
+	       :set 'custom-set-minor-mode
 	       :initialize 'custom-initialize-default
 	       ,@group
 	       :type 'boolean
@@ -170,7 +173,8 @@
 		  ((not (eq require t)) `(:require ,require))
 		  (t `(:require
 		       ',(intern (file-name-nondirectory
-				  (file-name-sans-extension curfile)))))))))
+				  (file-name-sans-extension curfile))))))
+	       ,@(nreverse extra-keywords))))
 
        ;; The actual function.
        (defun ,mode (&optional arg ,@extra-args)