emacs ecb conflicts with evil-mode?
Frank Fischer
frank-fischer at shadow-soft.de
Fri Mar 15 21:24:24 CET 2013
On 2013-03-02, Hongxu Chen <leftcopy.chx at gmail.com> wrote:
> --===============1925688492==
> Hi all,
>
> I am new to Emacs(and evil-mode). Currently I have difficulties in
> using evil-mode when *ecb mode* is activated. The problem is that the *Enter
> *key is no longer available in any windows of ecb, so I cannot switch from
> the navigation window to the source code window at the right side. I also
> tried `(evil-set-initial-state 'ecb-minor-mode 'emacs)`, this time I can
> use the default key-bindings in ecb(and so is the *Enter *key). What annoys
> me is that when I switch to the source code, evil-mode key-bindings are
> deactivated. And even I now toggle ecb-minor-mode off, the key-bindings are
> still not available. So I have to `M-x evil-mode` twice to use the right
> evil-mode.
I do not know ecb in detail, but ecb-minor-mode seems to be active in
each buffer when ecb is active. Hence, using 'ecb-minor-mode to modify
Evil states is a bad idea, because it will influence every buffer.
Unfortunately ecb buffer windows do not have a specific major mode.
However, there are several hooks. I suggest you try the following
hooks (but note that you must not enable/disable evil mode while ecb is
active because these hooks are only called when the ecb buffers are
created, and you must install these hooks *before* ecb is activated):
(add-hook 'ecb-history-buffer-after-create-hook 'evil-emacs-state)
(add-hook 'ecb-directories-buffer-after-create-hook 'evil-emacs-state)
(add-hook 'ecb-methods-buffer-after-create-hook 'evil-emacs-state)
(add-hook 'ecb-sources-buffer-after-create-hook 'evil-emacs-state)
Alternatively if only the *Enter* key annoys you, you can disable
evil's special binding of RET:
(define-key evil-motion-state-map (kbd "RET") nil)
I have the feeling that this function needs a rewrite anyway. Yes, it
simulates Vim's behaviour of the Enter key, but it often makes trouble
if Enter is bound to something special in some modes. I think, it is
not really useful in most motion state buffers, so maybe you should
just bind it in normal state only:
(define-key evil-normal-state-map (kbd "RET") 'evil-ret)
If you remove the RET key from motion-state, then you should be able
to use motion-state in ecb windows, which gives you a few bindings
like h j k l:
(add-hook 'ecb-history-buffer-after-create-hook 'evil-motion-state)
(add-hook 'ecb-directories-buffer-after-create-hook 'evil-motion-state)
(add-hook 'ecb-methods-buffer-after-create-hook 'evil-motion-state)
(add-hook 'ecb-sources-buffer-after-create-hook 'evil-motion-state)
Hope this helps,
Frank
More information about the implementations-list
mailing list