summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/acdw.el27
1 files changed, 22 insertions, 5 deletions
diff --git a/lisp/acdw.el b/lisp/acdw.el index 84fcb99..e25de43 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el
@@ -145,20 +145,37 @@ otherwise it's wrapped in `kbd'.
145The following keywords are recognized: 145The following keywords are recognized:
146 146
147:after ARGS .. call `autoload' on COMMAND using ARGS before 147:after ARGS .. call `autoload' on COMMAND using ARGS before
148 binding the key. ARGS can be just the filename to 148 binding the key. ARGS can be just the filename to
149 load; in that case it's wrapped in a list. 149 load; in that case it's wrapped in a list.
150
150:map KEYMAP .. define KEY in KEYMAP instead of the 151:map KEYMAP .. define KEY in KEYMAP instead of the
151 default `acdw/bind-default-map'." 152 default `acdw/bind-default-map'. If `:after' is also supplied,
153 run `autoload' on KEYMAP (except when using `:map-after', see).
154
155:map-after FILE .. run the underlying `define-key' command in an
156 `with-eval-after-load'. For the rare occasion when the keymap is
157 defined in a different file than the command it binds (looking
158 at you, `org-mode')."
152 (let ((after (when-let (sym (plist-get args :after)) 159 (let ((after (when-let (sym (plist-get args :after))
153 (if (not (listp sym)) 160 (if (not (listp sym))
154 (list sym) 161 (list sym)
155 sym))) 162 sym)))
163 (map-after (plist-get args :map-after))
156 (keymap (or (plist-get args :map) acdw/bind-default-map)) 164 (keymap (or (plist-get args :map) acdw/bind-default-map))
157 (keycode (if (vectorp key) key (kbd key))) 165 (keycode (if (vectorp key) key (kbd key)))
158 (command-list)) 166 (command-list))
159 (push `(define-key ,keymap ,keycode ',command) command-list) 167 (let ((define-key-command `(define-key ,keymap ,keycode ',command)))
168 (if map-after
169 (push `(with-eval-after-load ,map-after
170 ,define-key-command)
171 command-list)
172 (push define-key-command command-list)))
160 (when after 173 (when after
161 (push `(autoload ',command ,@after) command-list)) 174 (unless (fboundp command)
175 (push `(autoload ',command ,@after) command-list))
176 (unless (or map-after
177 (eq keymap acdw/bind-default-map))
178 (push `(autoload ',keymap ,(car after) nil nil 'keymap) command-list)))
162 `(progn 179 `(progn
163 ,@command-list))) 180 ,@command-list)))
164 181