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@e26c869735
Amend: 31519d393a
This commit is contained in:
Henrik Lissner 2022-06-17 21:27:53 +02:00
parent 24c658bae9
commit 0a3c123d72
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -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)))