Support git-timemachine
Supports evil bindings for git-timemachine. On my machine, git-timemachine starts with evil in normal mode, which is problematic when trying to access the keybindings "n" and "p", which navigate to the next and previous revisions. Additionally, normal mode eclispses "q", which exits the mode. I tried using `(evil-set-initial-state 'git-timemachine-mode 'motion)`, but that didn't work. I assume this is because `git-timemachine` is a minor-mode. To work around this, I used `add-hook` to ensure motion mode was the initial state. Once motion mode is the initial state, "p" and "q" become available. Unfortunately, "n" is still not. To get around this, I used a buffer-local binding in the local motion state map to map "n" appropriately. One known shortcoming of this approach is that there is no cleanup done after exiting the mode. Any suggestions are eagerly welcomed. Forgive any crude techniques that I used to get this functioning. I just wanted to broach the discussion with some of the other maintainers to get some insights and hopefully augment my implementation as needed.
This commit is contained in:
parent
aca031a7f3
commit
9298988cc4
|
@ -0,0 +1,22 @@
|
|||
;;; evil-collection-git-timemachine.el --- Bindings for `git-timemachine' -*- lexical-binding: t -*-
|
||||
;; Author: William Carroll <wpcarro@gmail.com>
|
||||
|
||||
;;; Commentary:
|
||||
;; Evil keybindings for `git-timemachine' that conform to the principles outlines in evil-collection
|
||||
|
||||
;;; Code:
|
||||
(require 'evil)
|
||||
(require 'git-timemachine)
|
||||
|
||||
(defun ecgt--setup-bindings ()
|
||||
"Setup `git-timemachine' since `evil-set-initial-state' is unavailable to
|
||||
minor modes."
|
||||
(evil-motion-state nil)
|
||||
(evil-local-set-key 'motion "n" #'git-timemachine-show-next-revision))
|
||||
|
||||
(defun evil-collection-git-timemachine-setup ()
|
||||
"Setup `evil' keybindings for `git-timemachine'."
|
||||
(add-hook 'git-timemachine-mode-hook #'ecgt--setup-bindings))
|
||||
|
||||
(provide 'evil-collection-git-timemachine)
|
||||
;;; evil-collection-git-timemachine.el ends here
|
Loading…
Reference in New Issue