A emacs dynamic module provide librime bindings for emacs
目前只实现了几个方法,理想情况是暴露所有 librime 的 API 到 emacs-lisp.
- emacs 需要启用支持动态模块,在编译的时候使用 –with-modules 选项。
- librime 版本 > 1.3.2
make liberime
ls build/
# try
make test- Build librime following this instruction, you will need xcode (good luck).
- Setup environment variable RIME_PATH to librime project dir, for example:
export RIME_PATH=~/Develop/others/librime
- Build just like on Linux
make liberime ls build/ # try make test
需要配合 pyim 使用。
shared_data_dir: librime 安装后提供的共享数据,里面会有预置的 schema 等 各平台所在位置详情。
user_data_dir: 推荐放在 “~/.emacs.d/rime”,
通过 use-package + quelpa 加载 注意 add-hook 一定要放在:init block 里面
使用 GitHub Repo
(use-package liberime-config
:quelpa (liberime-config
:fetcher github
:repo "merrickluo/liberime"
:files ("CMakeLists.txt" "Makefile" "src" "liberime-config.el"))
:init
(add-hook 'liberime-after-start-hook
(lambda ()
(liberime-select-schema "luna_pinyin_simp"))))使用本地文件
(use-package liberime-config
:quelpa (liberime-config
:fetcher file
:path "~/Develop/emacs/liberime"
:files ("CMakeLists.txt" "Makefile" "src" "liberime-config.el"))
:init
(add-hook 'after-liberime-load-hook
(lambda ()
(liberime-select-schema "luna_pinyin_simp"))))注意,使用 hook 修改输入方案会有一些问题,由于 liberime 在执行 sync 等操作之后会 重新部署,由于目前的技术限制,重新部署的通知在 elisp 环境无法收到,所以无法重新执 行这些 hooks,如果需要设置指定的输入方案,建议直接在
/.emacs.d/rime/default.custom.yaml配置。see example
#+NAME setup pyim
(use-package pyim
:after liberime-config
:config
(setq default-input-method "pyim")
(setq pyim-default-scheme 'rime))在手动修改了 librime 的配置后,可以手动调用 (liberime-deploy) 进行重新部署。
使用 liberime 会导致一个问题,就是在 Emacs 中输入中文时,词库跟系统输入法不一致, 无论是你在使用 fcitx-rime, ibus-rime, 或者是 squirrel。不过 librime 提供了方法让 我们保持词库同步。参考:Rime 同步用户资料。
默认情况下 liberime 的 installation.yaml 在
$HOME/.emacs.d/rime/installation.yaml,用户只需要在里面添加 sync_dir ,就可以使用
liberime-config 提供的 (liberime-sync) 方法进行同步了。还可以将其加入到
emacs 的 after-init-hook 中自动进行同步。
(add-hook 'after-init-hook #'liberime-sync)initialize deploy and started a session with librime returns t if success report error otherwise
returns list of pairs(list of (schema_id, schema_name) ) avaliable schema
Example output(prebuilt schemas)
(liberime-get-schema-list)
;; (("luna_pinyin" "朙月拼音") ("luna_pinyin_simp" "朙月拼音·简化字") ("luna_pinyin_fluency" "朙月拼音·語句流") ("bopomofo" "注音") ("bopomofo_tw" "注音·臺灣正體") ("cangjie5" "倉頡五代") ("stroke" "五筆畫") ("terra_pinyin" "地球拼音"))should use schema_id returns from libeliberime-get-schema-list returns t if success, report error otherwise
Example output:
(liberime-select-schema "luna_pinyin_simp")
;; t