1

In emacs-26.1, I am enabling the Japanese input method as follows ...

(toggle-enable-multibyte-characters 1)
(set-language-environment "Japanese")
(set-input-method "japanese")
(setq coding-system-for-read 'utf-8-unix)
(setq coding-system-for-write 'utf-8-unix)

This works fine and gives me hiragana characters when I enter their romaji equivalents, but SPC is mapped to a selection dialog for kanji characters. I want SPC to be mapped simply as self-insert-command, and I'd like to remap the kanji selection dialog to a different key sequence.

I tried the following, but it had no effect ...

(define-key kkc-keymap " " 'self-insert-command)
(define-key kkc-keymap "\C-^" 'kkc-next)

SPC still got me into the kanji selection dialog, and C-^did nothing.

I'm not sure, but it seems like there is code somewhere in kkc.el which forces kkc-next to be mapped to SPC, no matter what.

Short of completely rewriting some of the code in emacs-26.1/lisp/international/kkc.el, is there any way to remap the kanji selection dialog to something other than SPC?

  • I'm not knowledgeable about this, but (1) are you sure you have the right keymap, and (2) have you tried (kbd "SPC") instead of " "? – Drew Sep 8 '19 at 1:02
  • Thank you very much. It turns out that (kbd "SPC") does not change the behavior. Concerning the question of the correct keymap: in looking at the code in kkc.el, it seems that kkc-keymap is the one to use, but I am not sure. I'm hoping someone who is more familiar with the Japanese input method can help. – HippoMan Sep 8 '19 at 14:11
  • PS: it seems like this automatic romaji-to-hiragana encoding is not done via the normal keymap and mode methodologies of emacs. My Japanese-enabled buffer remains in fundamental-mode. Also, in kkc.el, it seems like there is special logic to explicitly traverse the kkc-keymap in a non-standard manner when characters are being typed, even though the mode is still fundamental-mode. Anyway, I'm still digging into this and will report whatever I ultimately come up with. – HippoMan Sep 8 '19 at 14:28
1

I figured it out.

As defined in lisp/international/quail.el, (quail-conversion-keymap) returns the keymap which is used for input methods, including the Japanese input method. In this keymap, " " (and not (kbd "SPC") in this case) gets mapped to quail-japanese-kanji-kkc, which causes the input selection dialog to be invoked via kkc-region from within lisp/international/kkc.el.

So, doing the following to enter the Japanese input method accomplishes what I want ...

(toggle-enable-multibyte-characters 1)
(set-language-environment "Japanese")
(set-input-method "japanese")
(setq coding-system-for-read 'utf-8-unix)
(setq coding-system-for-write 'utf-8-unix)
;; Enter the kanji selection dialog via `\C-^`,
;; and change the spacebar to simply insert a space.
(let ((qckeymap (quail-conversion-keymap)))
  (define-key qckeymap "\C-^" 'quail-japanese-kanji-kkc)
  (define-key qckeymap " " 'self-insert-command))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.