egg-980217.
[elisp/egg.git] / its-keydef.el
diff --git a/its-keydef.el b/its-keydef.el
new file mode 100644 (file)
index 0000000..90b77f1
--- /dev/null
@@ -0,0 +1,60 @@
+(eval-when-compile
+  (require 'cl))
+
+(defvar its-current-language "Japanese")
+
+(defvar its-zhuyin nil)
+(make-variable-buffer-local 'its-zhuyin)
+
+(defmacro its-make-slect-func (key name file map &optional lang zhuyin)
+  (setq name (intern (concat "its-select-" (symbol-name name)))
+       file (intern (concat "its/" (symbol-name file)))
+       map (intern (concat "its-" (symbol-name map) "-map"))
+       lang (symbol-name lang))
+  `(progn
+     (defun ,name ()
+       (interactive)
+       (cond
+       ((its-in-fence-p)
+        (its-input-end)
+        (its-put-cursor t))
+       ((egg-get-bunsetsu-info (point))
+        (egg-exit-conversion)))
+       ,(if lang `(egg-check-language ,lang))
+       (require ',file)
+       (setq its-current-map ,map)
+       ,(if lang `(setq its-current-language ,lang))
+       ,(if zhuyin `(setq its-zhuyin ,(eq zhuyin 'T)))
+       (egg-set-mode-line-title (its-get-indicator its-current-map)))
+     (define-key mule-keymap ,key ',name)))
+
+(defmacro its-do-list-make-slect-func (list)
+  (eval-when (eval compile)
+    (let (e l)
+      (while list
+       (setq e (car list))
+       (setq l (cons `(its-make-slect-func ,@(car list)) l))
+       (setq list (cdr list)))
+      (cons 'progn l))))
+
+(its-do-list-make-slect-func
+ (("Q"    upcase               ascii    up)
+  ("q"    downcase             ascii    down)
+  ("h"    hiragana             hira     hira             Japanese)
+  ("K"    katakana             kata     kata             Japanese)
+  ("x"    hankaku-katakana     hankata  han-kata         Japanese)
+  ("Z"    zenkaku-upcase       zenkaku  zenkaku-up       Japanese)
+  ("z"    zenkaku-downcase     zenkaku  zenkaku-down     Japanese)
+  ("\C-e" erpin-cn             erpin    erpin-cn         Chinese-GB NIL)
+  ("\C-p" pinyin-cn            pinyin   pinyin-cn        Chinese-GB NIL)
+  ("\C-z" zhuyin-cn            zhuyin   zhuyin-cn        Chinese-GB T)
+  ("\C-u" quanjiao-upcase-cn   quanjiao quanjiao-up-cn   Chinese-GB)
+  ("\C-d" quanjiao-downcase-cn quanjiao quanjiao-down-cn Chinese-GB)
+  ("E"    erpin-tw             erpin    erpin-tw         Chinese-CNS NIL)
+  ("P"    pinyin-tw            pinyin   pinyin-tw        Chinese-CNS NIL)
+  ("Z"    zhuyin-tw            zhuyin   zhuyin-tw        Chinese-CNS T)
+  ("U"    quanjiao-upcase-tw   quanjiao quanjiao-up-tw   Chinese-CNS)
+  ("D"    quanjiao-downcase-tw quanjiao quanjiao-down-tw Chinese-CNS)
+  ("H"    hangul               hangul   hangul           Korean)
+  ("J"    jeonkak-upcase       jeonkak  jeonkak-up       Korean)
+  ("j"    jeonkak-downcase     jeonkak  jeonkak-down     Korean)))