我才发现,原来之前有人在 Github 提过这个问题:
PS:其实我之前也攒了一些小改进,在本坛存个档,或许有遇到类似问题的坛友:
1、避免在 minibuffer 中激活 inline
(define-advice sis--inline-check-to-activate
(:around (orig) no-minibuffer)
(unless (minibufferp)
(funcall orig)))
否则,至少在我使用 vertico 时,如果激活了 inline,那么增加的 inline overlay 会使得候选项为空。
2、支持 universal-argument 的自动切换英文输入法(就如同这些键被绑定了 sis--prefix-override-handler
)
(define-advice universal-argument
(:around (orig) sis)
(funcall orig)
(when sis-global-respect-mode
(setq sis--prefix-handle-stage 'prefix)
(sis--respect-pre-command-handler)))
(define-advice universal-argument-more
(:around (orig &rest arg) sis)
(apply orig arg)
(when sis-global-respect-mode
(setq sis--prefix-handle-stage 'prefix)
(sis--respect-pre-command-handler)))
(define-advice negative-argument
(:around (orig &rest arg) sis)
(apply orig arg)
(when sis-global-respect-mode
(setq sis--prefix-handle-stage 'prefix)
(sis--respect-pre-command-handler)))
(define-advice `digit-argument`
(:around (orig &rest arg) sis)
(apply orig arg)
(when sis-global-respect-mode
(setq sis--prefix-handle-stage 'prefix)
(sis--respect-pre-command-handler)))
为什么不将这些键加入 sis-prefix-override-keys
呢?因为这些键太多了,比如在 Doom Emacs 下,evil normal state 直接敲击键盘上的数字键,就都是 digit-argument
命令。
3、如果你想手动进入 inline 模式(不想「输入空格」供其检测符合断言才进入、之后再手动删去)
(defun sis-inline-mode-force ()
(interactive)
(when (eq sis--for-buffer 'other)
(setq sis--prefix-handle-stage 'normal)
(add-transient-hook! 'post-self-insert-hook
(when (eq last-command 'sis-inline-mode-force)
(sis--inline-activate 'english (1- (point)))))))
这里的 add-transient-hook!
是 Doom Emacs 中的函数,是为了增加一个只运行一次的 hook/advice。如果不是 Doom 想用的话,得去抄一下这个宏的定义。
4、Doom Emacs 下,不同 evil state 光标颜色不同,让 sis 考虑这一点:
(defun my/sis--set-cursor-color-advice (color)
(pcase sis--current
('english
(cond ((or evil-insert-state-minor-mode evil-normal-state-minor-mode) (list (get 'cursor 'evil-normal-color)))
(evil-emacs-state-minor-mode (list (get 'cursor 'evil-emacs-color)))
(t (list sis-default-cursor-color))))
('other
(list sis-other-cursor-color))
(_
color)))
(advice-add 'sis--set-cursor-color-advice :override #'my/sis--set-cursor-color-advice)
5、利用 idle 实时切换输入法状态(比如,在 evil insert/emacs state 下,在英文内容和中文内容之间移动光标,就可以自动切换输入法)
(defvar my/idle-command-for-sis-timer nil)
(defun my/idle-command-for-sis ()
(when (and (or evil-insert-state-minor-mode evil-emacs-state-minor-mode)
(not (and (boundp 'evil-mc-mode) evil-mc-mode))
(not (overlayp sis--inline-overlay))
(not (eq sis--prefix-handle-stage 'sequence))
(not (memq real-last-command '(sis-inline-mode-force sis--inline-ret-check-to-deactivate)))
(not (equal last-input-event '(ns-put-working-text))))
(sis-context)))
(setq my/idle-command-for-sis-timer
(run-with-idle-timer 0.2 t #'my/idle-command-for-sis))
;; (when my/idle-command-for-sis-timer
;; (cancel-timer my/idle-command-for-sis-timer))