3

I'm an evil Emacs user. However, I really only use the normal mode for fancy Vim style edits when I find them more convenient than regular Emacs commands. (Mostly fancy bulk editing/yanking/deleting). However, I'm also a huge user of the minibuffer (I do a lot of M-x with ido and flx so I can avoid remembering the more esoteric commands). When I do, evil switches to normal mode automatically after I exit. I find that very annoying/confusing. How can I get it to stop? (preferably in an elegant, non-hackish way).

Thanks, PythonNut

EDIT:

It appears that the switch to normal mode happens in all windows and in all frames.

PythonNut
  • 6,182
  • 1
  • 25
  • 41
  • Actually, on inspection. It seems that the switch to normal mode happens when I enter the minibuffer, not when I exit it. The interesting thing is, the contents of `minibuffer-setup-hook` don't include any evil hooks. it's contents are `(minibuffer-depth-setup icicle-minibuffer-setup ido-minibuffer-setup auto-indent-minibuffer-hook rfn-eshadow-setup-minibuffer minibuffer-history-isearch-setup minibuffer-history-initialize)` – PythonNut Aug 08 '13 at 01:21

2 Answers2

1

You may reactivate evil-mode by adding whatever function you use to activate it to minibuffer-exit-hook.

juanleon
  • 9,220
  • 30
  • 41
  • Whatever happens, it happens after the call to minibuffer-exit-hook. `(add-hook 'minibuffer-exit-hook 'evil-emacs-state)` doesn't stop the change to normal mode. – PythonNut Aug 06 '13 at 22:17
  • I am not familiar with evil so I cannot comment on `evil-emacs-state`, but what about using this in the hook `(run-with-timer 0.2 nil 'evil-emacs-state)` (with a lambda). It is sort of a hack: the code will run 0.2 secs after exiting minibuffer. – juanleon Aug 07 '13 at 07:19
  • That works, but evil still seems confused about state. My modeline is colored by evil state, and it's still in normal-mode even though evil is actually in insert-mode. – PythonNut Oct 22 '13 at 18:54
1

I cannot reproduce your issue; maybe knowing your versions could help anyone to identify your issue. Can you reproduce your issue with "emacs -q" (plus adding evil to load-path)?

Here is an approach to identify the evil (traditional English meaning) piece of code, if any, that is calling to evil-normal-state:

(defadvice evil-normal-state (before debug-issue activate)
  (setq debug-on-error t)
  (inexisting-function-will-fail))

Eval this just after setting a buffer in the evil-state you want it to be, then go to to the minibuffer with M-x. Is there an stacktrace?

juanleon
  • 9,220
  • 30
  • 41
  • It does not happen in emacs -Q. I do get an error: `Error in post-command-hook (evil-mode-check-buffers): (void-function ...)` – PythonNut Oct 24 '13 at 03:46
  • Okay, I found the issue by binary search. I wrapped evil in my own global mode, so I could have evil everywhere. How can I get the behaviour of a global mode without it? – PythonNut Oct 24 '13 at 03:54
  • Fixed it myself :). You win the bounty. – PythonNut Oct 24 '13 at 03:59