Emacs with Japanese Apple Keyboards

by Carson Reynolds

Previously, I found a quick hack to cause the ¥ key on Apple Macbooks to emit a backslash in Emacs, which is handy for programming.

It turns out that works only with Macbooks and not other Apple system / keyboard combos. After some more research, I found another workaround to get backslashes out of Emacs in general and Aquamacs in particular. On the off-chance that you’re not a Japanese reader, add the following line to your .emacs file:

(setq ns-alternate-modifier 'option)

This will cause the option key with yen key (⌥+¥) to send a backslash. This work-around more closely imitates OS X behavior with Japanese keyboards.

Update:

The previous solution overrides the use of option for the meta-key. After asking for some help on stackoverflow, I found this as a better workaround:

(global-set-key (quote [134217893]) "\\")

This causes ⌥+¥ to output \ as expected without overriding the meta-key.

Advertisements