Hooks

Tempy tempy_one at web.de
Fri Dec 20 15:04:09 CET 2013


Hello,

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)

(add-hook 'org-mode-hook 'evil-neo-org-mode)

But the hook won't trigger. If i open some org file, TAB is still
bound to its old command. Only if i switch to the insert state, or
switch back to evil mode by pressing C-z twice, TAB calls the
'org-cycle command. First i thought this is some org mode problem,
but i have the same issue in other modes too. I did another test and
commented out the (evil-mode 1) command in my init file. Thus after
starting emacs and opening an org file, i called (evil-mode)
interactively and then TAB as defined by evil-define-key above
worked as expected.

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.

Greetings,
Chilli




More information about the implementations-list mailing list