分类: LINUX
2008-01-30 20:32:04
Add these to your ~/.emacs:
; Make Japanese the default language (set-language-environment "Japanese") ; Add anthy.el to the load path (push "/usr/local/share/emacs/site-lisp/anthy/" load-path) ; Load anthy.el (load-library "anthy") ; Set japanese-anthy as the default input-method (setq default-input-method "japanese-anthy")
'C-' toggles anthy. When you toggle anthy mode on, the modeline will say "Anthy: a" (the "a" will actually be the Japanese Hiragana あ). This shows anthy is in hiragana -> kanji conversion mode.
In addition, Anthy also has katakana input mode, half-width alphanumeric input mode, and full-width alphanumeric input mode. Each mode lets you input the respective type of characters.
Once you type some text, a | (fence) will appear at point, and the characters you typed will be shown underlined. Those characters are preliminary, and won't be passed to emacs until you `commit' it with C-j, C-m, or Enter.
Conversion begins when you press C-n, C-p, or Space, and the first candidate will be shown. This applies only to the hiragana->kanji conversion mode, however.
Pressing C-j, C-m, or Enter, will cause whatever you have shown in the buffer to be commited, i.e. fed to Emacs as the input text.
C-g cancels and discards all preliminary input.
When you begin converting with C-n, C-p, or Space (hiragana -> kanji conversion mode only), the first conversion candidate for that input will be shown in square brackets ([]).
Anthy internally keeps a list of possible conversion results for your hiragana input. You can move around in the list using C-n or Space and C-p.
C-n or Space selects the next candidate in the list. The newly selected candidate will appear on the screen. C-p selects the previous candidate. The candidate list is circular, meaning pressing C-n at the last candidate brings you back to the first one.
If you keep pressing C-n or C-p several times, a part of the candidate list will show up in the minibuffer. Each candidate will be displayed with a key that is associated with that candidate. Pressing the associated key selects that candidate (without commiting it).
When you're done choosing, press C-j, C-m, or Enter.
C-h or Backspace aborts the selection process, and the preliminary input is converted back to the original hiragana that you typed.
C-g similarly aborts the selection process, but it causes your preliminary input to be discarded rather than converted back.
mode | key | mode after pressing the key |
hiragana -> kanji | q | katakana |
hiragana -> kanji | l | half-width alphanumeric |
hiragana -> kanji | L | full-width alphanumeric |
katakana | q | hiragana -> kanji |
katakana | l | half-width alphanumeric |
katakana | L | full-width alphanumeric |
half-widht alphanumeric | C-j | hiragana -> kanji |
full-width alphanumeric | C-j | hiragana -> kanji |
NB: half-width alphanumeric mode is essentially US-ASCII input mode. It's different from turning anthy off in that the ASCII text will be given to anthy first, and that you can embed the ASCII text in your preliminary input text to be subject to conversion.
/ will always temporarily shift anthy into half-width alphanumeric mode, up until the next /. Pressing / twice in a row will get you a literal slash.
C-h and Backspace deletes the character right before the cursor.
C-d and Delete removes the character right after the cursor.
These keybindings apply when you've typed some hiragana text, but haven't begun the conversion process.
C-b or <-(Left) moves the cursor backward within the preliminary input. C-f or ->(Right) moves the cursor forward.
C-a takes the cursor to the beginning of the preliminary input, while C-e places the cursor at the end of the preliminary input.
Anthy breaks up the input into segments called bunsetsu (文節), which are roughly pairs of a (possibly conjugated) word and a suffix. Refer to a Japanese grammar textbook for more information. Candidate selection is done on one segment at a time rather than the whole buffered input. Segments may have to be adjusted in order to get the desired conversion appears in the candidate list. This section summarizes how to maneuver segments.
The following descriptions apply during the candidate selection process.
C-f or Right moves the focus to the next segment.
C-b or Left moves the focus to the previous segment.
C-a moves the focus to the first segment.
C-e moves the focus to the last segment.
C-o or Shift-Right elongates the focused segment by one character. The character is snatched from the next segment.
C-i or Shift-Left shortens the focused segment by one character. The abandoned character is merged into the next segment.
; Specify key to toggle anthy (this example specifies the default C-\) (global-set-key "\C-\\" 'anthy-mode) ; Modify a character in the hiragana map (anthy-change-hiragana-map "," ",") ; Change the whole hiragana map (map "." "," to their full-width representations) (anthy-load-hiragana-map anthy-alt-char-map) ;; Make spacebar insert half-width space (0x20) in kana -> kanji input mode (full-width space is inserted by default) (setq anthy-wide-space " ")
Anthy refers to some hiragana -> kanji conversion dictionaries when it fabricates the list of candidates. The generic dictionaries may not have some esoteric vocabulary or jargons, which you would want to register to your private dictionary.
To add a new word to the private dictionary, do:
(Right now, this doesn't work properly for anything but nouns.) FIXME: has the situation improved?
Install and specify japanese-egg-anthy as the input method to use anthy with tamago's interface.
(set-input-method 'japanese-egg-anthy)
Be noted that tamago isn't active maintained. Even the latest 4.0.6 release is quite old. You'd want to fetch the latest version from CVS. Some packaging systems, like ports/pkgsrc of the BSDs, have the CVS version.
Emacs21 users must apply this fix: .
Anthy comes with anthy.el which seems to shadow the anthy.el in tamago. If you use tamago, be sure not to install the anthy.el included in Anthy.
egg-anthy has other serious problems. For example, it crashes (FIXME: the original Japanese is vague here. Does it literally crash?) after 16 convert/cancel operations. It doesn't support M-h, M-k, or addition of words to the private dictionary. There's that fixes these problems.
A uim bridge for Emacs. Emacs can simply use uim through its toolkit, but uim.el (should) provide better integration and more verstaile interface. uim.el is (was) hosted at .
uim.el is included in the standard uim distribution package beginning from uim-1.0.0.