From ec57b21a924d88fa0f7e1d747f091c349cca0170 Mon Sep 17 00:00:00 2001 From: duianto Date: Sat, 30 Jan 2021 09:57:38 +0100 Subject: [PATCH] Fix which-key entries: gr and gs in dired and magit problem: pressing g shows the which-key entry: r -> evil-mc but it calls the expected commands: revert-buffer (in dired) magit-refresh s -> evil-easymotion but it calls the expected command: magit-jump-to-staged solution: removing the gr and gs which-key entries, shows the expected commands. --- layers/+source-control/git/packages.el | 9 ++++++++- layers/+spacemacs/spacemacs-defaults/funcs.el | 7 +++++++ layers/+spacemacs/spacemacs-defaults/packages.el | 4 +++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/layers/+source-control/git/packages.el b/layers/+source-control/git/packages.el index a9652ce8d..198ea74a1 100644 --- a/layers/+source-control/git/packages.el +++ b/layers/+source-control/git/packages.el @@ -253,7 +253,14 @@ (evil-define-key 'normal magit-section-mode-map (kbd "M-6") 'spacemacs/winum-select-window-6) (evil-define-key 'normal magit-section-mode-map (kbd "M-7") 'spacemacs/winum-select-window-7) (evil-define-key 'normal magit-section-mode-map (kbd "M-8") 'spacemacs/winum-select-window-8) - (evil-define-key 'normal magit-section-mode-map (kbd "M-9") 'spacemacs/winum-select-window-9)))) + (evil-define-key 'normal magit-section-mode-map (kbd "M-9") 'spacemacs/winum-select-window-9) + ;; Remove inherited bindings from evil-mc and evil-easymotion + ;; do this after the config to make sure the keymap is available + (which-key-add-keymap-based-replacements magit-mode-map + " g r" nil + " g r" nil + " g s" nil + " g s" nil)))) (defun git/init-magit-delta () (use-package magit-delta diff --git a/layers/+spacemacs/spacemacs-defaults/funcs.el b/layers/+spacemacs/spacemacs-defaults/funcs.el index 70fd38553..67b919bf4 100644 --- a/layers/+spacemacs/spacemacs-defaults/funcs.el +++ b/layers/+spacemacs/spacemacs-defaults/funcs.el @@ -121,6 +121,13 @@ If not in such a search box, fall back on `Custom-newline'." (defalias 'spacemacs/display-buffer-other-frame 'display-buffer-other-frame) (defalias 'spacemacs/find-file-and-replace-buffer 'find-alternate-file) +(defun spacemacs/dired-remove-evil-mc-gr-which-key-entry () + ;; Remove inherited bindings from evil-mc + ;; do this after the config to make sure the keymap is available + (which-key-add-keymap-based-replacements dired-mode-map + " g r" nil + " g r" nil)) + (defun spacemacs/indent-region-or-buffer () "Indent a region if selected, otherwise the whole buffer." (interactive) diff --git a/layers/+spacemacs/spacemacs-defaults/packages.el b/layers/+spacemacs/spacemacs-defaults/packages.el index da689e419..07d5d3195 100644 --- a/layers/+spacemacs/spacemacs-defaults/packages.el +++ b/layers/+spacemacs/spacemacs-defaults/packages.el @@ -125,7 +125,9 @@ (evil-define-key 'normal dired-mode-map (kbd "N") 'evil-ex-search-previous)) (when (eq 'hybrid dotspacemacs-editing-style) (evil-define-key 'normal dired-mode-map (kbd "n") 'evil-search-next) - (evil-define-key 'normal dired-mode-map (kbd "N") 'evil-search-previous))) + (evil-define-key 'normal dired-mode-map (kbd "N") 'evil-search-previous)) + (add-hook 'spacemacs-post-user-config-hook + 'spacemacs/dired-remove-evil-mc-gr-which-key-entry)) (defun spacemacs-defaults/init-dired-x () (use-package dired-x