cofi / evil-leader

<leader> key for evil
GNU General Public License v3.0
315 stars 22 forks source link

Key bindings are not defined in Fundamental mode with `,' as leader key #10

Closed mistrey closed 11 years ago

mistrey commented 11 years ago

To reproduce:

1) emacs -q

2) Evaluate

(let ((default-directory "/usr/share/emacs/site-lisp")) (normal-top-level-add-subdirs-to-load-path)) (let ((default-directory "~/.emacs.d/")) (normal-top-level-add-subdirs-to-load-path)) (require 'evil-leader) (require 'evil) (setq evil-leader/in-all-states t) (evil-leader/set-leader ",") (global-evil-leader-mode 1) (evil-mode 1) (evil-leader/set-key "tt" 'display-time-mode)

3) Change to buffer Messages and try ",tt"

The same example works with (evil-leader/set-leader "\")

Thank you for sharing your code!

cofi commented 11 years ago

What is the value of evil-leader-mode in *Messages*?

My guess is that *Messages* already exists and the hook to enable evil-leader-mode never triggers. With the original leader-key that happens as well.

mistrey commented 11 years ago

What is the value of evil-leader-mode in Messages? nil

After `M-x evil-leader-mode' it works.

Nevertheless, I question your guess since I have the same effect in all of my buffers that are in fundamental mode, for instance in the buffer Org PDF LaTeX Output. evil-leader-mode is nil there as well.

cofi commented 11 years ago

Yes, something strange happens with fundamental-mode buffers. Nevertheless please try commit e9d047fd7b2ff782a9d413544900576f39c916fa as I can't observe this behavior with the new global mode.

mistrey commented 11 years ago

Nevertheless please try commit e9d047fd7b2ff782a9d413544900576f39c916fa as I can't observe this behavior with the new global mode.

Thank you, it works great.

mistrey commented 11 years ago

Well, it worked. But after changing the order of my initialisation lines (The example mentioned above brought the error message "Wrong type argument: keymapp, nil") after the last update, it's the same like before.

cofi commented 11 years ago

I'm having some problems here ... How does you initialization look now and when do the errors occur?

mistrey commented 11 years ago

With Head: 453adeb Update to 0.3.3. I'm using

(require 'evil)
(require 'evil-leader)
(evil-mode 1)
(setq evil-leader/in-all-states t)
(evil-leader/set-leader ",")
(global-evil-leader-mode 1)

With this setup, variable evil-leader-mode is `nil' in buffer Messages

Dewdrops commented 11 years ago

I have the same problem.

Exactly, only the first Message buffer has this weird behavior, if you kill this buffer, then the new Message buffer WOULD have leader-key defined properly.

marktran commented 11 years ago

I'm also seeing this issue in my *scratch* buffer.

cofi commented 11 years ago

The problem is that in this setup the `evil-local-mode-hook' is not set up correctly for the early buffers.

You have to activate the leader mode before evil mode in order to have a correct hook. I hate to rely on execution order, but here is nothing we can do about it.

mistrey commented 11 years ago

Thank you. I can confirm that the setup below now works correctly. emacs -Q

(require 'evil-leader)
(require 'evil)
(setq evil-leader/in-all-states t)
(evil-leader/set-leader ",")
(global-evil-leader-mode 1)
(evil-mode 1)

Nevertheless, I didn't get it working with these lines in my productive setup with el-get. Finally an additional line (evil-mode nil) did the trick.

So this is my working setup now:

(require 'evil-leader)
(require 'evil)
(setq evil-leader/in-all-states t)
(evil-leader/set-leader ",")
(evil-mode nil)
(global-evil-leader-mode 1)
(evil-mode 1)
cofi commented 11 years ago

It seems that somehow evil-mode got activated somewhere else then.

Dewdrops commented 11 years ago

OK, it works. Thx

Profpatsch commented 10 years ago

It’s not only that you need (require 'evil-leader) before (require 'evil), but in-all-states, too and evil-mode needs to be nil when global-evil-leader-mode is run.

This works, anything else doesn’t:

; Neo2-evil

(evil-mode 1)

;;;; evil-leader
(require 'evil-leader)
(setq evil-leader/in-all-states t)
(evil-leader/set-leader ",")
(evil-mode nil) ;; no idea
(global-evil-leader-mode)
(evil-mode 1)
philc commented 10 years ago

The only way I was able to get evil-leader working in the messages buffer is to kill it after evil-leader has been loaded. Here's my setup:

(require 'evil-leader)
(require 'evil)
(require 'evil-nerd-commenter)
(global-evil-leader-mode t)
(evil-mode t)
(kill-buffer "*Messages*")