egg-980217.
[elisp/egg.git] / its-keydef.el
1 (eval-when-compile
2   (require 'cl))
3
4 (defvar its-current-language "Japanese")
5
6 (defvar its-zhuyin nil)
7 (make-variable-buffer-local 'its-zhuyin)
8
9 (defmacro its-make-slect-func (key name file map &optional lang zhuyin)
10   (setq name (intern (concat "its-select-" (symbol-name name)))
11         file (intern (concat "its/" (symbol-name file)))
12         map (intern (concat "its-" (symbol-name map) "-map"))
13         lang (symbol-name lang))
14   `(progn
15      (defun ,name ()
16        (interactive)
17        (cond
18         ((its-in-fence-p)
19          (its-input-end)
20          (its-put-cursor t))
21         ((egg-get-bunsetsu-info (point))
22          (egg-exit-conversion)))
23        ,(if lang `(egg-check-language ,lang))
24        (require ',file)
25        (setq its-current-map ,map)
26        ,(if lang `(setq its-current-language ,lang))
27        ,(if zhuyin `(setq its-zhuyin ,(eq zhuyin 'T)))
28        (egg-set-mode-line-title (its-get-indicator its-current-map)))
29      (define-key mule-keymap ,key ',name)))
30
31 (defmacro its-do-list-make-slect-func (list)
32   (eval-when (eval compile)
33     (let (e l)
34       (while list
35         (setq e (car list))
36         (setq l (cons `(its-make-slect-func ,@(car list)) l))
37         (setq list (cdr list)))
38       (cons 'progn l))))
39
40 (its-do-list-make-slect-func
41  (("Q"    upcase               ascii    up)
42   ("q"    downcase             ascii    down)
43   ("h"    hiragana             hira     hira             Japanese)
44   ("K"    katakana             kata     kata             Japanese)
45   ("x"    hankaku-katakana     hankata  han-kata         Japanese)
46   ("Z"    zenkaku-upcase       zenkaku  zenkaku-up       Japanese)
47   ("z"    zenkaku-downcase     zenkaku  zenkaku-down     Japanese)
48   ("\C-e" erpin-cn             erpin    erpin-cn         Chinese-GB NIL)
49   ("\C-p" pinyin-cn            pinyin   pinyin-cn        Chinese-GB NIL)
50   ("\C-z" zhuyin-cn            zhuyin   zhuyin-cn        Chinese-GB T)
51   ("\C-u" quanjiao-upcase-cn   quanjiao quanjiao-up-cn   Chinese-GB)
52   ("\C-d" quanjiao-downcase-cn quanjiao quanjiao-down-cn Chinese-GB)
53   ("E"    erpin-tw             erpin    erpin-tw         Chinese-CNS NIL)
54   ("P"    pinyin-tw            pinyin   pinyin-tw        Chinese-CNS NIL)
55   ("Z"    zhuyin-tw            zhuyin   zhuyin-tw        Chinese-CNS T)
56   ("U"    quanjiao-upcase-tw   quanjiao quanjiao-up-tw   Chinese-CNS)
57   ("D"    quanjiao-downcase-tw quanjiao quanjiao-down-tw Chinese-CNS)
58   ("H"    hangul               hangul   hangul           Korean)
59   ("J"    jeonkak-upcase       jeonkak  jeonkak-up       Korean)
60   ("j"    jeonkak-downcase     jeonkak  jeonkak-down     Korean)))