1;;; japanese.el --- Quail package for inputting Japanese  -*-coding: iso-2022-7bit;-*-
2
3;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
4;;   Free Software Foundation, Inc.
5;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
6;;   2006, 2007
7;;   National Institute of Advanced Industrial Science and Technology (AIST)
8;;   Registration Number H14PRO021
9
10;; Keywords: multilingual, input method, Japanese
11
12;; This file is part of GNU Emacs.
13
14;; GNU Emacs is free software; you can redistribute it and/or modify
15;; it under the terms of the GNU General Public License as published by
16;; the Free Software Foundation; either version 2, or (at your option)
17;; any later version.
18
19;; GNU Emacs is distributed in the hope that it will be useful,
20;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22;; GNU General Public License for more details.
23
24;; You should have received a copy of the GNU General Public License
25;; along with GNU Emacs; see the file COPYING.  If not, write to the
26;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
27;; Boston, MA 02110-1301, USA.
28
29;;; Commentary:
30
31;;; Code:
32
33(require 'quail)
34(require 'kkc)
35
36(defvar quail-japanese-use-double-n nil
37  "If non-nil, use type \"nn\" to insert $B$s(B.")
38
39;; Update Quail translation region while considering Japanese bizarre
40;; translation rules.
41(defun quail-japanese-update-translation (control-flag)
42  (if (null control-flag)
43      (setq quail-current-str
44	    (if (/= (aref quail-current-key 0) ?q)
45		(or quail-current-str quail-current-key)
46	      ""))
47    (if (integerp control-flag)
48	(if (= control-flag 0)
49	    (setq quail-current-str (aref quail-current-key 0))
50	  (cond ((= (aref quail-current-key 0) ?n)
51		 (setq quail-current-str ?$B$s(B)
52		 (if (and quail-japanese-use-double-n
53			  (= (aref quail-current-key 1) ?n))
54		     (setq control-flag t)))
55		((= (aref quail-current-key 0) (aref quail-current-key 1))
56		 (setq quail-current-str ?$B$C(B))
57		(t
58		 (setq quail-current-str (aref quail-current-key 0))))
59	  (if (integerp control-flag)
60	      (setq unread-command-events
61		    (list (aref quail-current-key control-flag)))))))
62  control-flag)
63
64;; Convert Hiragana <-> Katakana in the current translation region.
65(defun quail-japanese-toggle-kana ()
66  (interactive)
67  (setq quail-translating nil)
68  (let ((start (overlay-start quail-conv-overlay))
69	(end (overlay-end quail-conv-overlay)))
70    (save-excursion
71      (goto-char start)
72      (if (re-search-forward "\\cH" end t)
73	  (japanese-katakana-region start end)
74	(japanese-hiragana-region start end)))
75    (setq quail-conversion-str
76	  (buffer-substring (overlay-start quail-conv-overlay)
77			    (overlay-end quail-conv-overlay)))))
78
79;; Convert Hiragana in the current translation region to Kanji by KKC
80;; (Kana Kanji Converter) utility.
81(defun quail-japanese-kanji-kkc ()
82  (interactive)
83  (when (= (char-before (overlay-end quail-conv-overlay)) ?n)
84    ;; The last char is `n'.  We had better convert it to `$B$s(B'
85    ;; before kana-kanji conversion.
86    (goto-char (1- (overlay-end quail-conv-overlay)))
87    (insert ?$B$s(B)
88    (delete-char 1))
89  (let* ((from (copy-marker (overlay-start quail-conv-overlay)))
90	 (len (- (overlay-end quail-conv-overlay) from)))
91    (quail-delete-overlays)
92    (setq quail-current-str nil)
93    (unwind-protect
94	(let ((result (kkc-region from (+ from len))))
95	  (move-overlay quail-conv-overlay from (point))
96	  (setq quail-conversion-str (buffer-substring from (point)))
97	  (if (= (+ from result) (point))
98	      (setq quail-converting nil))
99	  (setq quail-translating nil))
100      (set-marker from nil))))
101
102(defun quail-japanese-self-insert-and-switch-to-alpha (key idx)
103  (quail-delete-region)
104  (setq unread-command-events (list (aref key (1- idx))))
105  (quail-japanese-switch-package "q" 1))
106
107(defvar quail-japanese-switch-table
108  '((?z . "japanese-zenkaku")
109    (?k . "japanese-hankaku-kana")
110    (?h . "japanese")
111    (?q . ("japanese-ascii"))))
112
113(defvar quail-japanese-package-saved nil)
114(make-variable-buffer-local 'quail-japanese-package-saved)
115(put 'quail-japanese-package-saved 'permanent-local t)
116
117(defun quail-japanese-switch-package (key idx)
118  (quail-delete-region)
119  (setq quail-current-str nil
120	quail-converting nil
121	quail-conversion-str "")
122  (let ((pkg (cdr (assq (aref key (1- idx)) quail-japanese-switch-table))))
123    (if (null pkg)
124	(quail-error "No package to be switched")
125      (if (stringp pkg)
126	  (activate-input-method pkg)
127	(if (string= (car pkg) current-input-method)
128	    (if quail-japanese-package-saved
129		(activate-input-method quail-japanese-package-saved))
130	  (setq quail-japanese-package-saved current-input-method)
131	  (activate-input-method (car pkg))))))
132  (throw 'quail-tag nil))
133
134(defvar quail-japanese-transliteration-rules
135  '(( "a" "$B$"(B") ( "i" "$B$$(B") ( "u" "$B$&(B") ( "e" "$B$((B") ( "o" "$B$*(B")
136    ("ka" "$B$+(B") ("ki" "$B$-(B") ("ku" "$B$/(B") ("ke" "$B$1(B") ("ko" "$B$3(B")
137    ("sa" "$B$5(B") ("si" "$B$7(B") ("su" "$B$9(B") ("se" "$B$;(B") ("so" "$B$=(B")
138    ("ta" "$B$?(B") ("ti" "$B$A(B") ("tu" "$B$D(B") ("te" "$B$F(B") ("to" "$B$H(B")
139    ("na" "$B$J(B") ("ni" "$B$K(B") ("nu" "$B$L(B") ("ne" "$B$M(B") ("no" "$B$N(B")
140    ("ha" "$B$O(B") ("hi" "$B$R(B") ("hu" "$B$U(B") ("he" "$B$X(B") ("ho" "$B$[(B")
141    ("ma" "$B$^(B") ("mi" "$B$_(B") ("mu" "$B$`(B") ("me" "$B$a(B") ("mo" "$B$b(B")
142    ("ya" "$B$d(B")             ("yu" "$B$f(B")             ("yo" "$B$h(B")
143    ("ra" "$B$i(B") ("ri" "$B$j(B") ("ru" "$B$k(B") ("re" "$B$l(B") ("ro" "$B$m(B")
144    ("la" "$B$i(B") ("li" "$B$j(B") ("lu" "$B$k(B") ("le" "$B$l(B") ("lo" "$B$m(B")
145    ("wa" "$B$o(B") ("wi" "$B$p(B") ("wu" "$B$&(B") ("we" "$B$q(B") ("wo" "$B$r(B")
146    ("n'" "$B$s(B")
147    ("ga" "$B$,(B") ("gi" "$B$.(B") ("gu" "$B$0(B") ("ge" "$B$2(B") ("go" "$B$4(B")
148    ("za" "$B$6(B") ("zi" "$B$8(B") ("zu" "$B$:(B") ("ze" "$B$<(B") ("zo" "$B$>(B")
149    ("da" "$B$@(B") ("di" "$B$B(B") ("du" "$B$E(B") ("de" "$B$G(B") ("do" "$B$I(B")
150    ("ba" "$B$P(B") ("bi" "$B$S(B") ("bu" "$B$V(B") ("be" "$B$Y(B") ("bo" "$B$\(B")
151    ("pa" "$B$Q(B") ("pi" "$B$T(B") ("pu" "$B$W(B") ("pe" "$B$Z(B") ("po" "$B$](B")
152
153    ("kya" ["$B$-$c(B"]) ("kyu" ["$B$-$e(B"]) ("kye" ["$B$-$'(B"]) ("kyo" ["$B$-$g(B"])
154    ("sya" ["$B$7$c(B"]) ("syu" ["$B$7$e(B"]) ("sye" ["$B$7$'(B"]) ("syo" ["$B$7$g(B"])
155    ("sha" ["$B$7$c(B"]) ("shu" ["$B$7$e(B"]) ("she" ["$B$7$'(B"]) ("sho" ["$B$7$g(B"])
156    ("cha" ["$B$A$c(B"]) ("chu" ["$B$A$e(B"]) ("che" ["$B$A$'(B"]) ("cho" ["$B$A$g(B"])
157    ("tya" ["$B$A$c(B"]) ("tyu" ["$B$A$e(B"]) ("tye" ["$B$A$'(B"]) ("tyo" ["$B$A$g(B"])
158    ("nya" ["$B$K$c(B"]) ("nyu" ["$B$K$e(B"]) ("nye" ["$B$K$'(B"]) ("nyo" ["$B$K$g(B"])
159    ("hya" ["$B$R$c(B"]) ("hyu" ["$B$R$e(B"]) ("hye" ["$B$R$'(B"]) ("hyo" ["$B$R$g(B"])
160    ("mya" ["$B$_$c(B"]) ("myu" ["$B$_$e(B"]) ("mye" ["$B$_$'(B"]) ("myo" ["$B$_$g(B"])
161    ("rya" ["$B$j$c(B"]) ("ryu" ["$B$j$e(B"]) ("rye" ["$B$j$'(B"]) ("ryo" ["$B$j$g(B"])
162    ("lya" ["$B$j$c(B"]) ("lyu" ["$B$j$e(B"]) ("lye" ["$B$j$'(B"]) ("lyo" ["$B$j$g(B"])
163    ("gya" ["$B$.$c(B"]) ("gyu" ["$B$.$e(B"]) ("gye" ["$B$.$'(B"]) ("gyo" ["$B$.$g(B"])
164    ("zya" ["$B$8$c(B"]) ("zyu" ["$B$8$e(B"]) ("zye" ["$B$8$'(B"]) ("zyo" ["$B$8$g(B"])
165    ("jya" ["$B$8$c(B"]) ("jyu" ["$B$8$e(B"]) ("jye" ["$B$8$'(B"]) ("jyo" ["$B$8$g(B"])
166    ( "ja" ["$B$8$c(B"]) ( "ju" ["$B$8$e(B"]) ( "je" ["$B$8$'(B"]) ( "jo" ["$B$8$g(B"])
167    ("bya" ["$B$S$c(B"]) ("byu" ["$B$S$e(B"]) ("bye" ["$B$S$'(B"]) ("byo" ["$B$S$g(B"])
168    ("pya" ["$B$T$c(B"]) ("pyu" ["$B$T$e(B"]) ("pye" ["$B$T$'(B"]) ("pyo" ["$B$T$g(B"])
169
170    ("kwa" ["$B$/$n(B"]) ("kwi" ["$B$/$#(B"]) ("kwe" ["$B$/$'(B"]) ("kwo" ["$B$/$)(B"])
171    ("tsa" ["$B$D$!(B"]) ("tsi" ["$B$D$#(B"]) ("tse" ["$B$D$'(B"]) ("tso" ["$B$D$)(B"])
172    ( "fa" ["$B$U$!(B"]) ( "fi" ["$B$U$#(B"]) ( "fe" ["$B$U$'(B"]) ( "fo" ["$B$U$)(B"])
173    ("gwa" ["$B$0$n(B"]) ("gwi" ["$B$0$#(B"]) ("gwe" ["$B$0$'(B"]) ("gwo" ["$B$0$)(B"])
174
175    ("dyi" ["$B$G$#(B"]) ("dyu" ["$B$I$%(B"]) ("dye" ["$B$G$'(B"]) ("dyo" ["$B$I$)(B"])
176    ("xwi" ["$B$&$#(B"])                  ("xwe" ["$B$&$'(B"]) ("xwo" ["$B$&$)(B"])
177
178    ("shi" "$B$7(B") ("tyi" ["$B$F$#(B"]) ("chi" "$B$A(B") ("tsu" "$B$D(B") ("ji" "$B$8(B")
179    ("fu"  "$B$U(B")
180    ("ye" ["$B$$$'(B"])
181
182    ("va" ["$B%t$!(B"]) ("vi" ["$B%t$#(B"]) ("vu" "$B%t(B") ("ve" ["$B%t$'(B"]) ("vo" ["$B%t$)(B"])
183
184    ("xa"  "$B$!(B") ("xi"  "$B$#(B") ("xu"  "$B$%(B") ("xe"  "$B$'(B") ("xo"  "$B$)(B")
185    ("xtu" "$B$C(B") ("xya" "$B$c(B") ("xyu" "$B$e(B") ("xyo" "$B$g(B") ("xwa" "$B$n(B")
186    ("xka" "$B%u(B") ("xke" "$B%v(B")
187
188    ("1" "$B#1(B") ("2" "$B#2(B") ("3" "$B#3(B") ("4" "$B#4(B") ("5" "$B#5(B")
189    ("6" "$B#6(B") ("7" "$B#7(B") ("8" "$B#8(B") ("9" "$B#9(B") ("0" "$B#0(B")
190
191    ("!" "$B!*(B") ("@" "$B!w(B") ("#" "$B!t(B") ("$" "$B!p(B") ("%" "$B!s(B")
192    ("^" "$B!0(B") ("&" "$B!u(B") ("*" "$B!v(B") ("(" "$B!J(B") (")" "$B!K(B")
193    ("-" "$B!<(B") ("=" "$B!a(B") ("`" "$B!.(B") ("\\" "$B!o(B") ("|" "$B!C(B")
194    ("_" "$B!2(B") ("+" "$B!\(B") ("~" "$B!1(B") ("[" "$B!V(B") ("]" "$B!W(B")
195    ("{" "$B!P(B") ("}" "$B!Q(B") (":" "$B!'(B") (";" "$B!((B") ("\""  "$B!I(B")
196    ("'" "$B!G(B") ("." "$B!#(B") ("," "$B!"(B") ("<" "$B!c(B") (">" "$B!d(B")
197    ("?" "$B!)(B") ("/" "$B!?(B")
198
199    ("z1" "$B!{(B") ("z!" "$B!|(B")
200    ("z2" "$B"&(B") ("z@" "$B"'(B")
201    ("z3" "$B"$(B") ("z#" "$B"%(B")
202    ("z4" "$B""(B") ("z$" "$B"#(B")
203    ("z5" "$B!~(B") ("z%" "$B"!(B")
204    ("z6" "$B!y(B") ("z^" "$B!z(B")
205    ("z7" "$B!}(B") ("z&" "$B!r(B")
206    ("z8" "$B!q(B") ("z*" "$B!_(B")
207    ("z9" "$B!i(B") ("z(" "$B!Z(B")
208    ("z0" "$B!j(B") ("z)" "$B![(B")
209    ("z-" "$B!A(B") ("z_" "$B!h(B")
210    ("z=" "$B!b(B") ("z+" "$B!^(B")
211    ("z\\" "$B!@(B") ("z|" "$B!B(B")
212    ("z`" "$B!-(B") ("z~" "$B!/(B")
213
214    ("zq" "$B!T(B") ("zQ" "$B!R(B")
215    ("zw" "$B!U(B") ("zW" "$B!S(B")
216    ("zr" "$B!9(B") ("zR" "$B!8(B")
217    ("zt" "$B!:(B") ("zT" "$B!x(B")
218    ("zp" "$B")(B") ("zP" "$B",(B")
219    ("z[" "$B!X(B") ("z{" "$B!L(B")
220    ("z]" "$B!Y(B") ("z}" "$B!M(B")
221
222    ("zs" "$B!3(B") ("zS" "$B!4(B")
223    ("zd" "$B!5(B") ("zD" "$B!6(B")
224    ("zf" "$B!7(B") ("zF" "$B"*(B")
225    ("zg" "$B!>(B") ("zG" "$B!=(B")
226    ("zh" "$B"+(B")
227    ("zj" "$B"-(B")
228    ("zk" "$B",(B")
229    ("zl" "$B"*(B")
230    ("z;" "$B!+(B") ("z:" "$B!,(B")
231    ("z\'" "$B!F(B") ("z\"" "$B!H(B")
232
233    ("zx" [":-"]) ("zX" [":-)"])
234    ("zc" "$B!;(B") ("zC" "$B!n(B")
235    ("zv" "$B"((B") ("zV" "$B!`(B")
236    ("zb" "$B!k(B") ("zB" "$B"+(B")
237    ("zn" "$B!l(B") ("zN" "$B"-(B")
238    ("zm" "$B!m(B") ("zM" "$B".(B")
239    ("z," "$B!E(B") ("z<" "$B!e(B")
240    ("z." "$B!D(B") ("z>" "$B!f(B")
241    ("z/" "$B!&(B") ("z?" "$B!g(B")
242
243    ("\\\\" quail-japanese-self-insert-and-switch-to-alpha)
244    ("{{" quail-japanese-self-insert-and-switch-to-alpha)
245    ("}}" quail-japanese-self-insert-and-switch-to-alpha)
246
247    ("qq" quail-japanese-switch-package)
248    ("qz" quail-japanese-switch-package)
249    ))
250
251
252;; $B%m!<%^;zF~NO5Z$S2>L>4A;zJQ49$K$h$kF|K\8lF~NO%a%=%C%I(B
253;;
254;; $B$3$NF~NO%a%=%C%I$G$NF|K\8l$NF~NO$OFs$D$N%9%F!<%8!V%m!<%^;z2>L>JQ49!W(B
255;; $B$H!V2>L>4A;zJQ49!W$+$i$J$k!#:G=i$O%m!<%^;z2>L>JQ49$N%9%F!<%8$G!"%9(B
256;; $B%Z!<%9%-!<$r2!$9$3$H$K$h$j!"<!$N%9%F!<%8!V2>L>4A;zJQ49!W$X?J$`!#(B
257;;
258;; $B!V%m!<%^;z2>L>JQ49!W(B
259;;
260;; $BJ?2>L>$O>.J8;z%-!<!JNs!K$rBG$D$3$H$K$h$jF~NO!#6gFIE@!"3g8LN`$OBP1~(B
261;; $B$9$k1Q;z%-!<$rBG$D$3$H$K$h$jF~NO!#$=$NB>$N%7%s%\%k$O(B `z' $B$KB3$1$F2?(B
262;; $B$l$+$N%-!<$rBG$D$3$H$K$h$jF~NO!#2<$KA4$F$N2DG=$J%-!<%7!<%1%s%9%j%9(B
263;; $B%H%"%C%W$5$l$F$$$k!#F~NO$5$l$?J8;z$O2<@~$G<($5$l$k!#(B
264;;
265;; $B$5$i$K0J2<$N%-!<$GFCJL$J=hM}$r9T$&!#(B
266;;
267;; K	$BJ?2>L>$rJR2>L>$K!"$"$k$$$OJR2>L>$rJ?2>L>$KJQ49(B
268;; qq	$B$3$NF~NO%a%=%C%I$H(B `japanese-ascii' $BF~NO%a%=%C%I$r%H%0%k@ZBX(B
269;; qz	`japanese-zenkaku' $BF~NO%a%=%C%I$K%7%U%H(B
270;;	qh $B$HBG$F$P85$KLa$k(B
271;; RET	$B8=:_$NF~NOJ8;zNs$r3NDj(B
272;; SPC	$B2>L>4A;zJQ49$K?J$`(B
273;;
274;; `japanese-ascii' $BF~NO%a%=%C%I$O(B ASCII $BJ8;z$rF~NO$9$k$N$K;H$&!#$3$l(B
275;; $B$OF~NO%a%=%C%I$r%*%U$K$9$k$N$H$[$H$s$IF1$8$G$"$k!#0[$J$k$N$O(B qq $B$H(B
276;; $BBG$D$3$H$K$h$j!"(B`japanese' $BF~NO%a%=%C%I$KLa$l$kE@$G$"$k!#(B
277;;
278;; `japanese-zenkaku' $BF~NO%a%=%C%I$OA43Q1Q?t;z$rF~NO$9$k$N$K;H$&!#(B
279;;
280;; $B!V%m!<%^;z2>L>JQ49!W%9%F!<%8$G$N%-!<%7!<%1%s%9$N%j%9%H$O:G8e$KIU$1(B
281;; $B$F$"$k!#(B
282;;
283;; $B!V2>L>4A;zJQ49!W(B
284;;
285;; $B$3$N%9%F!<%8$G$O!"A0%9%F!<%8$GF~NO$5$l$?J8;zNs$r2>L>4A;zJQ49$9$k!#(B
286;; $BJQ49$5$l$?J8;zNs$O!"CmL\J8@a!JH?E>I=<(!K$H;D$j$NF~NO!J2<@~I=<(!K$K(B
287;; $BJ,$1$i$l$k!#CmL\J8@a$KBP$7$F$O0J2<$N%3%^%s%I$,;H$($k!#(B
288;;
289;; SPC, C-n	kkc-next
290;;	$B<!$NJQ498uJd$rI=<((B
291;;	kkc-show-conversion-list-count $B0J>eB3$1$FBG$F$P!"JQ498uJd%j%9(B
292;;	$B%H$r%(%3!<%(%j%"$KI=<((B
293;; C-p		kkc-prev
294;;	$BA0$NJQ498uJd$rI=<((B
295;;	kkc-show-conversion-list-count $B0J>eB3$1$FBG$F$P!"JQ498uJd%j%9(B
296;;	$B%H$r%(%3!<%(%j%"$KI=<((B
297;; l		kkc-show-conversion-list-or-next-group
298;;	$B:G9b#1#08D$^$G$NJQ498uJd$r%(%3!<%(%j%"$KI=<(!#(B
299;;	$BB3$1$FBG$?$l$l$P!"<!$N#1#08uJd$rI=<(!#(B
300;; L		kkc-show-conversion-list-or-prev-group
301;;	$B:G9b#1#08D$^$G$NJQ498uJd$r%(%3!<%(%j%"$KI=<(!#(B
302;;	$BB3$1$FBG$?$l$l$P!"A0$N#1#08uJd$rI=<(!#(B
303;; 0..9		kkc-select-from-list
304;;	$BBG$?$l$??t;z$NJQ498uJd$rA*Br(B
305;; H		kkc-hiragana
306;;	$BCmL\J8@a$rJ?2>L>$KJQ49(B
307;; K		kkc-katakana
308;;	$BCmL\J8@a$rJR2>L>$KJQ49(B
309;; C-o		kkc-longer
310;;	$BCmL\J8@a$r8e$m$K0lJ8;z?-$P$9(B
311;; C-i		kkc-shorter
312;;	$BCmL\J8@a$r8e$m$+$i0lJ8;z=L$a$k(B
313;; C-f		kkc-next-phrase
314;;	$BCmL\J8@a$r3NDj$5$;$k!#$b$7;D$j$NF~NO$,$^$@$"$l$P!":G=i$NJ8@a$r(B
315;;	$BA*Br$7!"$=$l$rCmL\J8@a$H$7!"$=$N:G=i$NJQ498uJd$rI=<($9$k!#(B
316;; DEL, C-c	kkc-cancel
317;;	$B2>L>4A;zJQ49$r%-%c%s%;%k$7!"%m!<%^;z2>L>JQ49$N%9%F!<%8$KLa$k!#(B
318;; return		kkc-terminate
319;;	$BA4J8@a$r3NDj$5$;$k!#(B
320;; C-SPC, C-@	kkc-first-char-only
321;;	$B:G=i$NJ8;z$r3NDj$5$;!";D$j$O:o=|$9$k!#(B
322;; C-h		kkc-help
323;;	$B$3$l$i$N%-!<%P%$%s%I$N%j%9%H$rI=<($9$k!#$"(B
324
325(quail-define-package
326 "japanese" "Japanese" "A$B$"(B"
327 nil
328 "Japanese input method by Roman transliteration and Kana-Kanji conversion.
329
330When you use this input method, text entry proceeds in two stages:
331Roman-Kana transliteration and Kana-Kanji conversion.  When you start
332to enter text, you are in the first stage, Roman-Kana transliteration.
333Type SPC to proceed to the next stage, Kana-Kanji conversion.
334
335:: Roman-Kana transliteration ::
336
337You can input any Hiragana character as a sequence of lower-case
338letters, Japanese punctuation characters by typing punctuation keys,
339Japanese symbols by typing `z' followed by another key.  See below for
340a list of all available sequences.  The characters you input are
341underlined.
342
343In addition, the following keys provide special effects:
344
345K	Change Hiragana to Katakana or Katakana to Hiragana.
346qq	Toggle between this input method and the input method `japanese-ascii'.
347qz	Shift to the input method `japanese-zenkaku'.
348	Typing \"qh\" will put you back to this input method.
349RET	Accept the current character sequence.
350SPC	Proceed to the next stage, Kana-Kanji conversion.
351
352The input method `japanese-ascii' is used to enter ASCII characters.
353This is almost the same as turning off the input method.  The only
354difference is that typing `qq' will put you back into the Japanese
355input method.
356
357The input method `japanese-zenkaku' is used to enter full width
358JISX0208 characters corresponding to typed ASCII characters.
359
360List of the all key sequences for Roman-Kana transliteration is shown
361at the tail.
362
363:: Kana-Kanji conversion ::
364
365You can convert the current Japanese characters (underlined) to
366Kana-Kanji mixed text.  In this stage, the converted text is divided
367into two parts, the current phrase (highlighted) and the remaining
368input (underlined).  The following commands can be used on the
369current phrase.
370
371SPC, C-n	kkc-next
372	Show the next candidate for the current phrase.
373	If successively typed `kkc-show-conversion-list-count' times,
374	conversion candidates are shown in the echo area.
375C-p		kkc-prev
376	Show the previous candidate for the current phrase.
377	If successively typed `kkc-show-conversion-list-count' times,
378	conversion candidates are shown in the echo area.
379l		kkc-show-conversion-list-or-next-group
380	Show at most 10 candidates for the current phrase in echo area.
381	If typed repeatedly, show the next 10 candidates.
382L		kkc-show-conversion-list-or-prev-group
383	Show at most 10 candidates for the current phrase in echo area.
384	If typed repeatedly, show the previous 10 candidates.
3850..9		kkc-select-from-list
386	Select a candidate corresponding to the typed number.
387H		kkc-hiragana
388	Convert the current phrase to Hiragana
389K		kkc-katakana
390	Convert the current phrase to Katakana
391C-o		kkc-longer
392	Extend the current phrase; pull in the first character of
393	the remaining input.
394C-i		kkc-shorter
395	Contract the current phrase; drop its last character
396	back into the remaining input.
397C-f		kkc-next-phrase
398	Accept the current phrase.  If there remains input, select
399	the first phrase as the current one, and show the first
400	candidate for the conversion.
401DEL, C-c	kkc-cancel
402	Cancel the conversion, shift back to the Roman-Kana
403	transliteration.
404return		kkc-terminate
405	Accept the whole conversion.
406C-SPC, C-@	kkc-first-char-only
407	Accept the first character of the current conversion,
408	delete the remaining input.
409C-h		kkc-help
410	List these key bindings.
411"
412 nil t t nil nil nil nil nil
413 'quail-japanese-update-translation
414 '(("K" . quail-japanese-toggle-kana)
415   (" " . quail-japanese-kanji-kkc)
416   ("\C-m" . quail-no-conversion)
417   ([return] . quail-no-conversion))
418 )
419
420(dolist (elt quail-japanese-transliteration-rules)
421  (quail-defrule (car elt) (nth 1 elt)))
422
423(quail-define-package
424 "japanese-ascii" "Japanese" "Aa"
425 nil
426 "Temporary ASCII input mode used within the input method `japanese'.
427Type \"qq\" to go back to previous input method."
428 nil t t)
429
430(quail-define-rules ("qq" quail-japanese-switch-package))
431
432(quail-define-package
433 "japanese-zenkaku" "Japanese" "$B#A(B"
434 nil
435 "Japanese zenkaku alpha numeric character input method.
436---- Special key bindings ----
437qq:	toggle between this input method and the input method `japanese-ascii'.
438qh:	shift to the input method `japanese',
439	typing \"qz\" puts you back to this input method.
440"
441 nil t t)
442
443(quail-define-rules
444
445(" " "$B!!(B") ("!" "$B!*(B") ("\"" "$B!m(B") ("#" "$B!t(B")
446("$" "$B!p(B") ("%" "$B!s(B") ("&" "$B!u(B") ("'" "$B!l(B")
447("(" "$B!J(B") (")" "$B!K(B") ("*" "$B!v(B") ("+" "$B!\(B")
448("," "$B!$(B") ("-" "$B!](B") ("." "$B!%(B") ("/" "$B!?(B")
449("0" "$B#0(B") ("1" "$B#1(B") ("2" "$B#2(B") ("3" "$B#3(B")
450("4" "$B#4(B") ("5" "$B#5(B") ("6" "$B#6(B") ("7" "$B#7(B")
451("8" "$B#8(B") ("9" "$B#9(B") (":" "$B!'(B") (";" "$B!((B")
452("<" "$B!c(B") ("=" "$B!a(B") (">" "$B!d(B") ("?" "$B!)(B")
453("@" "$B!w(B") ("A" "$B#A(B") ("B" "$B#B(B") ("C" "$B#C(B")
454("D" "$B#D(B") ("E" "$B#E(B") ("F" "$B#F(B") ("G" "$B#G(B")
455("H" "$B#H(B") ("I" "$B#I(B") ("J" "$B#J(B") ("K" "$B#K(B")
456("L" "$B#L(B") ("M" "$B#M(B") ("N" "$B#N(B") ("O" "$B#O(B")
457("P" "$B#P(B") ("Q" "$B#Q(B") ("R" "$B#R(B") ("S" "$B#S(B")
458("T" "$B#T(B") ("U" "$B#U(B") ("V" "$B#V(B") ("W" "$B#W(B")
459("X" "$B#X(B") ("Y" "$B#Y(B") ("Z" "$B#Z(B") ("[" "$B!N(B")
460("\\" "$B!o(B") ("]" "$B!O(B") ("^" "$B!0(B") ("_" "$B!2(B")
461("`" "$B!F(B") ("a" "$B#a(B") ("b" "$B#b(B") ("c" "$B#c(B")
462("d" "$B#d(B") ("e" "$B#e(B") ("f" "$B#f(B") ("g" "$B#g(B")
463("h" "$B#h(B") ("i" "$B#i(B") ("j" "$B#j(B") ("k" "$B#k(B")
464("l" "$B#l(B") ("m" "$B#m(B") ("n" "$B#n(B") ("o" "$B#o(B")
465("p" "$B#p(B") ("q" "$B#q(B") ("r" "$B#r(B") ("s" "$B#s(B")
466("t" "$B#t(B") ("u" "$B#u(B") ("v" "$B#v(B") ("w" "$B#w(B")
467("x" "$B#x(B") ("y" "$B#y(B") ("z" "$B#z(B") ("{" "$B!P(B")
468("|" "$B!C(B") ("}" "$B!Q(B") ("~" "$B!A(B")
469
470("qq" quail-japanese-switch-package)
471("qh" quail-japanese-switch-package)
472)
473
474(defun quail-japanese-hankaku-update-translation (control-flag)
475  (setq control-flag
476	(quail-japanese-update-translation control-flag))
477  (if (or (and (stringp quail-current-str)
478	       (> (length quail-current-str) 0))
479	  (integerp quail-current-str))
480      (setq quail-current-str (japanese-hankaku quail-current-str)))
481  control-flag)
482
483(quail-define-package
484 "japanese-hankaku-kana"
485 "Japanese" "(I1(B"
486 nil
487 "Japanese hankaku katakana input method by Roman transliteration.
488---- Special key bindings ----
489qq:	toggle between this input method and the input method `japanese-ascii'.
490"
491 nil t t nil nil nil nil nil
492 'quail-japanese-hankaku-update-translation)
493
494(dolist (elt quail-japanese-transliteration-rules)
495  (quail-defrule (car elt)
496		 (let ((trans (nth 1 elt)))
497		   (when (or (stringp trans) (vectorp trans))
498		     (let ((s (japanese-hankaku (if (stringp trans)
499						    trans
500						  (aref trans 0)))))
501		       ;; If the result of the conversion is a string
502		       ;; containing more than one character, make the
503		       ;; result a vector, so that quail-defrule
504		       ;; recognizes the whole string is the
505		       ;; translation, instead of interpreting
506		       ;; individual characters as alternative
507		       ;; translations.
508		       (if (and (stringp s) (> (length s) 1))
509			   (setq trans (vector s))
510			 (setq trans s))))
511		   trans)))
512
513(quail-define-package
514 "japanese-hiragana" "Japanese" "$B$"(B"
515 nil
516 "Japanese hiragana input method by Roman transliteration."
517 nil t t nil nil nil nil nil
518 'quail-japanese-update-translation)
519
520;; Use the same map as that of `japanese'.
521(setcar (cdr (cdr quail-current-package))
522	(nth 2 (assoc "japanese" quail-package-alist)))
523
524;; Update Quail translation region while converting Hiragana to Katakana.
525(defun quail-japanese-katakana-update-translation (control-flag)
526  (setq control-flag
527	(quail-japanese-update-translation control-flag))
528  (if (or (and (stringp quail-current-str)
529	       (> (length quail-current-str) 0))
530	  (integerp quail-current-str))
531      (setq quail-current-str (japanese-katakana quail-current-str)))
532  control-flag)
533
534(quail-define-package
535 "japanese-katakana" "Japanese" "$B%"(B"
536 nil
537 "Japanese katakana input method by Roman transliteration."
538 nil t t nil nil nil nil nil
539 'quail-japanese-katakana-update-translation)
540
541(dolist (elt quail-japanese-transliteration-rules)
542  (quail-defrule (car elt)
543		 (let ((trans (nth 1 elt)))
544		   (cond ((stringp trans)
545			  (japanese-katakana trans))
546			 ((vectorp trans)
547			  (vector (japanese-katakana (aref trans 0))))
548			 (t trans)))))
549
550;;; arch-tag: 47e0bfd4-6ecc-4d01-89a8-d687c5e01ff7
551;;; japanese.el ends here
552