2

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?

Thanks.

1 Answer 1

0

You can check whether a hook has been called by adding something like (message "Test") to it. This will show that it has indeed been called. One issue here is that (when 'input-switch-is-on ...) will always evaluate to true because you're checking whether a symbol is not nil, rather than whether the variable has a non-nil value. You'll have to do more systematic debugging because if I replace the shell-command call with message, it displays "swim use com.apple.inputmethod.SCIM".

1
  • I have tried to check with a message but I never see any message, nor anything in message buffer. Commented Nov 20, 2017 at 14:13

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.