From d8fa5f39ade38e1cc955055606cb1c7ee71e4d32 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 26 Aug 2018 16:38:35 +0200 Subject: [PATCH] Omit undefined/disable keybinds in which-key This is for commands in disabled modules. This does not disable their keybinds, but it stops them from showing up in which-key. --- core/core-ui.el | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/core-ui.el b/core/core-ui.el index c31dcb2a3..ad9c70987 100644 --- a/core/core-ui.el +++ b/core/core-ui.el @@ -180,6 +180,14 @@ shorter major mode name in the mode-line. See `doom|set-mode-name'.") (+ (if (boundp 'display-line-numbers) 6 0) fill-column)) +(defun doom*hide-undefined-which-key-binds (bindings) + (cl-loop for bind in bindings + if (or (member (cdr bind) '("Prefix Command" "??")) + (fboundp (intern (cdr bind)))) + collect bind)) +(advice-add #'which-key--get-current-bindings :filter-return #'doom*hide-undefined-which-key-binds) +(advice-add #'which-key--get-keymap-bindings :filter-return #'doom*hide-undefined-which-key-binds) + ;; ;; Built-in packages