mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-01 12:17:25 -05:00
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:
@ -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
|
||||
|
Reference in New Issue
Block a user