Getting Kanji Working in Emacs: Mule-UCS Startup Hook

I finally solved a problem I was having with Japanese input into emacs, and thought I'd report it for the benefit of others that might be searching for a solution.

A month or so ago, emacs stopped accepting kanji in Japanese input, and stopped displaying kanji in files. Hiragana and katakana continued to input/display fine, but kanji no longer worked at all.

I spent a month testing all kinds of things (including some printf-debugging of the emacs source code!), but to make a long story short, it seems that all I needed to do was to add

   (require 'un-define)

to my .emacs file.

I'm not sure whether I previously had that line in my .emacs file and somehow accidentally deleted it, or whether an update to Debian's mule-ucs package (which is required for kanji to work in emacs) stopped doing that require for me. In either case, I've been bummed for the last month or two, and am now happy. やっと出来ました。

The top of my .emacs file now looks like this:

   (require 'un-define)
   (prefer-coding-system       'utf-8)
   (set-default-coding-systems 'utf-8)
   (set-terminal-coding-system 'utf-8)
   (set-keyboard-coding-system 'utf-8)

All 4 comments so far, oldest first...

Thanks very much for funding that. I do not know if that change in emacs was triggered as a result of the release of etch being just about ready to be released or not, but this. Is a good caveat to watch for next time I dwell in Japanese input. Thanks!

— comment by William on April 18th, 2007 at 2:58am JST (10 years, 1 month ago) comment permalink

Hi Jeffrey,

Next time, try googling for an answer in Japanese.

Keywords used this time: emacs utf-8 漢字入力

Result and jackpot:

Tadaa! Two months of grief reduced to twenty-seconds, just like that.

Oh, I did searches similar to that, and it’s such a search that lead to the solution. Most of the two months was trying to figure out where the problem was…. I didn’t know whether it was a problem with my Mac or its Terminal app, my shell settings, the Debian Linux box I was connected to, its emacs install, or my ‘screen’ install or settings. I was futzing with installing new versions of emacs, old versions of emacs, reading the man page for ‘stty’ a dozen times. As far as I could tell, emacs wasn’t getting the input (I wondered whether it put the tty into some weird kind of state I’d never heard of), so to test this, I built a version of emacs that displayed the raw bytes of keyboard input as they came in, and indeed, emacs was getting the input. From that point, it took 15 minutes of digging around to solve the problem, and another 15 minutes to write the post. —Jeffrey

— comment by Andy on April 18th, 2007 at 8:33am JST (10 years, 1 month ago) comment permalink

Hello again,

Gotcha! I’m not into programming at all, though I do know about text editors like vi, vim, and emacs from openSUSE installed on my thinkpad. Most of my digging around is done in dictionaries.

Cheers …

— comment by Andy on April 18th, 2007 at 9:28am JST (10 years, 1 month ago) comment permalink

Very nice. I’d never had a problem with this in Fedora, but I recently decided to give the new Ubuntu feisty fawn distro a swing and was having a helluva time with emacs and funny characters. I got other Japanese specific encodings working fine, euc-jp and shift-jis, but finding out why Japanese utf8 wasn’t displaying properly was becoming a huge pain. I’ve been able to input things properly, but I couldn’t get them to display!

>>”Next time, try googling for an answer in Japanese.
Keywords used this time: emacs utf-8 漢字入力”

Instead, I think “emacs utf-8 漢字 表示” makes more sense, since my problem at least was displaying, not inputting Japanese utf-8. The article is also about display, not input…

Anyway that’s my 2cents. Thanks again!

— comment by Joe on May 3rd, 2007 at 12:29pm JST (10 years ago) comment permalink
Leave a comment...

All comments are invisible to others until Jeffrey approves them.

Please mention what part of the world you're writing from, if you don't mind. It's always interesting to see where people are visiting from.

You can use basic HTML; be sure to close tags properly.

Subscribe without commenting