;; Copyright 1992 NEC Corporation, Tokyo, Japan.
;;
;; Permission to use, copy, modify, distribute and sell this software
;; and its documentation for any purpose is hereby granted without
;; fee, provided that the above copyright notice appear in all copies
;; and that both that copyright notice and this permission notice
;; appear in supporting documentation, and that the name of NEC
;; Corporation not be used in advertising or publicity pertaining to
;; distribution of the software without specific, written prior
;; permission.  NEC Corporation makes no representations about the
;; suitability of this software for any purpose.  It is provided "as
;; is" without express or implied warranty.
;;
;; NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
;; INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN 
;; NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
;; CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF 
;; USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 
;; OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 
;; PERFORMANCE OF THIS SOFTWARE. 
;; Using this customize file gives you a Japanese Input Interface
;; like EWS-UX/v R6.1 does.

;;  @(#) 102.1 $Id: jdemon.canna,v 1.1.1.1 2002/10/19 08:27:52 aida_s Exp $

; definition of modes peculier to jdaemon.

(defmode jdaemon-base-mode nil nil '(romaji kakutei))
(defmode jdaemon-kana-mode nil nil '(katakana hankaku kakutei))
(defmode jdaemon-eisu-mode nil nil '(romaji zenkaku))

(initialize-function '(japanese-mode jdaemon-base-mode))

(setq romkana-table "jdaemon.cbp")

(use-dictionary
 "iroha"
 "fuzokugo"
 "hojomwd"
 "hojoswd"
 :bushu "bushu"
 :user  "user"
 )

(setq cursor-wrap          t)	; default t
(setq select-direct        t)	; default t
(setq numerical-key-select t)	; default t
(setq character-based-move t)	; default t
(setq reverse-widely       t)	; default nil
(setq break-into-roman     nil)	; default nil
(setq quit-if-end-of-ichiran t)	; default nil
(setq kakutei-if-end-of-bunsetsu t)	; default nil
(setq stay-after-validate  nil)	; default t

;;  setting for mode string

(set-mode-display 'jdaemon-base-mode      "")
(set-mode-display 'jdaemon-kana-mode      "Ｒ")
(set-mode-display 'jdaemon-eisu-mode      "　全角逐次かなシ")

(set-mode-display 'alpha-mode             nil)
(set-mode-display 'empty-mode             "Ｒ全角逐次かなシ")
(set-mode-display 'hex-mode               "Ｒ全角１６進　シ")
(set-mode-display 'bushu-mode             "Ｒ全角部首")
(set-mode-display 'henkan-nyuuryoku-mode  "Ｒ全角逐次かなシ")
(set-mode-display 'zen-hira-henkan-mode   "Ｒ全角逐次かなシ")
(set-mode-display 'zen-kata-henkan-mode   "Ｒ全角逐次カナシ")
(set-mode-display 'zen-hira-kakutei-mode  nil)
(set-mode-display 'zen-kata-kakutei-mode  nil)
(set-mode-display 'han-kata-kakutei-mode  "Ｒ")
(set-mode-display 'zen-alpha-henkan-mode  "　全角逐次かなシ")
(set-mode-display 'han-alpha-kakutei-mode "")
(set-mode-display 'kigou-mode             "Ｒ全角記号　　シ")
(set-mode-display 'mojishu-mode           nil)
(set-mode-display 'tankouho-mode          nil)
(set-mode-display 'ichiran-mode           nil)
(set-mode-display 'yes-no-mode            nil)
(set-mode-display 'extend-mode            nil)
(set-mode-display 'russian-mode           "Ｒ全角ロシア　シ")
(set-mode-display 'greek-mode             "Ｒ全角ギリシャシ")
(set-mode-display 'line-mode              "Ｒ全角罫線　　シ")
(set-mode-display 'changing-server-mode   nil)
(set-mode-display 'henkan-method-mode     nil)
(set-mode-display 'delete-dic-mode        nil)
(set-mode-display 'touroku-mode           "Ｒ全角登録　　シ")
(set-mode-display 'touroku-hinshi-mode    "Ｒ全角登録品詞シ")
(set-mode-display 'touroku-dic-mode       "Ｒ全角登録辞書シ")
(set-mode-display 'quoted-insert-mode     "Ｒ全角ｑ　　　シ")
(set-mode-display 'bubun-muhenkan-mode    "Ｒ全角逐次編集シ")
(set-mode-display 'han-kata-henkan-mode   nil)
(set-mode-display 'han-alpha-henkan-mode  nil)
(set-mode-display 'mount-dic-mode         nil)

;;  setting for keymapping

(global-unbind-key-function 'quoted-insert)
(global-unbind-key-function 'extend)
(global-unbind-key-function 'shrink)
(global-unbind-key-function 'alpha-mode)
(global-unbind-key-function 'quoted-insert)
(global-unbind-key-function 'forward)
(global-unbind-key-function 'backward)
(global-unbind-key-function 'previous)
(global-unbind-key-function 'next)
(global-unbind-key-function 'beginning-of-line)
(global-unbind-key-function 'end-of-line)
(global-unbind-key-function 'delete-next)
(global-unbind-key-function 'kill-to-end-of-line)
(global-unbind-key-function 'henkan)
(global-unbind-key-function 'quit)
(global-unbind-key-function 'japanese-mode)

(global-set-key " "         'self-insert)

(global-set-key "\C-x"      'henkan)
(global-set-key "\Down"     'henkan)
(global-set-key "\Xfer"     'henkan)
(global-set-key "\C-o"      'forward)
(global-set-key "\C-n"      'backward)
(global-set-key "\C-c"      'quit)

(setq toggle-r 'base-kana-eisu-toggle)
;(setq toggle-e (sequence
;		'base-hiragana-katakana-toggle
;		'base-kakutei-henkan-toggle
;		'base-zenkaku-hankaku-toggle
;			 ))

(let ((mode 'empty-mode))
  (set-key mode "\C-r" 'jdaemon-eisu-mode)
  (set-key mode "\C-e" 'jdaemon-kana-mode)
  (set-key mode "\C-b" 'bushu-mode)
  (set-key mode "\C-w" 'hex-mode)
  (set-key mode "\C-k" 'base-hiragana-katakana-toggle)
  )

(let ((mode 'yomi-mode))
  (set-key mode "\C-r" toggle-r)
  (set-key mode "\C-e" '(kakutei jdaemon-kana-mode)) ; jdaemon-base の時あり
  (set-key mode "\C-k" 'base-hiragana-katakana-toggle)
  )

(let ((mode 'jdaemon-eisu-mode))
  (set-key mode "\C-r" 'henkan-nyuuryoku-mode)
  (set-key mode "\C-e" 'jdaemon-base-mode)
  (set-key mode "\C-b" 'bushu-mode)
  (set-key mode "\C-w" 'hex-mode)
  )

(let ((mode 'jdaemon-kana-mode))
  (set-key mode "\C-r" 'jdaemon-base-mode)
  (set-key mode "\C-e" 'henkan-nyuuryoku-mode)
  )

(let ((mode 'jdaemon-base-mode))
  (set-key mode "\C-r" 'jdaemon-kana-mode)
  (set-key mode "\C-e" 'jdaemon-eisu-mode)
  )

(let ((mode 'yomi-mode))
  (set-key mode "\C-a" 'hiragana)
  (set-key mode "\C-z" 'katakana)
  (set-key mode "." (sequence 'self-insert 'henkan))
  (set-key mode "," (sequence 'self-insert 'henkan))
  (set-key mode ">" (sequence 'self-insert 'henkan))
  (set-key mode "<" (sequence 'self-insert 'henkan))
  (set-key mode "!" (sequence 'self-insert 'henkan))
  (set-key mode "?" (sequence 'self-insert 'henkan))
  )

(let ((mode 'mojishu-mode))
  (set-key mode "\Right" 'extend)
  (set-key mode "\Left"  'shrink)
  (set-key mode "\C-a"   'hiragana)
  (set-key mode "\C-z"   'katakana)
  )

(let ((mode 'tankouho-mode))
  (set-key mode "\Right" 'extend)
  (set-key mode "\Left"  'shrink)
  (set-key mode "\C-a"   'hiragana)
  (set-key mode "\C-z"   'katakana)
  (set-key mode "\Xfer"  'kouho-ichiran)
  (set-key mode "\Down"  'kouho-ichiran)
  (set-key mode "\C-h"   'previous)
  )

(let ((mode 'ichiran-mode))
  (set-key mode "0"     'quit)
  (set-key mode "\C-h"  'previous)
  (set-key mode "\Down" 'next)
  (set-key mode "\Up"   'previous)
  )
