Don't bind missing commands to leader keys
I don't want to litter config/default/+evil-bindings.el with conditions for every keybind whose module may or may not be enabled. It impacts its readability and is relatively expensive (due to the internals of map! and general). So instead, we no-op keybinds for commands that don't exist (and aren't autoloaded), so you don't see missing function errors when using these keys.
This commit is contained in:
parent
038e0196c7
commit
d6c9520d93
1 changed files with 12 additions and 5 deletions
|
@ -99,11 +99,18 @@ If any hook returns non-nil, all hooks after it are ignored.")
|
|||
(general--concat t doom-leader-key ,key)
|
||||
,desc)
|
||||
wkforms))
|
||||
(push `(define-key doom-leader-map (general--kbd ,key)
|
||||
,(if (general--extended-def-p unquoted-def)
|
||||
(plist-get unquoted-def :def)
|
||||
def))
|
||||
forms)))))
|
||||
;; Don't bind missing functions (so they don't throw errors when
|
||||
;; used). `fboundp' conveniently returns `t' for autoloaded
|
||||
;; functions as well as defined ones.
|
||||
(let* ((fn (if (general--extended-def-p unquoted-def)
|
||||
(plist-get unquoted-def :def)
|
||||
def))
|
||||
(unquoted-fn (doom-unquote fn)))
|
||||
(when (or (not (symbolp unquoted-fn))
|
||||
(fboundp unquoted-fn))
|
||||
(push `(define-key doom-leader-map (general--kbd ,key)
|
||||
,fn)
|
||||
forms)))))))
|
||||
(macroexp-progn
|
||||
(append (nreverse forms)
|
||||
(when wkforms
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue