From 0a3c123d7206d1b3feecb3636f128b6340e732dd Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 17 Jun 2022 21:27:53 +0200 Subject: [PATCH] fix(magit): {1-4} overriding evil keybinds evil-collection-magit-section introduces some redundant keybinds on number keys 1-4, so our hack to correct these keys needed an adjustment. And by unbinding these keys at the source (magit-section-mode-map), we don't have to do the same for each inheriting keymap (like code-review-mode-map and magit-mode-map). Ref: emacs-evil/evil-collection@e26c8697354e Amend: 31519d393a8b --- modules/tools/magit/config.el | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/modules/tools/magit/config.el b/modules/tools/magit/config.el index 271ffee56..bc4cb643e 100644 --- a/modules/tools/magit/config.el +++ b/modules/tools/magit/config.el @@ -227,17 +227,11 @@ ensure it is built when we actually use Forge." :defer t :init (defvar evil-collection-magit-use-z-for-folds t) :config - ;; These numbered keys mask the numerical prefix keys. Since they've already - ;; been replaced with z1, z2, z3, etc (and 0 with g=), there's no need to keep - ;; them around: - (undefine-key! magit-mode-map "M-1" "M-2" "M-3" "M-4" "1" "2" "3" "4" "0") - ;; q is enough; ESC is way too easy for a vimmer to accidentally press, ;; especially when traversing modes in magit buffers. (evil-define-key* 'normal magit-status-mode-map [escape] nil) (after! code-review - (undefine-key! code-review-mode-map "M-1" "M-2" "M-3" "M-4" "1" "2" "3" "4" "0") (map! :map code-review-mode-map :n "r" #'code-review-transient-api :n "RET" #'code-review-comment-add-or-edit)) @@ -290,3 +284,17 @@ ensure it is built when we actually use Forge." (transient-append-suffix 'magit-dispatch '(0 -1 -1) '("*" "Worktree" magit-worktree))) + + +(use-package! evil-collection-magit-section + :when (featurep! :editor evil +everywhere) + :defer t + :init + (defvar evil-collection-magit-section-use-z-for-folds evil-collection-magit-use-z-for-folds) + (after! magit-section + ;; These numbered keys mask the numerical prefix keys. Since they've already + ;; been replaced with z1, z2, z3, etc (and 0 with g=), there's no need to + ;; keep them around: + (undefine-key! magit-section-mode-map "M-1" "M-2" "M-3" "M-4" "1" "2" "3" "4" "0") + ;; `evil-collection-magit-section' binds these redundant keys. + (map! :map magit-section-mode-map :n "1" nil :n "2" nil :n "3" nil :n "4" nil)))