Fix wrong which-key labels & leader key precedence

This changes how leader keys are bound, to fix an issue where the wrong
which-key label was assigned to the wrong keys, and cases where the
leader key was being shadowed by other minor mode mappings.

Unfortunately, this new method adds 10-20% to startup times. I'll
address this in a future patch. For now, correctness is more important.

Also fixes dashboard keybind detection.
This commit is contained in:
Henrik Lissner 2018-12-27 00:06:06 -05:00
parent 6992e27884
commit 63a224f0e8
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 18 additions and 19 deletions

View file

@ -419,17 +419,13 @@ controlled by `+doom-dashboard-pwd-policy'."
'help-echo label)
(format "%-37s" (buffer-string)))
;; Lookup command keys dynamically
(or (let ((maps (list global-map)))
(when (bound-and-true-p evil-normal-state-map)
(push evil-motion-state-map maps)
(push evil-normal-state-map maps))
(when-let* ((key (where-is-internal action maps t)))
(propertize (with-temp-buffer
(save-excursion (insert (key-description key)))
(while (re-search-forward "<\\([^>]+\\)>" nil t)
(replace-match (upcase (substring (match-string 1) 0 3))))
(buffer-string))
'face 'font-lock-constant-face)))
(or (when-let* ((key (where-is-internal action nil t)))
(propertize (with-temp-buffer
(save-excursion (insert (key-description key)))
(while (re-search-forward "<\\([^>]+\\)>" nil t)
(replace-match (upcase (substring (match-string 1) 0 3))))
(buffer-string))
'face 'font-lock-constant-face))
""))))
(if (display-graphic-p)
"\n\n"