diff options
| -rw-r--r-- | modes/magit/evil-collection-magit.el | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/modes/magit/evil-collection-magit.el b/modes/magit/evil-collection-magit.el index 732ba47..1cdef63 100644 --- a/modes/magit/evil-collection-magit.el +++ b/modes/magit/evil-collection-magit.el @@ -558,6 +558,16 @@ denotes the original magit key for this command.") (eq (magit-diff-type) 'untracked)) (magit-stage-untracked t))) +(defcustom evil-collection-magit-visit-worktree-file-on-return t + "When non-nil (default), RET visits the file in the worktree +\(`magit-diff-visit-worktree-file') and S-<return> visits the file +in the current diff context (`magit-diff-visit-file'). + +When nil, the bindings are swapped: RET uses `magit-diff-visit-file' +and S-<return> uses `magit-diff-visit-worktree-file'." + :group 'magit + :type 'boolean) + (defvar evil-collection-magit-original-section-bindings `((,(copy-keymap magit-file-section-map) "\C-j" magit-diff-visit-worktree-file) (,(copy-keymap magit-hunk-section-map) "\C-j" magit-diff-visit-worktree-file)) @@ -565,17 +575,31 @@ denotes the original magit key for this command.") evil-collection-magit affects.") (defun evil-collection-magit-adjust-section-bindings () - "Revert changed bindings in section maps generated by evil-collection-magit" + "Adjust bindings in section maps for evil-collection-magit." (define-key magit-file-section-map "I" 'evil-collection-magit-stage-untracked-file-with-intent) (define-key magit-file-section-map "\C-j" nil) ; breaking change - (define-key magit-hunk-section-map "\C-j" nil)) ; breaking change + (define-key magit-hunk-section-map "\C-j" nil) ; breaking change + (let ((return-cmd (if evil-collection-magit-visit-worktree-file-on-return + 'magit-diff-visit-worktree-file + 'magit-diff-visit-file)) + (s-return-cmd (if evil-collection-magit-visit-worktree-file-on-return + 'magit-diff-visit-file + 'magit-diff-visit-worktree-file))) + (define-key magit-file-section-map (kbd "RET") return-cmd) + (define-key magit-hunk-section-map (kbd "RET") return-cmd) + (define-key magit-file-section-map (kbd "S-<return>") s-return-cmd) + (define-key magit-hunk-section-map (kbd "S-<return>") s-return-cmd))) (defun evil-collection-magit-revert-section-bindings () - "Revert changed bindings in section maps generated by evil-collection-magit" + "Revert changed bindings in section maps generated by evil-collection-magit." (define-key magit-file-section-map "I" nil) (define-key magit-file-section-map "\C-j" 'magit-diff-visit-file-worktree) - (define-key magit-hunk-section-map "\C-j" 'magit-diff-visit-file-worktree)) + (define-key magit-hunk-section-map "\C-j" 'magit-diff-visit-file-worktree) + (define-key magit-file-section-map (kbd "RET") 'magit-diff-visit-file) + (define-key magit-hunk-section-map (kbd "RET") 'magit-diff-visit-file) + (define-key magit-file-section-map (kbd "S-<return>") nil) + (define-key magit-hunk-section-map (kbd "S-<return>") nil)) ;; Popups |
