aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuangxiong Lin <[email protected]>2022-03-13 23:48:07 +0800
committerGuangxiong Lin <[email protected]>2022-03-13 23:48:07 +0800
commit73534041ca3320fd2cb5da2f3635d7a5acee672a (patch)
treefbd57b7e71d5db893e3a450b9aebdf9f712b87a2
parentcb5409866f2127dc6a3138a433ac918b51721ab5 (diff)
downloaddotfiles-73534041ca3320fd2cb5da2f3635d7a5acee672a.tar.gz
dotfiles-73534041ca3320fd2cb5da2f3635d7a5acee672a.tar.bz2
dotfiles-73534041ca3320fd2cb5da2f3635d7a5acee672a.zip
Implement simple sis (emacs)
-rw-r--r--.emacs.d/lisp/init-input-method.el24
1 files changed, 18 insertions, 6 deletions
diff --git a/.emacs.d/lisp/init-input-method.el b/.emacs.d/lisp/init-input-method.el
index 5c0c61b..11fcb78 100644
--- a/.emacs.d/lisp/init-input-method.el
+++ b/.emacs.d/lisp/init-input-method.el
@@ -7,13 +7,25 @@
(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)
- (add-hook 'after-init-hook
+ (add-hook 'evil-insert-state-exit-hook
(lambda ()
- (sis-global-respect-mode t)
- (sis-global-context-mode t))))
-
- (with-eval-after-load 'sis
- (add-hook 'evil-insert-state-exit-hook 'sis-set-english)))
+ (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)