I have a set of key bindings that I use for both web-mode
and php-mode
in insert mode (of Evil). So I cannot use set-local-map
or something. Because in normal mode, the same keys will then call other commands. So the bindings need to be active in evil-insert-state-map
only.
I have the following:
(eval-after-load 'php-mode
'(progn
(define-key evil-insert-state-map
(kbd "C-<next>") (lambda () (interactive) (insert " = ")))
(define-key evil-insert-state-map
(kbd "C-<prior>") (lambda () (interactive) (insert "->")))))
(eval-after-load 'web-mode
'(progn
(define-key evil-insert-state-map
(kbd "C-<next>") 'zencoding-expand-yas)
(define-key evil-insert-state-map
(kbd "C-<prior>") 'zencoding-expand-line)))
So every time web-mode
or php-mode
is being loaded, these key bindings will be activated.
The problem is: Suppose I have two open buffers, one in the php-mode
and the other in web-mode
. When the web-mode
buffer is the current buffer and I switch to an another buffer which's in php-mode
, the web-mode
bindings are still active inside the php-mode
buffer.
I tried to solve this problem by using (add-hook 'web-mode-hook [...])
and (add-hook 'php-mode-hook [...])
instead of setting up the bindings in eval-after-load
. But that solution doesn't work in this situation.
Any suggestions? I would really appreciate it.