Skip to content
 
 

Repository files navigation

liberime [开发中]

Introduce

A emacs dynamic module provide librime bindings for emacs

目前只实现了几个方法,理想情况是暴露所有 librime 的 API 到 emacs-lisp.

Require

  1. emacs 需要启用支持动态模块,在编译的时候使用 –with-modules 选项。
  2. librime 版本 > 1.3.2

Build

Build On Linux:

make liberime
ls build/

# try
make test

Build On Darwin

  1. Build librime following this instruction, you will need xcode (good luck).
  2. Setup environment variable RIME_PATH to librime project dir, for example:
    export RIME_PATH=~/Develop/others/librime
        
  3. Build just like on Linux
    make liberime
    ls build/
    
    # try
    make test
        

Usage

Initialize

需要配合 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))

Deploy

在手动修改了 librime 的配置后,可以手动调用 (liberime-deploy) 进行重新部署。

Sync

使用 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)

Available methods

(liberime-start shared_data_dir user_data_dir)

initialize deploy and started a session with librime returns t if success report error otherwise

(liberime-get-schema-list)

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" "地球拼音"))

(liberime-select-schema schema_id)

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

About

A emacs dynamic module provide librime bindings for emacs

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages