Update: It worked properly somehow after disabling and enabling nyan-mode. BUT there is no evidence indicating any relationship between them. Because I can't reproduce this problem after it was magically fixed.
My suspicion is that if the -- INSERT -- can show properly then the hook can be called properly. And if not it can't. Because I don't remember seeing -- INSERT -- when the problem exists. But again there is no evidence. Just for someone who might encounter this problem some day.
I have following code in my init.el (actually .spacemacs but you know what I mean). I try to invoke function input-switch-use-method1 when I enter insert mode in evil
;; switch input method when toggling insert mode (setq input-switch-method0 "com.apple.keyboardlayout.all") (setq input-switch-method1 "com.apple.inputmethod.SCIM") (defun input-switch-use-method (method) (when 'input-switch-is-on (shell-command (replace-regexp-in-string "method" method "swim use method")))) (defun input-switch-activate () (interactive) (setq input-switch-is-on t)) (defun input-switch-use-method1 () (interactive) (input-switch-use-method input-switch-method1)) (add-hook 'markdown-mode-hook 'input-switch-activate) (add-hook 'evil-insert-state-entry-hook 'input-switch-use-method1)
When I call
input-switch-use-method1 directly from M-x it works, but entering insert mode by pressing
i does not do anything.
I found no information indicating this hook being defective. Does anyone know why and how can I fix this?