4

If I load up emacs and go to my .emacs file (a fragment of which is given below), and I press SPC f or C-c C-f then it does find-file, which is the expected behaviour. However, if I type M-x eval-buffer, or load-file, suddenly SPC f doesn't work, but C-c C-f still does. If I press SPC, it just goes to the next character as it would without evil-leader. What gives?

(require 'evil) 
(evil-mode 1)

(require 'evil-leader)
(global-evil-leader-mode)

(evil-leader/set-leader "<SPC>")

(evil-leader/set-key "f" 'find-file)

(x-posted from superuser.com)

8
  • Comment deleted, as my suggestion didn't work regardless.
    – achalk
    Commented Jan 31, 2017 at 21:00
  • You can't prove this false because you don't have access to my machine. I'm still having this error. I am using eval-buffer and load-file and they both have the same effect. Perhaps it has something to do with my setup somehow? Commented Jan 31, 2017 at 21:15
  • Here's my .emacs file: pastebin.com/fZp5Ddk7 Commented Jan 31, 2017 at 21:26
  • I can confirm that I can reproduce this with your init file, but I don't know what to suggest. When working with evil-mode, I've had problems redefining keys in the evil-normal-state map. But it's bizarre that simply re-evaluating the init file results in different behaviour.
    – achalk
    Commented Feb 1, 2017 at 1:18
  • 2
    Try switching the order of enabling evil-leader and evil. The global-evil-leader-mode sets up a hook which is likely not run if evil is already active.
    – justbur
    Commented Feb 1, 2017 at 2:43

1 Answer 1

3

global-evil-leader-mode adds a function to enable evil-leader-mode through the hook evil-local-mode-hook. This means that evil-leader-mode is enabled in a buffer after enabling evil-local-mode.

In your case, you are enabling evil-local-mode (through the global evil-mode) and then adding to the hook, meaning the hook is run before you added the evil-leader-mode function to it. If you reverse the order of (global-evil-leader-mode) and (evil-mode 1), the problem will be fixed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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