/[emacs]/emacs/lisp/emacs-lisp/easy-mmode.el
ViewVC logotype

Diff of /emacs/lisp/emacs-lisp/easy-mmode.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.46 by lektu, Tue Feb 4 12:53:34 2003 UTC revision 1.47 by monnier, Mon Mar 24 17:41:43 2003 UTC
# Line 90  BODY contains code that will be executed Line 90  BODY contains code that will be executed
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.
# Line 101  BODY contains code that will be executed Line 102  BODY contains code that will be executed
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.
# Line 119  For example, you could write Line 119  For example, you could write
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.
# Line 161  See the command `%s' for a description o Line 164  See the command `%s' for a description o
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
# Line 170  use either \\[customize] or the function Line 173  use either \\[customize] or the function
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)

Legend:
Removed from v.1.46  
changed lines
  Added in v.1.47

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26