comparison lisp/emacs-lisp/easy-mmode.el @ 112345:32f10f475431

* emacs-lisp/easy-mmode.el (define-minor-mode): Don't re-evaluate the keymap expression. Improve docstring.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 17 Jan 2011 16:42:23 -0500
parents 376148b31b5e
children 67bea318ed68
comparison
equal deleted inserted replaced
112344:7c2cdabbc4a9 112345:32f10f475431
91 91
92 Optional INIT-VALUE is the initial value of the mode's variable. 92 Optional INIT-VALUE is the initial value of the mode's variable.
93 Optional LIGHTER is displayed in the modeline when the mode is on. 93 Optional LIGHTER is displayed in the modeline when the mode is on.
94 Optional KEYMAP is the default keymap bound to the mode keymap. 94 Optional KEYMAP is the default keymap bound to the mode keymap.
95 If non-nil, it should be a variable name (whose value is a keymap), 95 If non-nil, it should be a variable name (whose value is a keymap),
96 a keymap, or a list of arguments for `easy-mmode-define-keymap'. 96 or an expression that returns either a keymap or a list of
97 If KEYMAP is a keymap or list, this also defines the variable MODE-map. 97 arguments for `easy-mmode-define-keymap'. If KEYMAP is not a symbol,
98 this also defines the variable MODE-map.
98 99
99 BODY contains code to execute each time the mode is enabled or disabled. 100 BODY contains code to execute each time the mode is enabled or disabled.
100 It is executed after toggling the mode, and before running MODE-hook. 101 It is executed after toggling the mode, and before running MODE-hook.
101 Before the actual body code, you can write keyword arguments, i.e. 102 Before the actual body code, you can write keyword arguments, i.e.
102 alternating keywords and values. These following special keywords 103 alternating keywords and values. These following special keywords
254 ,(unless (symbolp keymap) ;nil is also a symbol. 255 ,(unless (symbolp keymap) ;nil is also a symbol.
255 `(defvar ,keymap-sym 256 `(defvar ,keymap-sym
256 (let ((m ,keymap)) 257 (let ((m ,keymap))
257 (cond ((keymapp m) m) 258 (cond ((keymapp m) m)
258 ((listp m) (easy-mmode-define-keymap m)) 259 ((listp m) (easy-mmode-define-keymap m))
259 (t (error "Invalid keymap %S" ,keymap)))) 260 (t (error "Invalid keymap %S" m))))
260 ,(format "Keymap for `%s'." mode-name))) 261 ,(format "Keymap for `%s'." mode-name)))
261 262
262 (add-minor-mode ',mode ',lighter 263 (add-minor-mode ',mode ',lighter
263 ,(if keymap keymap-sym 264 ,(if keymap keymap-sym
264 `(if (boundp ',keymap-sym) ,keymap-sym)))))) 265 `(if (boundp ',keymap-sym) ,keymap-sym))))))