I’m currently living in Japan and learning Japanese in University. In order to make learning easier I’m using the Anki app. However, Ubuntu and emacs don’t come with easy Japanese functionality out of the box and in this post I will document the efforts I took to make this happen.

Table of Contents

Ubuntu setup

For ubuntu, the preferred Japanese input method is a Japanese keyboard called mozc. Use the link in the resources below for this purpose.

Then, setup the following ENV variables in your .bashrc:

export QT_IM_MODULE=fcitx
export GTK_IM_MODULE=fcitx

You can go the text entry setting and set the keyboard change button to ‘pause’, which I did.

Debian setup

You can’t install mozc on Debian GUI so you should first install the ibus-mozc package and then use the ibus GUI for selecting mozc.

Emacs setup

You can then proceed to setup your emacs with the mozc keyboard. For this purpose, you should first copy-paste the file mozc.el from the mozc sources into your .emacs.d/ folder and then paste the following into your init.el (after loading the mozc.el file).

(require 'mozc)
(setq default-input-method "japanese-mozc")
(setq mozc-candidate-style 'overlay)

Once this is done, install the emacs-mozc-bin package from the ubuntu sources so that emacs can communicate with the mozc server.

You should now be able to change between Japanese and English keyboards using the C-\ command inside emacs. This does not change your system input.

Resources