aboutsummaryrefslogtreecommitdiff
path: root/.emacs.d/lisp/init-input-method.el
blob: e027c44570a1e745c28b70bd102fb0cbb176d06d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
(when *is-a-linux*
  (setq fcitx-remote-command "fcitx5-remote")
  (when (gx/maybe-require-package 'fcitx)
    (add-hook 'after-init-hook 'fcitx-aggressive-setup 'append)))

(when *is-a-mac*
  (setq sis-external-ism "/usr/local/bin/macism")
  (setq sis-english-source "com.apple.keylayout.ABC"
  	sis-other-source "com.apple.inputmethod.SCIM.ITABC")
  (setq sis-do-get
	(lambda ()
	  (string-trim (shell-command-to-string sis-external-ism))))
  (setq sis-do-set
	(lambda (source)
	  (start-process "set-input-source" nil
			 sis-external-ism source)))

  (setq gx/input-method--insert-state-source sis-english-source)
  (when (gx/maybe-require-package 'sis)
    (autoload 'sis-get "sis" nil t)
    (autoload 'sis-set-english "sis" nil t)
    (autoload 'sis-set-other "sis" nil t)
    (add-hook 'evil-insert-state-exit-hook
	      (lambda ()
		(setq gx/input-method--insert-state-source (sis-get))
		(sis-set-english)))
    (add-hook 'evil-insert-state-entry-hook
	      (lambda ()
		(unless (minibufferp)
		  (when (string= gx/input-method--insert-state-source
				 sis-other-source)
		    (sis-set-other)))))))

(provide 'init-input-method)