Setup VcXsrv as X11 Environment

Follow emacs-wsl’s README to install VcXsrv as X11 Environment.

Environment Variables Configure

export DISPLAY=:0.0
# for hidpi
export GDK_DPI_SCALING=2

After the installation, run start "" "C:\Program Files\VcXsrv\vcxsrv.exe" :0 -multiwindow -clipboard -wgl in Command Prompt (Not powershell) to start VcXsrv.

Compile & Install Emacs 28

According to the install instructions of emacs-rime, Emacs’s version needs higher than 26.1 to support dynamic modules. However, OpenSUSE 15.3 only has Emacs 25.3, and we can’t use snap in WSL 1, so we need to compile one from the source code.

Compile Emacs (Install locally)

# Download emacs 28.0.90
$ wget https://git.savannah.gnu.org/cgit/emacs.git/snapshot/emacs-28.0.90.tar.gz
# Install
$ sudo zypper source-install --build-deps-only emacs
$ tar xf emacs-28.0.90.tar.gz && cd emacs-emacs-28.0.90
$ mkdir -p ~/usr/emacs28
$ ./configure --with-x-toolkit=gtk --with-cairo --prefix=$HOME/usr/emacs28
$ make -j<cpu_nums>
$ make install

Fonts

.emacs:

;; set font for emoji
(setq use-default-font-for-symbols nil)
(set-fontset-font t 'symbol "Noto Color Emoji")
;; set font for Chinese & Japanese
(set-fontset-font t 'han "Noto Sans SC")
(set-fontset-font t 'kana "Noto Sans JP")

According to this post on reddit, due to a bug on OpenSUSE, maybe we need

/usr/share/X11/app-defaults/Emacs manually: prefixing the line Emacs.FontBackend: xft,x with !!

to avoid the issue.

Compile & Install emacs-rime

Compile & Install librime for emacs-rime

# install compile dependencies
$ zypper install cmake emacs-el gnutls libgnutls-devel libboost_* glog-devel leveldb-devel libmarisa libcapnp-devel libopencc2 gtest
$ cd ~/.emacs.d && git clone --recursive https://github.com/rime/librime.git
$ cd librime && make

❗️️: To avoid pthread error cover the real error while compiling in multi-threads, it’s better to compile in single core at first time. Or it may cost more time to find the real error.

make install to install globaly or set up rime-librime-root in .emacs :

(use-package rime
  :custom
  (rime-librime-root "~/.emacs.d/librime/build"))

Install emacs-rime

Follow the instruction in emacs-rime’s doc.

Set up Default Schema

Using default configure from rime-prelude:

$ git clone https://github.com/rime/rime-prelude.git
$ cd rime-prelue/*.yaml ~/.emacs.d/rime

At this time, if the configure is correct, M-x rime should trigger the input method.

Configure Candidate Menu (optional)

And we need to install posframe if we want to add a candidate menu that follows the cursor (just like the showcase):

.emacs:

(require 'posframe)
(setq default-input-method "rime"
      rime-show-candidate 'posframe)

Configure Menu Keybinding

.emacs:

(use-package rime
  :bind
  (:map rime-mode-map
   ("C-`" . 'rime-send-keybinding)))

Reference

If configured successfully, press C-` will show configure menu.

Install cloverpinyin (optional)

cloverpinyin provides a better input scheme and has a better corpus. Using this scheme give me a better experience like other commercial input methods.

Download the release and decompress into the rime’s schema folder:

$ cd ~/.emacs.d/rime/ && wget https://github.com/fkxxyz/rime-cloverpinyin/releases/download/1.1.4/clover.schema-1.1.4.zip
$ unzip clover.schema-1.1.4.zip

Final .emacs Configure

(require 'posframe)
(require 'rime)
(rime-compile-module)
(setq default-input-method "rime"
      rime-show-candidate 'posframe)
(setq rime-posframe-properties
 (list :font "Noto Sans SC Regular"
       :internal-border-width 10))
(setq rime-share-data-dir "/home/flandre/.emacs.d/rime")
(use-package rime
  :custom
  (default-input-method "rime")
  :bind
  (:map rime-mode-map
   ("C-`" . 'rime-send-keybinding)))

I added all relevant configure here.

NOTICE: If you use custom compiled librime you may don’t need (require 'rime), otherwise emacs won’t load your custom compiled librime.so.

Showcase

emacs-rime

Notes

  • I tried to use stow for multiple Emacs versions, but it’s not a good practice to maintain multiple package versions. And I didn’t find other tools like Checkinstall or update-alternatives on OpenSUSE, so I just installed locally and set $PATH.

Refrences