japanese.el 23 KB

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