;; Basic Roma-to-HankakuKana (jisx0201) Translation Table for Egg

;; This file is part of Egg on Mule (Japanese Environment)

;; Egg is distributed in the forms of patches to GNU
;; Emacs under the terms of the GNU EMACS GENERAL PUBLIC
;; LICENSE which is distributed along with GNU Emacs by the
;; Free Software Foundation.

;; Egg is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied
;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
;; PURPOSE.  See the GNU EMACS GENERAL PUBLIC LICENSE for
;; more details.

;; You should have received a copy of the GNU EMACS GENERAL
;; PUBLIC LICENSE along with Nemacs; see the file COPYING.
;; If not, write to the Free Software Foundation, 675 Mass
;; Ave, Cambridge, MA 02139, USA.

;;; 92.9.24  created for Mule Ver.0.9.6 by K.Shibata <shibata@sgi.co.jp>

(require 'japan-util)

(its-define-mode "roma-han-kata"  "ｱｧ" t)

(egg-dolist (aa '("k" "s" "t" "h" "y" "r" "w" "g" "z" "d" "b"
		  "p" "c" "f" "j" "v"))
  (its-defrule (concat aa aa) "ｯ" aa))

(its-defrule "tch"  "ｯ" "ch")

(egg-dolist (q1 '("b" "m" "p"))
  (its-defrule (concat "m" q1) "ﾝ" q1))

(its-defrule "N" "ﾝ")

(defvar enable-double-n-syntax nil "*Enable \"nn\" input for \"ﾝ\" ")

(its-defrule-conditional "n"
  ((not enable-double-n-syntax) "ﾝ")
  (t nil))
(its-defrule-conditional "nn"
  ( enable-double-n-syntax "ﾝ")
  (t nil))

(its-defrule "n'" "ﾝ")

(let ((small '"x" ))
  (its-defrule (concat small "a") "ｧ")
  (its-defrule (concat small "i") "ｨ")
  (its-defrule (concat small "u") "ｩ")
  (its-defrule (concat small "e") "ｪ")
  (its-defrule (concat small "o") "ｫ")
  (its-defrule (concat small "ya") "ｬ")
  (its-defrule (concat small "yu") "ｭ")
  (its-defrule (concat small "yo") "ｮ")
  (its-defrule (concat small "tu") "ｯ")
  (its-defrule (concat small "tsu") "ｯ")
  )


(its-defrule   "a"    "ｱ")
(its-defrule   "i"    "ｲ")
(its-defrule   "u"    "ｳ")
(its-defrule   "e"    "ｴ")
(its-defrule   "o"    "ｵ")
(its-defrule   "ka"   "ｶ")
(its-defrule   "ki"   "ｷ")
(its-defrule   "ku"   "ｸ")
(its-defrule   "ke"   "ｹ")
(its-defrule   "ko"   "ｺ")
(its-defrule   "kya"  "ｷｬ")
(its-defrule   "kyu"  "ｷｭ")
(its-defrule   "kye"  "ｷｪ")
(its-defrule   "kyo"  "ｷｮ")
(its-defrule   "sa"   "ｻ")
(its-defrule   "si"   "ｼ")
(its-defrule   "su"   "ｽ")
(its-defrule   "se"   "ｾ")
(its-defrule   "so"   "ｿ")
(its-defrule   "sya"  "ｼｬ")
(its-defrule   "syu"  "ｼｭ")
(its-defrule   "sye"  "ｼｪ")
(its-defrule   "syo"  "ｼｮ")
(its-defrule   "sha"  "ｼｬ")
(its-defrule   "shi"  "ｼ")
(its-defrule   "shu"  "ｼｭ")
(its-defrule   "she"  "ｼｪ")
(its-defrule   "sho"  "ｼｮ")
(its-defrule   "ta"   "ﾀ")
(its-defrule   "ti"   "ﾁ")
(its-defrule   "tu"   "ﾂ")
(its-defrule   "te"   "ﾃ")
(its-defrule   "to"   "ﾄ")
(its-defrule   "tya"  "ﾁｬ")
(its-defrule   "tyi"  "ﾃｨ")
(its-defrule   "tyu"  "ﾁｭ")
(its-defrule   "tye"  "ﾁｪ")
(its-defrule   "tyo"  "ﾁｮ")
(its-defrule   "tsu"  "ﾂ")
(its-defrule   "cha"  "ﾁｬ")
(its-defrule   "chi"  "ﾁ")
(its-defrule   "chu"  "ﾁｭ")
(its-defrule   "che"  "ﾁｪ")
(its-defrule   "cho"  "ﾁｮ")
(its-defrule   "na"   "ﾅ")
(its-defrule   "ni"   "ﾆ")
(its-defrule   "nu"   "ﾇ")
(its-defrule   "ne"   "ﾈ")
(its-defrule   "no"   "ﾉ")
(its-defrule   "nya"  "ﾆｬ")
(its-defrule   "nyu"  "ﾆｭ")
(its-defrule   "nye"  "ﾆｪ")
(its-defrule   "nyo"  "ﾆｮ")
(its-defrule   "ha"   "ﾊ")
(its-defrule   "hi"   "ﾋ")
(its-defrule   "hu"   "ﾌ")
(its-defrule   "he"   "ﾍ")
(its-defrule   "ho"   "ﾎ")
(its-defrule   "hya"  "ﾋｬ")
(its-defrule   "hyu"  "ﾋｭ")
(its-defrule   "hye"  "ﾋｪ")
(its-defrule   "hyo"  "ﾋｮ")
(its-defrule   "fa"   "ﾌｧ")
(its-defrule   "fi"   "ﾌｨ")
(its-defrule   "fu"   "ﾌ")
(its-defrule   "fe"   "ﾌｪ")
(its-defrule   "fo"   "ﾌｫ")
(its-defrule   "ma"   "ﾏ")
(its-defrule   "mi"   "ﾐ")
(its-defrule   "mu"   "ﾑ")
(its-defrule   "me"   "ﾒ")
(its-defrule   "mo"   "ﾓ")
(its-defrule   "mya"  "ﾐｬ")
(its-defrule   "myu"  "ﾐｭ")
(its-defrule   "mye"  "ﾐｪ")
(its-defrule   "myo"  "ﾐｮ")
(its-defrule   "ya"   "ﾔ")
(its-defrule   "yi"   "ｲ")
(its-defrule   "yu"   "ﾕ")
(its-defrule   "ye"   "ｲｪ")
(its-defrule   "yo"   "ﾖ")
(its-defrule   "ra"   "ﾗ")
(its-defrule   "ri"   "ﾘ")
(its-defrule   "ru"   "ﾙ")
(its-defrule   "re"   "ﾚ")
(its-defrule   "ro"   "ﾛ")
(its-defrule   "la"   "ﾗ")
(its-defrule   "li"   "ﾘ")
(its-defrule   "lu"   "ﾙ")
(its-defrule   "le"   "ﾚ")
(its-defrule   "lo"   "ﾛ")
(its-defrule   "rya"  "ﾘｬ")
(its-defrule   "ryu"  "ﾘｭ")
(its-defrule   "rye"  "ﾘｪ")
(its-defrule   "ryo"  "ﾘｮ")
(its-defrule   "lya"  "ﾘｬ")
(its-defrule   "lyu"  "ﾘｭ")
(its-defrule   "lye"  "ﾘｪ")
(its-defrule   "lyo"  "ﾘｮ")
(its-defrule   "wa"   "ﾜ")
(its-defrule   "wu"   "ｳ")
(its-defrule   "wo"   "ｦ")
(its-defrule   "ga"   "ｶﾞ")
(its-defrule   "gi"   "ｷﾞ")
(its-defrule   "gu"   "ｸﾞ")
(its-defrule   "ge"   "ｹﾞ")
(its-defrule   "go"   "ｺﾞ")
(its-defrule   "gya"  "ｷﾞｬ")
(its-defrule   "gyu"  "ｷﾞｭ")
(its-defrule   "gye"  "ｷﾞｪ")
(its-defrule   "gyo"  "ｷﾞｮ")
(its-defrule   "za"   "ｻﾞ")
(its-defrule   "zi"   "ｼﾞ")
(its-defrule   "zu"   "ｽﾞ")
(its-defrule   "ze"   "ｾﾞ")
(its-defrule   "zo"   "ｿﾞ")
(its-defrule   "zya"  "ｼﾞｬ")
(its-defrule   "zyu"  "ｼﾞｭ")
(its-defrule   "zye"  "ｼﾞｪ")
(its-defrule   "zyo"  "ｼﾞｮ")
(its-defrule   "ja"   "ｼﾞｬ")
(its-defrule   "ji"   "ｼﾞ")
(its-defrule   "ju"   "ｼﾞｭ")
(its-defrule   "je"   "ｼﾞｪ")
(its-defrule   "jo"   "ｼﾞｮ")
(its-defrule   "da"   "ﾀﾞ")
(its-defrule   "di"   "ﾁﾞ")
(its-defrule   "du"   "ﾂﾞ")
(its-defrule   "de"   "ﾃﾞ")
(its-defrule   "do"   "ﾄﾞ")
(its-defrule   "dya"  "ﾁﾞｬ")
(its-defrule   "dyi"  "ﾁﾞｨ")
(its-defrule   "dyu"  "ﾁﾞｭ")
(its-defrule   "dye"  "ﾁﾞｪ")
(its-defrule   "dyo"  "ﾁﾞｮ")
(its-defrule   "ba"   "ﾊﾞ")
(its-defrule   "bi"   "ﾋﾞ")
(its-defrule   "bu"   "ﾌﾞ")
(its-defrule   "be"   "ﾍﾞ")
(its-defrule   "bo"   "ﾎﾞ")
(its-defrule   "va"   "ｳﾞｧ")
(its-defrule   "vi"   "ｳﾞｨ")
(its-defrule   "vu"   "ｳﾞ")
(its-defrule   "ve"   "ｳﾞｪ")
(its-defrule   "vo"   "ｳﾞｫ")
(its-defrule   "bya"  "ﾋﾞｬ")
(its-defrule   "byu"  "ﾋﾞｭ")
(its-defrule   "bye"  "ﾋﾞｪ")
(its-defrule   "byo"  "ﾋﾞｮ")
(its-defrule   "pa"   "ﾊﾟ")
(its-defrule   "pi"   "ﾋﾟ")
(its-defrule   "pu"   "ﾌﾟ")
(its-defrule   "pe"   "ﾍﾟ")
(its-defrule   "po"   "ﾎﾟ")
(its-defrule   "pya"  "ﾋﾟｬ")
(its-defrule   "pyu"  "ﾋﾟｭ")
(its-defrule   "pye"  "ﾋﾟｪ")
(its-defrule   "pyo"  "ﾋﾟｮ")
(its-defrule   "kwi"  "ｸｨ")
(its-defrule   "kwu"  "ｸ")
(its-defrule   "kwe"  "ｸｪ")
(its-defrule   "kwo"  "ｸｫ")
(its-defrule   "gwi"  "ｸﾞｨ")
(its-defrule   "gwu"  "ｸﾞ")
(its-defrule   "gwe"  "ｸﾞｪ")
(its-defrule   "gwo"  "ｸﾞｫ")
(its-defrule   "tsa"  "ﾂｧ")
(its-defrule   "tsi"  "ﾂｨ")
(its-defrule   "tse"  "ﾂｪ")
(its-defrule   "tso"  "ﾂｫ")
(its-defrule   "xka"  "ｶ")
(its-defrule   "xke"  "ｹ")
(its-defrule   "xti"  "ﾃｨ")
(its-defrule   "xdi"  "ﾁﾞｨ")
(its-defrule   "xdu"  "ﾄﾞｩ")
(its-defrule   "xde"  "ﾁﾞｪ")
(its-defrule   "xdo"  "ﾄﾞｫ")
(its-defrule   "xwi"  "ｳｨ")
(its-defrule   "xwe"  "ｳｪ")
(its-defrule   "xwo"  "ｳｫ")

(its-defrule   "-"   "ｰ")
(its-defrule   "["    "｢")
(its-defrule   "]"    "｣")
(its-defrule   "z/"   "･")

(defvar use-kuten-for-period t "*ﾋﾟﾘｵﾄﾞを句点に変換する")
(defvar use-touten-for-comma t "*ｺﾝﾏを読点に変換する")

(its-defrule-conditional "."
  (use-kuten-for-period "｡")
  (t "."))

(its-defrule-conditional ","
  (use-touten-for-comma "､")
  (t ","))

(its-defrule (concat zenkaku-escape ",")  "，")
(its-defrule (concat zenkaku-escape ".")  "．")

(defun its:select-hankaku-katakana ()
  (interactive)
  (its:select-mode "roma-han-kata"))

(define-key mule-keymap "x" 'its:select-hankaku-katakana)
(define-key fence-mode-map "\e\C-x" 'its:select-hankaku-katakana)

;;;
;;;  JISX 0201 fence mode
;;;

(defun fence-hankaku-katakana  ()
  (interactive)
  (japanese-katakana-region egg:*region-start* egg:*region-end* t))

(defun fence-katakana  ()
  (interactive)
  (japanese-katakana-region egg:*region-start* egg:*region-end*))

(defun fence-hiragana  ()
  (interactive)
  (japanese-katakana-region egg:*region-start* egg:*region-end*)
  (japanese-hiragana-region egg:*region-start* egg:*region-end*))

(define-key fence-mode-map "\ex"  'fence-hankaku-katakana)
