diff options
-rw-r--r-- | init.el | 4 | ||||
-rw-r--r-- | lisp/acdw.el | 27 |
2 files changed, 25 insertions, 6 deletions
diff --git a/init.el b/init.el index 8836991..466c280 100644 --- a/init.el +++ b/init.el | |||
@@ -432,7 +432,9 @@ indicator in the mode-line." | |||
432 | (org-export-with-smart-quotes t) | 432 | (org-export-with-smart-quotes t) |
433 | (org-export-with-sub-superscripts t)) | 433 | (org-export-with-sub-superscripts t)) |
434 | :hooks ((before-save-hook acdw/hook--org-mode-fix-blank-lines)) | 434 | :hooks ((before-save-hook acdw/hook--org-mode-fix-blank-lines)) |
435 | :binds (("RET" unpackaged/org-return-dwim :map org-mode-map))) | 435 | :binds (("RET" unpackaged/org-return-dwim |
436 | :map org-mode-map :map-after 'org))) | ||
437 | |||
436 | 438 | ||
437 | ;;; Programming languages | 439 | ;;; Programming languages |
438 | 440 | ||
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'. | |||
145 | The following keywords are recognized: | 145 | The 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 | ||