1;;; japanese.el --- Quail package for inputting Japanese 2 3;; Copyright (C) 2001-2021 Free Software Foundation, Inc. 4;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 5;; 2006, 2007, 2008, 2009, 2010, 2011 6;; National Institute of Advanced Industrial Science and Technology (AIST) 7;; Registration Number H14PRO021 8 9;; Keywords: multilingual, input method, Japanese 10 11;; This file is part of GNU Emacs. 12 13;; GNU Emacs is free software: you can redistribute it and/or modify 14;; it under the terms of the GNU General Public License as published by 15;; the Free Software Foundation, either version 3 of the License, or 16;; (at your option) any later version. 17 18;; GNU Emacs is distributed in the hope that it will be useful, 19;; but WITHOUT ANY WARRANTY; without even the implied warranty of 20;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21;; GNU General Public License for more details. 22 23;; You should have received a copy of the GNU General Public License 24;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. 25 26;;; Commentary: 27 28;;; Code: 29 30(require 'quail) 31(require 'kkc) 32 33(defvar quail-japanese-use-double-n nil 34 "If non-nil, use type \"nn\" to insert ん.") 35 36;; Update Quail translation region while considering Japanese bizarre 37;; translation rules. 38(defun quail-japanese-update-translation (control-flag) 39 (if (null control-flag) 40 (setq quail-current-str 41 (if (/= (aref quail-current-key 0) ?q) 42 (or quail-current-str quail-current-key) 43 "")) 44 (if (integerp control-flag) 45 (let ((keylen (length quail-current-key))) 46 (cond ((= control-flag 0) 47 (setq quail-current-str (aref quail-current-key 0) 48 control-flag t)) 49 ((= (aref quail-current-key 0) ?n) 50 (setq quail-current-str ?ん) 51 (if (and quail-japanese-use-double-n 52 (> keylen 0) 53 (= (aref quail-current-key 1) ?n)) 54 (setq control-flag t))) 55 ((and (> keylen 1) 56 (= (aref quail-current-key 0) (aref quail-current-key 1))) 57 (setq quail-current-str ?っ)) 58 (t 59 (setq quail-current-str (aref quail-current-key 0)))) 60 (if (integerp control-flag) 61 (setq unread-command-events 62 (append 63 (substring quail-current-key control-flag) 64 unread-command-events)))))) 65 control-flag) 66 67;; Convert Hiragana <-> Katakana in the current translation region. 68(defun quail-japanese-toggle-kana () 69 (interactive) 70 (setq quail-translating nil) 71 (let ((start (overlay-start quail-conv-overlay)) 72 (end (overlay-end quail-conv-overlay))) 73 (save-excursion 74 (goto-char start) 75 (if (re-search-forward "\\cH" end t) 76 (japanese-katakana-region start end) 77 (japanese-hiragana-region start end))) 78 (setq quail-conversion-str 79 (buffer-substring (overlay-start quail-conv-overlay) 80 (overlay-end quail-conv-overlay))))) 81 82;; Convert Hiragana in the current translation region to Kanji by KKC 83;; (Kana Kanji Converter) utility. 84(defun quail-japanese-kanji-kkc () 85 (interactive) 86 (when (= (char-before (overlay-end quail-conv-overlay)) ?n) 87 ;; The last char is `n'. We had better convert it to `ん' 88 ;; before kana-kanji conversion. 89 (goto-char (1- (overlay-end quail-conv-overlay))) 90 (insert ?ん) 91 (delete-char 1)) 92 (let* ((from (copy-marker (overlay-start quail-conv-overlay))) 93 (len (- (overlay-end quail-conv-overlay) from))) 94 (quail-delete-overlays) 95 (setq quail-current-str nil) 96 (unwind-protect 97 (let ((result (kkc-region from (+ from len)))) 98 (move-overlay quail-conv-overlay from (point)) 99 (setq quail-conversion-str (buffer-substring from (point))) 100 (if (= (+ from result) (point)) 101 (setq quail-converting nil)) 102 (setq quail-translating nil)) 103 (set-marker from nil)))) 104 105(defun quail-japanese-self-insert-and-switch-to-alpha (key idx) 106 (quail-delete-region) 107 (push (aref key (1- idx)) unread-command-events) 108 (quail-japanese-switch-package "q" 1)) 109 110(defvar quail-japanese-switch-table 111 '((?z . "japanese-zenkaku") 112 (?k . "japanese-hankaku-kana") 113 (?h . "japanese") 114 (?q . ("japanese-ascii")))) 115 116(defvar quail-japanese-package-saved nil) 117(make-variable-buffer-local 'quail-japanese-package-saved) 118(put 'quail-japanese-package-saved 'permanent-local t) 119 120(defun quail-japanese-switch-package (key idx) 121 (quail-delete-region) 122 (setq quail-current-str nil 123 quail-converting nil 124 quail-conversion-str "") 125 (let ((pkg (cdr (assq (aref key (1- idx)) quail-japanese-switch-table)))) 126 (if (null pkg) 127 (quail-error "No package to be switched") 128 (if (stringp pkg) 129 (activate-input-method pkg) 130 (if (string= (car pkg) current-input-method) 131 (if quail-japanese-package-saved 132 (activate-input-method quail-japanese-package-saved)) 133 (setq quail-japanese-package-saved current-input-method) 134 (activate-input-method (car pkg)))))) 135 (throw 'quail-tag nil)) 136 137(defvar quail-japanese-transliteration-rules 138 '(( "a" "あ") ( "i" "い") ( "u" "う") ( "e" "え") ( "o" "お") 139 ("ka" "か") ("ki" "き") ("ku" "く") ("ke" "け") ("ko" "こ") 140 ("sa" "さ") ("si" "し") ("su" "す") ("se" "せ") ("so" "そ") 141 ("ta" "た") ("ti" "ち") ("tu" "つ") ("te" "て") ("to" "と") 142 ("na" "な") ("ni" "に") ("nu" "ぬ") ("ne" "ね") ("no" "の") 143 ("ha" "は") ("hi" "ひ") ("hu" "ふ") ("he" "へ") ("ho" "ほ") 144 ("ma" "ま") ("mi" "み") ("mu" "む") ("me" "め") ("mo" "も") 145 ("ya" "や") ("yu" "ゆ") ("yo" "よ") 146 ("ra" "ら") ("ri" "り") ("ru" "る") ("re" "れ") ("ro" "ろ") 147 ("la" "ら") ("li" "り") ("lu" "る") ("le" "れ") ("lo" "ろ") 148 ("wa" "わ") ("wi" "ゐ") ("wu" "う") ("we" "ゑ") ("wo" "を") 149 ("n'" "ん") 150 ("ga" "が") ("gi" "ぎ") ("gu" "ぐ") ("ge" "げ") ("go" "ご") 151 ("za" "ざ") ("zi" "じ") ("zu" "ず") ("ze" "ぜ") ("zo" "ぞ") 152 ("da" "だ") ("di" "ぢ") ("du" "づ") ("de" "で") ("do" "ど") 153 ("ba" "ば") ("bi" "び") ("bu" "ぶ") ("be" "べ") ("bo" "ぼ") 154 ("pa" "ぱ") ("pi" "ぴ") ("pu" "ぷ") ("pe" "ぺ") ("po" "ぽ") 155 156 ("kya" ["きゃ"]) ("kyu" ["きゅ"]) ("kye" ["きぇ"]) ("kyo" ["きょ"]) 157 ("sya" ["しゃ"]) ("syu" ["しゅ"]) ("sye" ["しぇ"]) ("syo" ["しょ"]) 158 ("sha" ["しゃ"]) ("shu" ["しゅ"]) ("she" ["しぇ"]) ("sho" ["しょ"]) 159 ("cha" ["ちゃ"]) ("chu" ["ちゅ"]) ("che" ["ちぇ"]) ("cho" ["ちょ"]) 160 ("tya" ["ちゃ"]) ("tyu" ["ちゅ"]) ("tye" ["ちぇ"]) ("tyo" ["ちょ"]) 161 ("nya" ["にゃ"]) ("nyu" ["にゅ"]) ("nye" ["にぇ"]) ("nyo" ["にょ"]) 162 ("hya" ["ひゃ"]) ("hyu" ["ひゅ"]) ("hye" ["ひぇ"]) ("hyo" ["ひょ"]) 163 ("mya" ["みゃ"]) ("myu" ["みゅ"]) ("mye" ["みぇ"]) ("myo" ["みょ"]) 164 ("rya" ["りゃ"]) ("ryu" ["りゅ"]) ("rye" ["りぇ"]) ("ryo" ["りょ"]) 165 ("lya" ["りゃ"]) ("lyu" ["りゅ"]) ("lye" ["りぇ"]) ("lyo" ["りょ"]) 166 ("gya" ["ぎゃ"]) ("gyu" ["ぎゅ"]) ("gye" ["ぎぇ"]) ("gyo" ["ぎょ"]) 167 ("zya" ["じゃ"]) ("zyu" ["じゅ"]) ("zye" ["じぇ"]) ("zyo" ["じょ"]) 168 ("jya" ["じゃ"]) ("jyu" ["じゅ"]) ("jye" ["じぇ"]) ("jyo" ["じょ"]) 169 ( "ja" ["じゃ"]) ( "ju" ["じゅ"]) ( "je" ["じぇ"]) ( "jo" ["じょ"]) 170 ("bya" ["びゃ"]) ("byu" ["びゅ"]) ("bye" ["びぇ"]) ("byo" ["びょ"]) 171 ("pya" ["ぴゃ"]) ("pyu" ["ぴゅ"]) ("pye" ["ぴぇ"]) ("pyo" ["ぴょ"]) 172 173 ("kwa" ["くゎ"]) ("kwi" ["くぃ"]) ("kwe" ["くぇ"]) ("kwo" ["くぉ"]) 174 ("tsa" ["つぁ"]) ("tsi" ["つぃ"]) ("tse" ["つぇ"]) ("tso" ["つぉ"]) 175 ( "fa" ["ふぁ"]) ( "fi" ["ふぃ"]) ( "fe" ["ふぇ"]) ( "fo" ["ふぉ"]) 176 ("gwa" ["ぐゎ"]) ("gwi" ["ぐぃ"]) ("gwe" ["ぐぇ"]) ("gwo" ["ぐぉ"]) 177 178 ("dyi" ["でぃ"]) ("dyu" ["どぅ"]) ("dye" ["でぇ"]) ("dyo" ["どぉ"]) 179 ("xwi" ["うぃ"]) ("xwe" ["うぇ"]) ("xwo" ["うぉ"]) 180 181 ("shi" "し") ("tyi" ["てぃ"]) ("chi" "ち") ("tsu" "つ") ("ji" "じ") 182 ("fu" "ふ") 183 ("ye" ["いぇ"]) 184 185 ("va" ["ヴぁ"]) ("vi" ["ヴぃ"]) ("vu" "ヴ") ("ve" ["ヴぇ"]) ("vo" ["ヴぉ"]) 186 187 ("xa" "ぁ") ("xi" "ぃ") ("xu" "ぅ") ("xe" "ぇ") ("xo" "ぉ") 188 ("xtu" "っ") ("xya" "ゃ") ("xyu" "ゅ") ("xyo" "ょ") ("xwa" "ゎ") 189 ("xka" "ヵ") ("xke" "ヶ") 190 191 ("1" "1") ("2" "2") ("3" "3") ("4" "4") ("5" "5") 192 ("6" "6") ("7" "7") ("8" "8") ("9" "9") ("0" "0") 193 194 ("!" "!") ("@" "@") ("#" "#") ("$" "$") ("%" "%") 195 ("^" "^") ("&" "&") ("*" "*") ("(" "(") (")" ")") 196 ("-" "ー") ("=" "=") ("`" "`") ("\\" "¥") ("|" "|") 197 ("_" "_") ("+" "+") ("~" " ̄") ("[" "「") ("]" "」") 198 ("{" "{") ("}" "}") (":" ":") (";" ";") ("\"" "”") 199 ("'" "’") ("." "。") ("," "、") ("<" "<") (">" ">") 200 ("?" "?") ("/" "/") 201 202 ("z1" "○") ("z!" "●") 203 ("z2" "▽") ("z@" "▼") 204 ("z3" "△") ("z#" "▲") 205 ("z4" "□") ("z$" "■") 206 ("z5" "◇") ("z%" "◆") 207 ("z6" "☆") ("z^" "★") 208 ("z7" "◎") ("z&" "£") 209 ("z8" "¢") ("z*" "×") 210 ("z9" "♂") ("z(" "【") 211 ("z0" "♀") ("z)" "】") 212 ("z-" "〜") ("z_" "∴") 213 ("z=" "≠") ("z+" "±") 214 ("z\\" "\") ("z|" "‖") 215 ("z`" "´") ("z~" "¨") 216 217 ("zq" "《") ("zQ" "〈") 218 ("zw" "》") ("zW" "〉") 219 ("zr" "々") ("zR" "仝") 220 ("zt" "〆") ("zT" "§") 221 ("zp" "〒") ("zP" "↑") 222 ("z[" "『") ("z{" "〔") 223 ("z]" "』") ("z}" "〕") 224 225 ("zs" "ヽ") ("zS" "ヾ") 226 ("zd" "ゝ") ("zD" "ゞ") 227 ("zf" "〃") ("zF" "→") 228 ("zg" "‐") ("zG" "—") 229 ("zh" "←") 230 ("zj" "↓") 231 ("zk" "↑") 232 ("zl" "→") 233 ("z;" "゛") ("z:" "゜") 234 ("z'" "‘") ("z\"" "“") 235 236 ("zx" [":-"]) ("zX" [":-)"]) 237 ("zc" "〇") ("zC" "℃") 238 ("zv" "※") ("zV" "÷") 239 ("zb" "°") ("zB" "←") 240 ("zn" "′") ("zN" "↓") 241 ("zm" "″") ("zM" "〓") 242 ("z," "‥") ("z<" "≦") 243 ("z." "…") ("z>" "≧") 244 ("z/" "・") ("z?" "∞") 245 246 ("\\\\" quail-japanese-self-insert-and-switch-to-alpha) 247 ("{{" quail-japanese-self-insert-and-switch-to-alpha) 248 ("}}" quail-japanese-self-insert-and-switch-to-alpha) 249 250 ("qq" quail-japanese-switch-package) 251 ("qz" quail-japanese-switch-package) 252 )) 253 254 255;; ローマ字入力及び仮名漢字変換による日本語入力メソッド 256;; 257;; この入力メソッドでの日本語の入力は二つのステージ「ローマ字仮名変換」 258;; と「仮名漢字変換」からなる。最初はローマ字仮名変換のステージで、ス 259;; ペースキーを押すことにより、次のステージ「仮名漢字変換」へ進む。 260;; 261;; 「ローマ字仮名変換」 262;; 263;; 平仮名は小文字キー(列)を打つことにより入力。句読点、括弧類は対応 264;; する英字キーを打つことにより入力。その他のシンボルは `z' に続けて何 265;; れかのキーを打つことにより入力。下に全ての可能なキーシーケンスリス 266;; トアップされている。入力された文字は下線で示される。 267;; 268;; さらに以下のキーで特別な処理を行う。 269;; 270;; K 平仮名を片仮名に、あるいは片仮名を平仮名に変換 271;; qq この入力メソッドと `japanese-ascii' 入力メソッドをトグル切替 272;; qz `japanese-zenkaku' 入力メソッドにシフト 273;; qh と打てば元に戻る 274;; RET 現在の入力文字列を確定 275;; SPC 仮名漢字変換に進む 276;; 277;; `japanese-ascii' 入力メソッドは ASCII 文字を入力するのに使う。これ 278;; は入力メソッドをオフにするのとほとんど同じである。異なるのは qq と 279;; 打つことにより、`japanese' 入力メソッドに戻れる点である。 280;; 281;; `japanese-zenkaku' 入力メソッドは全角英数字を入力するのに使う。 282;; 283;; 「ローマ字仮名変換」ステージでのキーシーケンスのリストは最後に付け 284;; てある。 285;; 286;; 「仮名漢字変換」 287;; 288;; このステージでは、前ステージで入力された文字列を仮名漢字変換する。 289;; 変換された文字列は、注目文節(反転表示)と残りの入力(下線表示)に 290;; 分けられる。注目文節に対しては以下のコマンドが使える。 291;; 292;; SPC, C-n kkc-next 293;; 次の変換候補を表示 294;; kkc-show-conversion-list-count 以上続けて打てば、変換候補リス 295;; トをエコーエリアに表示 296;; C-p kkc-prev 297;; 前の変換候補を表示 298;; kkc-show-conversion-list-count 以上続けて打てば、変換候補リス 299;; トをエコーエリアに表示 300;; l kkc-show-conversion-list-or-next-group 301;; 最高10個までの変換候補をエコーエリアに表示。 302;; 続けて打たれれば、次の10候補を表示。 303;; L kkc-show-conversion-list-or-prev-group 304;; 最高10個までの変換候補をエコーエリアに表示。 305;; 続けて打たれれば、前の10候補を表示。 306;; 0..9 kkc-select-from-list 307;; 打たれた数字の変換候補を選択 308;; H kkc-hiragana 309;; 注目文節を平仮名に変換 310;; K kkc-katakana 311;; 注目文節を片仮名に変換 312;; C-o kkc-longer 313;; 注目文節を後ろに一文字伸ばす 314;; C-i kkc-shorter 315;; 注目文節を後ろから一文字縮める 316;; C-f kkc-next-phrase 317;; 注目文節を確定させる。もし残りの入力がまだあれば、最初の文節を 318;; 選択し、それを注目文節とし、その最初の変換候補を表示する。 319;; DEL, C-c kkc-cancel 320;; 仮名漢字変換をキャンセルし、ローマ字仮名変換のステージに戻る。 321;; return kkc-terminate 322;; 全文節を確定させる。 323;; C-SPC, C-@ kkc-first-char-only 324;; 最初の文字を確定させ、残りは削除する。 325;; C-h kkc-help 326;; これらのキーバインドのリストを表示する。あ 327 328(quail-define-package 329 "japanese" "Japanese" "Aあ" 330 nil 331 "Japanese input method by Roman transliteration and Kana-Kanji conversion. 332 333When you use this input method, text entry proceeds in two stages: 334Roman-Kana transliteration and Kana-Kanji conversion. When you start 335to enter text, you are in the first stage, Roman-Kana transliteration. 336Type SPC to proceed to the next stage, Kana-Kanji conversion. 337 338:: Roman-Kana transliteration :: 339 340You can input any Hiragana character as a sequence of lower-case 341letters, Japanese punctuation characters by typing punctuation keys, 342Japanese symbols by typing `z' followed by another key. See below for 343a list of all available sequences. The characters you input are 344underlined. 345 346In addition, the following keys provide special effects: 347 348K Change Hiragana to Katakana or Katakana to Hiragana. 349qq Toggle between this input method and the input method `japanese-ascii'. 350qz Shift to the input method `japanese-zenkaku'. 351 Typing \"qh\" will put you back to this input method. 352RET Accept the current character sequence. 353SPC Proceed to the next stage, Kana-Kanji conversion. 354 355The input method `japanese-ascii' is used to enter ASCII characters. 356This is almost the same as turning off the input method. The only 357difference is that typing `qq' will put you back into the Japanese 358input method. 359 360The input method `japanese-zenkaku' is used to enter full width 361JISX0208 characters corresponding to typed ASCII characters. 362 363List of the all key sequences for Roman-Kana transliteration is shown 364at the tail. 365 366:: Kana-Kanji conversion :: 367 368You can convert the current Japanese characters (underlined) to 369Kana-Kanji mixed text. In this stage, the converted text is divided 370into two parts, the current phrase (highlighted) and the remaining 371input (underlined). The following commands can be used on the 372current phrase. 373 374SPC, C-n kkc-next 375 Show the next candidate for the current phrase. 376 If successively typed `kkc-show-conversion-list-count' times, 377 conversion candidates are shown in the echo area. 378C-p kkc-prev 379 Show the previous candidate for the current phrase. 380 If successively typed `kkc-show-conversion-list-count' times, 381 conversion candidates are shown in the echo area. 382l kkc-show-conversion-list-or-next-group 383 Show at most 10 candidates for the current phrase in echo area. 384 If typed repeatedly, show the next 10 candidates. 385L kkc-show-conversion-list-or-prev-group 386 Show at most 10 candidates for the current phrase in echo area. 387 If typed repeatedly, show the previous 10 candidates. 3880..9 kkc-select-from-list 389 Select a candidate corresponding to the typed number. 390H kkc-hiragana 391 Convert the current phrase to Hiragana 392K kkc-katakana 393 Convert the current phrase to Katakana 394C-o kkc-longer 395 Extend the current phrase; pull in the first character of 396 the remaining input. 397C-i kkc-shorter 398 Contract the current phrase; drop its last character 399 back into the remaining input. 400C-f kkc-next-phrase 401 Accept the current phrase. If there remains input, select 402 the first phrase as the current one, and show the first 403 candidate for the conversion. 404DEL, C-c kkc-cancel 405 Cancel the conversion, shift back to the Roman-Kana 406 transliteration. 407return kkc-terminate 408 Accept the whole conversion. 409C-SPC, C-@ kkc-first-char-only 410 Accept the first character of the current conversion, 411 delete the remaining input. 412C-h kkc-help 413 List these key bindings. 414" 415 nil t t nil nil nil nil nil 416 'quail-japanese-update-translation 417 '(("K" . quail-japanese-toggle-kana) 418 (" " . quail-japanese-kanji-kkc) 419 ("\C-m" . quail-no-conversion) 420 ([return] . quail-no-conversion)) 421 ) 422 423(dolist (elt quail-japanese-transliteration-rules) 424 (quail-defrule (car elt) (nth 1 elt))) 425 426(quail-define-package 427 "japanese-ascii" "Japanese" "Aa" 428 nil 429 "Temporary ASCII input mode used within the input method `japanese'. 430Type \"qq\" to go back to previous input method." 431 nil t t) 432 433(quail-define-rules ("qq" quail-japanese-switch-package)) 434 435(quail-define-package 436 "japanese-zenkaku" "Japanese" "A" 437 nil 438 "Japanese zenkaku alpha numeric character input method. 439---- Special key bindings ---- 440qq: toggle between this input method and the input method `japanese-ascii'. 441qh: shift to the input method `japanese', 442 typing \"qz\" puts you back to this input method. 443" 444 nil t t) 445 446(quail-define-rules 447 448(" " " ") ("!" "!") ("\"" "″") ("#" "#") 449("$" "$") ("%" "%") ("&" "&") ("'" "′") 450("(" "(") (")" ")") ("*" "*") ("+" "+") 451("," ",") ("-" "−") ("." ".") ("/" "/") 452("0" "0") ("1" "1") ("2" "2") ("3" "3") 453("4" "4") ("5" "5") ("6" "6") ("7" "7") 454("8" "8") ("9" "9") (":" ":") (";" ";") 455("<" "<") ("=" "=") (">" ">") ("?" "?") 456("@" "@") ("A" "A") ("B" "B") ("C" "C") 457("D" "D") ("E" "E") ("F" "F") ("G" "G") 458("H" "H") ("I" "I") ("J" "J") ("K" "K") 459("L" "L") ("M" "M") ("N" "N") ("O" "O") 460("P" "P") ("Q" "Q") ("R" "R") ("S" "S") 461("T" "T") ("U" "U") ("V" "V") ("W" "W") 462("X" "X") ("Y" "Y") ("Z" "Z") ("[" "[") 463("\\" "¥") ("]" "]") ("^" "^") ("_" "_") 464("`" "‘") ("a" "a") ("b" "b") ("c" "c") 465("d" "d") ("e" "e") ("f" "f") ("g" "g") 466("h" "h") ("i" "i") ("j" "j") ("k" "k") 467("l" "l") ("m" "m") ("n" "n") ("o" "o") 468("p" "p") ("q" "q") ("r" "r") ("s" "s") 469("t" "t") ("u" "u") ("v" "v") ("w" "w") 470("x" "x") ("y" "y") ("z" "z") ("{" "{") 471("|" "|") ("}" "}") ("~" "〜") 472 473("qq" quail-japanese-switch-package) 474("qh" quail-japanese-switch-package) 475) 476 477(defun quail-japanese-hankaku-update-translation (control-flag) 478 (setq control-flag 479 (quail-japanese-update-translation control-flag)) 480 (if (or (and (stringp quail-current-str) 481 (> (length quail-current-str) 0)) 482 (integerp quail-current-str)) 483 (setq quail-current-str (japanese-hankaku quail-current-str))) 484 control-flag) 485 486(quail-define-package 487 "japanese-hankaku-kana" 488 "Japanese" "ア" 489 nil 490 "Japanese hankaku katakana input method by Roman transliteration. 491---- Special key bindings ---- 492qq: toggle between this input method and the input method `japanese-ascii'. 493" 494 nil t t nil nil nil nil nil 495 'quail-japanese-hankaku-update-translation) 496 497(dolist (elt quail-japanese-transliteration-rules) 498 (quail-defrule (car elt) 499 (let ((trans (nth 1 elt))) 500 (when (or (stringp trans) (vectorp trans)) 501 (let ((s (japanese-hankaku (if (stringp trans) 502 trans 503 (aref trans 0))))) 504 ;; If the result of the conversion is a string 505 ;; containing more than one character, make the 506 ;; result a vector, so that quail-defrule 507 ;; recognizes the whole string is the 508 ;; translation, instead of interpreting 509 ;; individual characters as alternative 510 ;; translations. 511 (if (and (stringp s) (> (length s) 1)) 512 (setq trans (vector s)) 513 (setq trans s)))) 514 trans))) 515 516(quail-define-package 517 "japanese-hiragana" "Japanese" "あ" 518 nil 519 "Japanese hiragana input method by Roman transliteration." 520 nil t t nil nil nil nil nil 521 'quail-japanese-update-translation) 522 523;; Use the same map as that of `japanese'. 524(setcar (cdr (cdr quail-current-package)) 525 (nth 2 (assoc "japanese" quail-package-alist))) 526 527;; Update Quail translation region while converting Hiragana to Katakana. 528(defun quail-japanese-katakana-update-translation (control-flag) 529 (setq control-flag 530 (quail-japanese-update-translation control-flag)) 531 (if (or (and (stringp quail-current-str) 532 (> (length quail-current-str) 0)) 533 (integerp quail-current-str)) 534 (setq quail-current-str (japanese-katakana quail-current-str))) 535 control-flag) 536 537(quail-define-package 538 "japanese-katakana" "Japanese" "ア" 539 nil 540 "Japanese katakana input method by Roman transliteration." 541 nil t t nil nil nil nil nil 542 'quail-japanese-katakana-update-translation) 543 544(dolist (elt quail-japanese-transliteration-rules) 545 (quail-defrule (car elt) 546 (let ((trans (nth 1 elt))) 547 (cond ((stringp trans) 548 (japanese-katakana trans)) 549 ((vectorp trans) 550 (vector (japanese-katakana (aref trans 0)))) 551 (t trans))))) 552 553;;; japanese.el ends here 554