Skip to content

Commit 2437a95

Browse files
authored
Fix #277: use input method only in insert state (#432)
Fix is based on code from modalka, as mentioned in the issue discussion.
1 parent d80c2ff commit 2437a95

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

meow-shims.el

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,21 @@ Argument ENABLE non-nil means turn on."
249249
(add-hook 'which-key-mode-hook 'meow--which-key-describe-keymap)
250250
(remove-hook 'which-key-mode-hook 'meow--which-key-describe-keymap)))
251251

252+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
253+
;; input methods
254+
255+
(defvar meow--input-method-setup nil)
256+
257+
(defun meow--input-method-advice (fnc key)
258+
"Intended to be advice for quail-input-method. Only use the input method in insert mode."
259+
(funcall (if (and (boundp 'meow-mode) meow-mode (not (meow-insert-mode-p))) #'list fnc) key))
260+
261+
(defun meow--setup-input-method (enable)
262+
(setq meow--input-method-setup enable)
263+
(if enable
264+
(advice-add 'quail-input-method :around 'meow--input-method-advice)
265+
(advice-remove 'quail-input-method 'meow--input-method-advice)))
266+
252267
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
253268
;; polymode
254269

@@ -292,7 +307,8 @@ Argument ENABLE non-nil means turn on."
292307
(eval-after-load "cider" (lambda () (meow--setup-cider t)))
293308
(eval-after-load "which-key" (lambda () (meow--setup-which-key t)))
294309
(eval-after-load "undo-tree" (lambda () (meow--setup-undo-tree t)))
295-
(eval-after-load "diff-hl" (lambda () (meow--setup-diff-hl t))))
310+
(eval-after-load "diff-hl" (lambda () (meow--setup-diff-hl t)))
311+
(eval-after-load "quail" (lambda () (meow--setup-input-method t))))
296312

297313
(defun meow--disable-shims ()
298314
"Remove shim setups."
@@ -306,7 +322,8 @@ Argument ENABLE non-nil means turn on."
306322
(when meow--polymode-setup (meow--setup-polymode nil))
307323
(when meow--cider-setup (meow--setup-cider nil))
308324
(when meow--which-key-setup (meow--setup-which-key nil))
309-
(when meow--diff-hl-setup (meow--setup-diff-hl nil)))
325+
(when meow--diff-hl-setup (meow--setup-diff-hl nil))
326+
(when meow--input-method-setup (meow--setup-input-method nil)))
310327

311328
;;; meow-shims.el ends here
312329
(provide 'meow-shims)

0 commit comments

Comments
 (0)