在 WSL 中使用 emacs-rime
在 WSL 中使用 Emacs 时,无法直接使用 Windows 安装的 RIME 输入法,当前比较好的方案是在 WSL 中安装 librime ,在 Emacs 中使用 emacs-rime 作为前端,使用体验比较贴近原生 RIME 输入法。
首先在WSL中安装librime: apt install librime-dev rime-data-double-pinyin 。
然后在Emacs中安装和配置emacs-rime:
(use-package rime
:ensure t
:custom
(default-input-method "rime")
(rime-user-data-dir "~/.emacs.d/.local/rime")
(rime-emacs-module-header-root "/usr/local/emacs/include")
(rime-show-candidate 'posframe)
(rime-posframe-properties (list :font "LXGW WenKai-13.5"
:border-width 1
:left-fringe 5
:right-fringe 5))
(rime-cursor "\u2038")
:config
(defun +rime-custom-faces (&rest _)
(modus-themes-with-colors
(custom-set-faces
`(rime-default-face ((,c :background ,bg-dim :foreground ,fg-main)))
`(rime-code-face ((,c :foreground ,blue-warmer)))
`(rime-highlight-candidate-face ((,c :foreground ,blue-cooler)))
`(rime-comment-face ((,c :foreground ,comment)))
`(rime-preedit-face ((,c :foreground ,fg-main :underline (:style dots)))))))
(add-hook 'modus-themes-after-load-theme-hook #'+rime-custom-faces)
(+rime-custom-faces)
(keymap-set rime-mode-map "C-`" #'rime-send-keybinding)
(defun +rime-finalize ()
(when rime--lib-loaded
(rime-lib-finalize)))
(add-hook 'kill-emacs-hook #'+rime-finalize))
自定义配置文件 default.custom.yaml 还有其他输入方案的配置文件,存放在 rime-user-data-dir 目录下。
执行 toggle-input-method 来激活使用rime输入法,默认快捷键为 C-\ 。