How do I disable evil-mode
in a buffer in which git-timemachine
is activated?
This answer is directly from the EVIL developer Frank Fischer,
I tested on Emacs24.4 with latest evil1.0.9+. Most evil key bindings still works, but we let git-timemachine's hotkeys take priority.
;; @see https://bitbucket.org/lyro/evil/issue/511/let-certain-minor-modes-key-bindings
(eval-after-load 'git-timemachine
'(progn
(evil-make-overriding-map git-timemachine-mode-map 'normal)
;; force update evil keymaps after git-timemachine-mode loaded
(add-hook 'git-timemachine-mode-hook #'evil-normalize-keymaps)))
This piece of advice will toggle evil-local-mode
: disabling it when you enable git-timemachine-mode
, and enabling it when you turn off git-timemachine-mode
:
(defadvice git-timemachine-mode (after toggle-evil activate)
"Turn off `evil-local-mode' when enabling
`git-timemachine-mode', and turn it back on when disabling
`git-timemachine-mode'."
(evil-local-mode (if git-timemachine-mode -1 1)))
-
Thanks, this is exactly what I was looking for. Sadly it's not working though. Could it be because git-timemachine-mode is activated by calling git-timemachine (i.e. without -mode at the end)? – lukerandall Mar 7 '15 at 17:02
If you want evil to be in emacs mode when you launch git-timemachine, try that: http://wikemacs.org/wiki/Evil#Enter_an_emacs_mode_in_a_given_state
In a nutshell, try
(evil-set-initial-state 'git-timemachine 'emacs)
evil-mode
is a global minor mode, what you're probably after is not disabling it alltogether (since that would disable it anywhere else, too). – wasamasa Mar 5 '15 at 15:10