evil-mode: How to automatically switch to insert mode after certain commands?
max6166
max6166 at hotmail.com
Fri Mar 20 20:28:38 CET 2015
Óscar Fuentes <ofv <at> wanadoo.es> writes:
> Another approach is to advice `call-interactively'. Again, untested
> code:
>
> (defvar maybe-enter-insert-mode-commands
> '(org-insert-heading)
> "List of commands that trigger insert mode.")
>
> (defun maybe-enter-insert-mode (command &rest args)
> (when (memq command maybe-enter-insert-mode-commands)
> (evil-insert-state nil)))
>
> (advice-add 'call-interactively :after 'maybe-enter-insert-mode)
>
> Be warned that this method is quite gross. If your Emacs starts behaving
> strangely, the code above can be the cause.
Thank you so much, Oscar. The above method is working great so far.
I was thinking of adapting your code for other purposes, but I am concerned
about your warning. What are the potential problems with this code?
Thanks again.
--
For other readers, I think the last line is missing a hash and should be:
(advice-add 'call-interactively :after #'maybe-enter-insert-mode)
More information about the implementations-list
mailing list