1

I am newbie here, need some help.

After upgrade magit to v2.1.0 this morning, i found some short keys are different from the early version. What bothers me is this:

when I use some short key(for example 'b'), it shows the option windows, in early version, i just type another short key in the option window to do the action (like checkout branch). But now in v2.1.0 i find i can't do it anymore. As I use evil-mode for vim operation, the option windows is in evil-mode, and i only can use magit short key after i enter the insert mode of evil-mode.

Can anyone tells me how to disable evil-mode in the whole magit?

  • What I would recommend is to only enable evil-local-mode for the modes you actually need Evil in (e.g. writing text modes, programming modes). You can do this with hooks. And optionally you can have a handy key-binding to toggle evil-local-mode on demand. (e.g. john2x.com/emacs.html#sec-8-19). Alternatively, you can toggle Evil's "emacs mode" by pressing C-z. – john2x Aug 7 '15 at 3:59
  • 1
    Don't. Evil is intended to be used as global mode. – wasamasa Aug 7 '15 at 9:00
  • I did not know that. Yeah, that show-paren thing has been bugging me for a long time. I didn't realize it was because I was using evil-local-mode. I guess it's time to shave some yaks. – john2x Aug 7 '15 at 10:41
6

Evil has the concept of states (just like modes in Vim). Customize the initial state of Magit buffers to not be normal anymore:

(eval-after-load 'evil-core
  '(evil-set-initial-state 'magit-popup-mode 'emacs))

Alternatively, upgrade your Evil installation because this got added to their whitelist of initial states :)

  • Would it be possible to do the reverse? Make emacs as the default state, and only set to normal state on select modes? – john2x Aug 7 '15 at 10:42
  • Sure, but it would be even more tedious to do so unless you have a hack to make the lookup of the initial state somewhat automatic. An example of this can be found in my init.org. – wasamasa Aug 7 '15 at 10:46
  • I've got in contact with upstream, but there hasn't been much of a reaction yet. – wasamasa Aug 7 '15 at 10:47
0

You can do something like that:

(add-hook 'after-change-major-mode-hook
            '(lambda () 
               (evil-mode (if (or (equal major-mode 'magit-log-mode) (equal major-mode 'magit-popup-mode) (equal major-mode 'magit-status-mode)(equal major-mode 'magit-mode)) 0 1))))

But magit is a set of major mode and it will not work every where. For example the commit window is in text-mode so you need to add text-mode

(add-hook 'after-change-major-mode-hook
                '(lambda () 
                   (evil-mode (if (or (equal major-mode 'text-mode) (equal major-mode 'magit-log-mode) (equal major-mode 'magit-popup-mode) (equal major-mode 'magit-status-mode)(equal major-mode 'magit-mode)) 0 1))))

But now text-mode is not in evil-mode so... Maybe the good solution is https://github.com/tarleb/evil-rebellion

Regards

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.