比如输入完汉字之后按空格后,再输入英文,感觉反应很慢,输入的快了会丢字母,不知道什么问题?
要定位问题的话需要一些更详细的信息,还有就是独立使用 emacs-rime 的时候会不会也卡。
原理上 inline ascii 模式也是由 librime 驱动的,应该和系统输入法的 Rime 里面按右 Shift 之后的效果是一样的。
Emacs是mac port 27.1,配置用的是spacemacs develop版, emacs-rime 版本是20201115. 单独使用emacs-rime不卡,但激活临时英文状态(比如按空格)以及激活后很很卡,输入英文稍快一点都会丢字母。
emacs-rime 相关配置为:
(setq rime-librime-root "~/.emacs.d/private/librime/dist")
(setq rime-emacs-module-header-root "/Applications/Emacs.app/Contents/Resources/include")
(setq rime-user-data-dir "~/Library/Rime-emacs")
(setq rime-posframe-properties
(list :background-color "#333333"
:foreground-color "#dcdccc"
:font "WenQuanYi Micro Hei Mono-14"
:internal-border-width 10))
(setq default-input-method "rime"
rime-show-candidate 'posframe)
(setq rime-translate-keybindings
'("C-f" "C-b" "C-n" "C-p" "C-g"))
(setq rime-disable-predicates
'(rime-predicate-evil-mode-p
rime-predicate-after-alphabet-char-p
rime-predicate-space-after-cc-p
rime-predicate-punctuation-after-space-cc-p
rime-predicate-prog-in-code-p
rime-predicate-after-ascii-char-p
rime-predicate-current-uppercase-letter-p
))
(setq mode-line-mule-info '((:eval (rime-lighter))))
(setq rime-inline-ascii-trigger 'shift-l)
(defun rime-evil-escape-advice (orig-fun key)
"advice for `rime-input-method' to make it work together with `evil-escape'.
Mainly modified from `evil-escape-pre-command-hook'"
(if rime--preedit-overlay
;; if `rime--preedit-overlay' is non-nil, then we are editing something, do not abort
(apply orig-fun (list key))
(when (featurep 'evil-escape)
(let* (
(fkey (elt evil-escape-key-sequence 0))
(skey (elt evil-escape-key-sequence 1))
(evt (read-event nil nil evil-escape-delay))
)
(cond
((and (characterp evt)
(or (and (char-equal key fkey) (char-equal evt skey))
(and evil-escape-unordered-key-sequence
(char-equal key skey) (char-equal evt fkey))))
(evil-repeat-stop)
(evil-normal-state))
((null evt) (apply orig-fun (list key)))
(t
(apply orig-fun (list key))
(if (numberp evt)
(apply orig-fun (list evt))
(setq unread-command-events (append unread-command-events (list evt))))))))))
(advice-add 'rime-input-method :around #'rime-evil-escape-advice)
单独使用是指在 emacs -Q 类似的环境下么?
可以先尝试用 profiler 看下.
profiler-start 输入一会,再 profiler-report 看下输出。
我说的不太清楚,我是说如果不激活临时英文模式不卡。没有试过emacs -Q. 我试一下profiler。
- command-execute 729 62%
- call-interactively 729 62%
- funcall-interactively 729 62%
- counsel-M-x 716 61%
- ivy-read 675 58%
- apply 675 58%
- ivy-posframe--read 675 58%
- apply 675 58%
+ #<compiled 0x1feb4cd47451> 675 58%
+ counsel--M-x-externs 41 3%
+ org-self-insert-command 12 1%
+ evil-org-append-line 1 0%
+ flyspell-post-command-hook 232 20%
- rime-input-method 141 12%
- apply 141 12%
- rime-evil-escape-advice 141 12%
- if 141 12%
- if 110 9%
- progn 110 9%
- let* 110 9%
+ cond 25 2%
read-event 8 0%
+ apply 31 2%
+ timer-event-handler 31 2%
+ which-key--hide-popup 12 1%
+ redisplay_internal (C function) 10 0%
+ ... 1 0%
+ company-post-command 1 0%
+ my-yas-try-expanding-auto-snippets 1 0%
+ evil-repeat-post-hook 1 0%
这句配置导致的,我注释后就不卡了。 注释掉之后就没法用jk
切换到 normal state.