Using rime input method in Emacs

Posted by Merve on Thu, 16 Jan 2020 12:41:19 +0100

When using external input method in email, the biggest problem is that when switching the email mode, there will be a delay for input, because you need to manually switch the input method to the corresponding English mode to use the shortcut keys normally.

But if you use Emacs' own input function, you don't need to do these synchronizations. You just need to exit from the insert mode. This operation is really too convenient for Emacs.

After several attempts, some problems occurred in the configuration process have been tested, and now they are sorted out as follows.

Compile librime

Because I use the Mac system, I need to install some tools first.

brew install cmake git boost

These three tools are used to compile liberime. Originally, I wanted to download them from GitHub, but there was a problem. So I decided to compile one by myself. I tested it here. It's not good to only use CommandLineTools. You need to install xcode safely.

  1. Download librime version Library
git clone --recursive https://github.com/rime/librime.git
  1. Compiling third-party libraries
cd librime
make xcode/thirdparty
  1. Compile librime
make xcode

Compile liberime

Compiling this depends on the librime file. You need to import the dependency first.

  1. Download the liberime project
git clone git@github.com:merrickluo/liberime.git
  1. Introduce librime dependency
export RIME_PATH=~/DEV/librime
  1. Compiling liberime files
make liberime
  1. Then add liberime to the. emacs.d project

If you don't want to compile by yourself, you can download the compiled file directly, but you need to store the file in a specified path.

Download path: liberime.so

Add Emacs configuration

Before adding configuration, check whether Emacs supports module load. If not, please install the supported version first. It is recommended to use emacs-mac Version in.

(use-package pyim
  :demand t
  :diminish pyim-isearch-mode
  :init
  (setq default-input-method "pyim"
        pyim-title "ㄓ"
        pyim-default-scheme 'rime
        pyim-page-length 7
        pyim-page-tooltip 'proframe)
  :config
  (setq-default pyim-english-input-switch-functions
                '(pyim-probe-dynamic-english
                  pyim-probe-evil-normal-mode
                  pyim-probe-program-mode
                  pyim-probe-org-structure-template))

  (setq-default pyim-punctuation-half-width-functions
                '(pyim-probe-punctuation-line-beginning
                  pyim-probe-punctuation-after-punctuation))
  (pyim-isearch-mode t)
  :bind ("M-j" . pyim-convert-string-at-point))

(use-package liberime
  :load-path (lambda () (expand-file-name "rime" user-emacs-directory))
  :custom
  (rime_share_data_dir "/Library/Input Methods/Squirrel.app/Contents/SharedSupport/")
  (rime_user_data_dir (expand-file-name "rime" user-emacs-directory))
  :init
  (module-load (expand-file-name "liberime.so" user-emacs-directory))
  :config
  ;; Configure sync folder
  (liberime-start rime_share_data_dir rime_user_data_dir)
  (liberime-select-schema "wubi86"))

(use-package posframe)

(provide 'modules-pyim)

Restart Emacs to use pyim instead of the original input method.

The article starts at: https://www.zucchiniy.cn

Topics: Programming git github xcode Mac