1

I have the following in my init.el, and it does a great job of automatically disabling evil in certain emacs modes:

(dolist (mode '(git-rebase-mode
        flycheck-error-list-mode
        inf-ruby-mode
        term-mode))
  (add-to-list 'evil-emacs-state-modes mode))

However, this will not work for help-mode, which is frustrating, as help-mode has some great keybindings I'd like to take advantage of. I've also tried this: (add-to-list 'evil-emacs-state-modes 'help-mode), but it didn't work either.

How can I turn off evil in help-mode?

7

The reason this fails is because help-mode is in evil-motion-state-modes by default, adding it to evil-emacs-state-modes will therefore not have the desired effect as Evil looks it up in evil-motion-state-modes first to determine the initial state.

The correct way to change the initial state of a mode is by using evil-set-initial-state:

(evil-set-initial-state 'help-mode 'emacs)

This helper function ensures that a given mode cannot be in more than one of the evil-*-state-modes variables. Alternatively customize every initial state variable to hold the correct modes and make sure you're not introducing any duplicates.

  • Thanks, this fixed the problem and taught me more about emacs lisp functions. – tcelferact Mar 5 '17 at 20:14

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.