(defvar input-method-cursor-color "Orange"
"Default cursor color if using an input method.")
(defvar default-cursor-color (frame-parameter nil 'cursor-color)
"Default text cursor color.")
(defun change-cursor-color-on-input-method ()
"Set cursor color depending on whether an input method is used or not."
(interactive)
(set-cursor-color (if current-input-method
input-method-cursor-color
default-cursor-color)))
(add-hook 'post-command-hook 'change-cursor-color-on-input-method)
很好用,感谢分享!我在 change-cursor-color-on-input-method 函数的 if 里增加了两条断言,可以遵从 emacs-rime 中的 rime-disable-predicates 来改变光标颜色:
(defun change-cursor-color-on-input-method ()
"Set cursor color depending on whether an input method is used or not."
(interactive)
(set-cursor-color (if (and (rime--should-enable-p)
(not (rime--should-inline-ascii-p))
current-input-method)
input-method-cursor-color
default-cursor-color)))