Hooks not working

Frank Fischer frank-fischer at shadow-soft.de
Sun Dec 22 19:55:43 CET 2013


On 20.12.2013 14:56, BoSa wrote:
> I do have a problem with keybindings defined with evil-define-key
> and hooks. According to the documentation, i should use the following
> lisp code to enable special bindings for certain modes.
> 
> (define-minor-mode evil-neo-org-mode
>   "Neo+Evil+Org mode"
>   :init-value nil
>   :lighter " NeoEvilOrg"
>   :keymap (make-sparse-keymap))
> 
> (evil-define-key 'normal evil-neo-org-mode-map (kbd "TAB") 'org-cycle)

I would not create a new minor mode. It's probably easier to put the
keybindings in the appropriate local maps, i.e.

(add-hook 'org-mode-hook (lambda ()
  (define-key evil-normal-state-local-map (kbd "TAB") 'org-cycle))

or something like this. The local keymaps are buffer local so the usual
Emacs rules apply.

> At the end it seems evil doesn't observe the bindings defined by
> evil-defined-key immediately after startup. Only if i reenter some
> state they take effect. I have no clue what i'm doing wrong.

This is a know problem. I just have no idea how to detect that a certain
minor mode is being enabled (afaik there is not an
`activate-minor-mode-hook` or something like this in Emacs).

Frank




More information about the implementations-list mailing list