evil-mode: How to automatically switch to insert mode after certain commands?

max6166 max6166 at hotmail.com
Thu Mar 19 18:26:28 CET 2015


Óscar Fuentes <ofv <at> wanadoo.es> writes:

> I would try adding a function to `post-command-hook' that enters
> instert-mode when `insert-command' is in a list of symbols.
> 
> Totally untested code:
> 
> (defvar maybe-enter-insert-mode-commands
>   '(org-insert-heading)
>   "List of commands that trigger insert mode.")
> 
> (defun maybe-enter-insert-mode ()
>   (when (memq last-command maybe-enter-insert-mode-commands)
>      (evil-insert-state nil)))
> 
> (add-hook post-command-hook 'maybe-enter-insert-mode)
> 

Thank you very much, Oscar. The above code gives the error:

add-hook: Wrong type argument: symbolp, (evil-visual-post-command
linum-update-current t) [2 times]

Unfortunately, I am new to elisp & emacs so I have no idea how to figure out
the problem.


More information about the implementations-list mailing list