This commit was manufactured by cvs2svn to create branch 'gniibe'.
authortomo <tomo>
Tue, 23 Jun 1998 04:57:41 +0000 (04:57 +0000)
committertomo <tomo>
Tue, 23 Jun 1998 04:57:41 +0000 (04:57 +0000)
18 files changed:
ChangeLog
egg-cnv.el
egg-com.el
egg-edep.el [new file with mode: 0644]
egg-mlh.el
egg.el
egg/canna.el [new file with mode: 0644]
egg/sj3.el
egg/sj3rpc.el
egg/wnn.el
euc-china.el [new file with mode: 0644]
euc-cn.el [new file with mode: 0644]
its-keydef.el
its.el
its/hangul.el
its/hira.el
its/pinyin.el
leim-list-egg.el

index 3861686..9989248 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,83 +1,3 @@
-1998-03-03  KATAYAMA Yoshio <kate@pfu.co.jp>
-
-       *its.el (its-get-keyseq-syl): Compensate when DSYL has back.
-       (its-DSYL-with-back-p): New function. Return t when DSYL has back.
-       (its-concrete-DSYL-p): New function. Return t when DSYL is cons
-       form which means input is not continued after DSYL was created.
-       (its-make-concrete-DSYL): New function.
-       (its-self-insert-char): Make DSYL to ``concrete-DSYL'' if cursor
-       is t which means input is not continued.
-       (its-input): Test input key is whether acceptable or not when
-       its-barf-on-invalid-keyseq is non-nil.
-       (its-input-to-vsyl): Set cursor status, not just returning it.
-       (its-state-machine its-state-machine-keyseq): Make sure to issue
-       ``DSYL-with-back'' when syllable is decided by the rule with back.
-       ``test mode'' is added.
-       (its-keyseq-acceptable-p): New function.
-       (its-forward-SYL): The args order of put-text-property was wrong.
-       (its-delete-backward-SYL-by-keystroke): New function.
-       (its-delete-backward-within-SYL): ``delete-by-keystroke'' mode
-       did not work when syllable is decided by the rule with back.
-       Deletion limit is extended to outside of SYL (meaning of
-       ``within-SYL'' is changed to ``deletion starts within SYL).
-       (its-transpose-chars): Fixed up.
-       (its-in-fence-p): Confuse at openning fence.
-
-1998-02-25  KATAYAMA Yoshio <kate@pfu.co.jp>
-
-       * its.el (its-put-cursor): Enable its-map change in fence mode.
-
-       * its-keydef.el (its-make-select-func): Same as above.
-
-1998-02-25  KATAYAMA Yoshio <kate@pfu.co.jp>
-
-       * its.el (its-set-cursor-status): New function.
-       (its-setup-fence-mode): New function.
-       (its-insert-fence-open its-insert-fence-close): Deleted.
-       (its-start, its-restart, its-self-insert-char): Avoid fence
-       destruction on its-barf.
-       (its-input-to-vsyl, its-state-machine, its-state-machine-keyseq,
-       its-buffer-ins/del-SYL, its-ins/del-SYL-batch): Update cursor
-       status on updating syllables.
-       (its-input-error): New function to realize doc-string of
-       its-barf-on-invalid-keyseq.
-
-       * egg.el (egg-mode): Don't use egg-mode-line-title which cause
-       wrong-type-argument at isearch.  Bind its-select-XXX to key only
-       when modefull is select.
-
-       * egg-mlh.el (mlh-hangul, mlh-zhongwen, mlh-zhongwen-tw): Same
-       as above.
-
-       * its-keydef.el (its-make-select-func): Same as above.
-
-       * leim-list-egg.el: Same as above.
-
-1998-02-24  KATAYAMA Yoshio <kate@pfu.co.jp>
-
-       * its.el (its-state-machine-keyseq): Remove binding
-       its-barf-on-invalid-keyseq to nil.
-       (its-ins/del-SYL-batch): Avoide altering its-XXX-map.
-       (its-translate-region-internal): its-translation-result's data
-       type is changed to string.
-
-       * egg-cnv.el (egg-convert-region): Gather contiguous same
-       language part.
-
-1998-02-21  KATAYAMA Yoshio <kate@pfu.co.jp>
-
-       * its.el (its-ins/del-SYL-batch): Set its-lang property.
-       (its-translate-region): Remove its-lang property from translated
-       text.
-       (its-translate-region-internal): New function.  Retain its-lang
-       property on translated text.
-
-       * egg-mlh.el (mlh-space-bar-backward-henkan): Force base language
-       to Japanese.
-
-       (mlh-hangul mlh-zhongwen-tw mlh-zhongwen): New functions for
-       conversion functions.
-
 1998-02-20  KATAYAMA Yoshio <kate@pfu.co.jp>
 
        * its.el (its-restart): New function.
index b85cd04..8c499b3 100644 (file)
 
 ;;; Code:
 
-(defvar egg-current-language)
-(make-variable-buffer-local 'egg-current-language)
-(put 'egg-current-language 'permanent-local t)
-
 (defsubst egg-bunsetsu-info () 'intangible)
 
 (defun egg-get-bunsetsu-info (p)
-  (let ((bunsetsu-info (get-text-property p (egg-bunsetsu-info))))
-    (if bunsetsu-info
-       (setq egg-conversion-backend (get-text-property p 'egg-backend)
-             egg-current-language (get-text-property p 'egg-lang)))
-    bunsetsu-info))
+  (let ((info (get-text-property p (egg-bunsetsu-info))))
+    (cond
+     ((consp info)
+      (setq egg-conversion-backend (car info))
+      (cdr info)))))
 ;;
 
-(defconst egg-conversion-backend-other-languages
-  [ egg-init-other-languages
-
-        egg-start-conversion-other-languages
-      egg-get-bunsetsu-converted-other-languages
-      egg-get-bunsetsu-source-other-languages
-      egg-list-candidates-other-languages
-          egg-get-number-of-candidates-other-languages
-          egg-get-current-candidate-number-other-languages
-          egg-get-all-candidates-other-languages
-          egg-decide-candidate-other-languages
-      egg-change-bunsetsu-length-other-languages
-    egg-end-conversion-other-languages
-    nil
-
-    egg-fini-other-languages
- ])
-
-(defun egg-init-other-languages ()
-  )
-
-(defun egg-start-conversion-other-languages (yomi-string language)
-  (list yomi-string))
-(defun egg-get-bunsetsu-converted-other-languages (bunsetsu-info)
-  bunsetsu-info)
-(defun egg-get-bunsetsu-source-other-languages (bunsetsu-info)
-  bunsetsu-info)
-(defun egg-list-candidates-other-languages (bunsetsu-info prev-bunsetsu-info)
-  1)
-(defun egg-get-number-of-candidates-other-languages (bunsetsu-info)
-  1)
-(defun egg-get-current-candidate-number-other-languages (bunsetsu-info)
-  0)
-(defun egg-get-all-candidates-other-languages (bunsetsu-info)
-  (list bunsetsu-info))
-(defun egg-decide-candidate-other-languages (bunsetsu-info candidate-pos)
-  bunsetsu-info)
-(defun egg-change-bunsetsu-length-other-languages (b0 b1 b2 len)
-  (let ((s (concat b1 b2)))
-    (set-text-properties 0 (length s) nil s)
-    (if (= len (length s))
-       (list s)
-      (list (substring s 0 len) (substring s len)))))
-(defun egg-end-conversion-other-languages (bunsetsu-info-list)
-  nil)
-(defun egg-fini-other-languages (language)
-  nil)
-
 (defvar egg-conversion-backend-alist nil)
 (make-variable-buffer-local 'egg-conversion-backend-alist)
 (defvar egg-conversion-backend nil)
 (defvar egg-finalize-backend-alist nil)
 
 (defun egg-set-current-backend (language)
-  (setq egg-conversion-backend
-       (cdr (assoc language egg-conversion-backend-alist)))
-  (if (null egg-conversion-backend)
-      (setq egg-conversion-backend egg-conversion-backend-other-languages)))
+  (let ((backend (assoc lang  egg-conversion-backend-alist)))
+    (if (null backend)
+       (error "%S is not supported" lang)
+      (setq egg-conversion-backend (cdr backend)))))
 
 (defun egg-initialize-backend (language)
   (egg-set-current-backend language)
   (funcall (aref egg-conversion-backend 9) b0 b1 b2 len))
 (defun egg-end-conversion (bunsetsu-info-list)
   (funcall (aref egg-conversion-backend 10) bunsetsu-info-list))
-(defun egg-start-reverse-conversion (yomi-string language)
-  (egg-set-current-backend language)
-  (if (aref egg-conversion-backend 11)
-      (funcall (aref egg-conversion-backend 11) yomi-string language)
-    (beep)))
 
 (defun egg-finalize-backend ()
   (let ((alist egg-finalize-backend-alist))
       (funcall (car (car (car alist))) (cdr (car (car alist))))
       (setq alist (cdr alist)))))
 
-(defun egg-set-conversion-backend (backend langs &optional force)
-  (let (pair)
-    (if backend
-       (setq egg-conversion-backend backend)
-      (setq backend egg-conversion-backend))
-    (while langs
-      (setq pair (assoc (car langs) egg-conversion-backend-alist))
-      (cond
-       ((null pair)
-       (setq egg-conversion-backend-alist
-             (cons (cons (car langs) backend) egg-conversion-backend-alist)))
-       (force
-       (setcdr pair backend)))
-      (setq pair (cons (aref backend (1- (length backend))) (car langs)))
-      (if (null (assoc pair egg-finalize-backend-alist))
-         (setq egg-finalize-backend-alist
-               (cons (list pair) egg-finalize-backend-alist)))
-      (setq langs (cdr langs)))))
+(defmacro egg-set-conversion-backend-internal (backend langs &optional force)
+  `(let ((l ,langs) pair)
+     (while l
+       (setq pair (assoc (car l) egg-conversion-backend-alist))
+       (if (null pair)
+          (setq egg-conversion-backend-alist 
+                (cons (cons (car l) ,backend)
+                      egg-conversion-backend-alist))
+        ,(if force `(setcdr pair ,backend)))
+       (setq pair (cons (aref ,backend 11) (car l)))
+       (if (null (assoc pair egg-finalize-backend-alist))
+          (setq egg-finalize-backend-alist
+                (cons (list pair) egg-finalize-backend-alist)))
+       (setq l (cdr l)))))
+
+(defun egg-set-conversion-backend (backend curent-langs other-langs)
+  (egg-set-conversion-backend-internal backend curent-langs t)
+  (egg-set-conversion-backend-internal backend other-langs))
 \f
-(defvar egg-conversion-open  "|"  "*\e$B%U%'%s%9$N;OE@$r<($9J8;zNs\e(B (1 \e$BJ8;z0J>e\e(B)")
-(defvar egg-conversion-close "|"  "*\e$B%U%'%s%9$N=*E@$r<($9J8;zNs\e(B (1 \e$BJ8;z0J>e\e(B)")
-(defvar egg-conversion-face  nil  "*\e$B%U%'%s%9I=<($KMQ$$$k\e(B face \e$B$^$?$O\e(B nil")
+(defvar egg-conversion-open "|")
+(defvar egg-conversion-close "|")
 (defvar egg-conversion-separator " ")
 
-(defun egg-get-conversion-face ()
-  (let ((face (and (listp egg-conversion-face)
-                  (or (assoc egg-current-language egg-conversion-face)
-                      (assoc t egg-conversion-face)))))
-    (if face (cdr face) egg-conversion-face)))
-
 ;;
 (defun egg-convert-region (start end)
   (interactive "r")
-  (if (>= start end)
-      ;; nothing to do
-      nil
-    (remove-text-properties start end '(read-only nil intangible nil))
-    (goto-char start)
-    (insert egg-conversion-open)
-    (let ((inhibit-read-only t)
-         (max (make-marker))
-         bunsetsu-info-list contin p s e result)
-      (setq p (+ (point) (- end start)))
-      (set-text-properties start (point)
+  (let (bunsetsu-info-list lang contin p s e)
+    (save-restriction
+      (narrow-to-region start end)
+      (goto-char start)
+      (insert egg-conversion-open)
+      (add-text-properties start (point)
                           (list
-                           'read-only t
                            'egg-start t
-                           'egg-source (buffer-substring (point) p)))
+                           'egg-source (buffer-substring (point)
+                                                         (point-max))))
       (if egg-conversion-face
-         (put-text-property start (point) 'invisible t))
+          (put-text-property start (point) 'invisible t))
       (setq start (point))
-      (goto-char p)
-      (insert egg-conversion-close)
-      (set-text-properties p (point) '(read-only t rear-nonsticky t egg-end t))
-      (if egg-conversion-face
-         (put-text-property p (point) 'invisible t))
-      (set-marker max p)
-      (egg-separate-languages start max)
+      (egg-separate-languages start (point-max))
       (goto-char start)
-      (while (< (point) max)
-       (setq egg-current-language (get-text-property (point) 'egg-lang)
-             s (point)
-             e (point))
-       (while (and (< e max)
-                   (equal egg-current-language
-                          (get-text-property e 'egg-lang)))
-         (setq e (next-single-property-change e 'egg-lang nil max)))
-       (condition-case result
-           (setq bunsetsu-info-list
-                 (egg-start-conversion
-                  (buffer-substring-no-properties s e)
-                  egg-current-language))
-         (error
-          (setq egg-conversion-backend egg-conversion-backend-other-languages
-                bunsetsu-info-list (egg-start-conversion-other-languages
-                                    (buffer-substring-no-properties s e)
-                                    egg-current-language))
-          (message "egg %s backend: %s" egg-current-language (cadr result))))
-       (setq contin (< e max))
+      (while (< (point) (point-max))
+       (setq lang (get-text-property (point) 'egg-lang))
+       (setq s (point)
+             e (next-single-property-change s 'egg-lang nil (point-max)))
+       (setq bunsetsu-info-list
+             (egg-start-conversion (buffer-substring s e) lang))
+       (setq contin (< e (point-max)))
        (delete-region s e)
        (egg-insert-bunsetsu-list bunsetsu-info-list
-                                 (if (< (point) max) 'contine t)))
-      (set-marker max nil)
-      (goto-char start))))
+                                 (if (< (point) (point-max)) 'contine t))))
+    (setq p (point))
+    (insert egg-conversion-close)
+    (put-text-property p (point) 'egg-end t)
+    (if egg-conversion-face
+       (put-text-property p (point) 'invisible t))
+    (goto-char start)))
 
-(defun egg-separate-languages (start end &optional use-context)
-  (let (lang last-lang last-chinese p pe l c cset)
-    ;; 1st pass -- mark undefined Chinese part
+(defun egg-separate-languages (start end)
+  (let (lang last-lang last-chinese p l c cset)
     (goto-char start)
-    (and use-context
-        (setq last-lang (get-text-property (1- (point)) 'egg-lang))
-        (or (equal last-lang "Chinese-GB") (equal last-lang "Chinese-CNS"))
-        (setq last-chinese last-lang))
     (while (< (point) end)
-      (setq p (point)
-           pe (next-single-property-change (point) 'egg-lang nil end))
+      (setq p (next-single-property-change (point) 'its-lang nil end))
       (cond
-       ((get-text-property (point) 'egg-lang)
-       (goto-char pe)
-       (setq lang nil))
-       ((setq l (egg-chinese-syllable (buffer-substring p pe)))
-       (goto-char (+ p l))
-       (setq lang "Chinese"))
+       ((get-text-property (point) 'its-lang)
+       (goto-char p))
+       ((setq l (egg-chinese-syllable (buffer-substring (point) p)))
+       (setq p (point))
+       (goto-char (+ (point) l))
+       (put-text-property p (point) 'its-lang "Chinese"))
        ((progn
          (setq c (following-char)
                cset (char-charset c))
          (eq cset 'chinese-sisheng))
+       (setq p (point))
        (forward-char)
-       (setq lang "Chinese"))
+       (put-text-property p (point) 'its-lang "Chinese"))
        ((eq cset 'ascii)
-       (skip-chars-forward "\0-\177" pe)
-       (if (eq (char-charset (following-char)) 'chinese-sisheng)
-           (goto-char (max (1+ pp) (- (point) 6))))
-       (setq lang nil))
-       ((eq cset 'composition)
-       (forward-char)
-       (setq lang (egg-charset-to-language
-                   (char-charset (car (decompose-composite-char c 'list))))))
+       (forward-char))
        (t
-       (skip-chars-forward (concat (vector (make-char cset 33 33))
-                                   "-"
-                                   (vector (make-char cset 127 127)))
-                           pe)
-       (setq lang (egg-charset-to-language cset))))
-      (if lang
-         (put-text-property p (point) 'egg-lang lang)))
-    ;; 2nd pass -- set language property
+       (setq p (point))
+       (forward-char)
+       (put-text-property p (point) 'its-lang (egg-char-to-language c)))))
     (goto-char start)
     (while (< (point) end)
-      (setq lang (get-text-property (point) 'egg-lang))
+      (setq lang (get-text-property (point) 'its-lang))
       (cond
        ((null lang)
        (setq lang (or last-lang
       (if (or (equal lang "Chinese-GB") (equal lang "Chinese-CNS"))
          (setq last-chinese lang))
       (setq p (point))
-      (goto-char (next-single-property-change (point) 'egg-lang nil end))
+      (goto-char (next-single-property-change (point) 'its-lang nil end))
       (set-text-properties p (point) (list 'egg-lang lang)))))
 
-(defun egg-charset-to-language (charset)
-  (let ((list language-info-alist))
+(defun egg-char-to-language (c)
+  (let ((charset (char-charset c))
+       (list language-info-alist))
     (while (and list
                (null (memq charset (assq 'charset (car list)))))
       (setq list (cdr list)))
     (car (car list))))
 
 (defun egg-next-part-lang (end)
-  (let* ((p (next-single-property-change (point) 'egg-lang nil end))
-        (lang (get-text-property p 'egg-lang)))
+  (let* ((p (next-single-property-change (point) 'its-lang nil end))
+        (lang (get-text-property p 'its-lang)))
     (if (equal lang "Chinese")
        (egg-next-chinese-lang end)
       (or lang
   (let (p lang)
     (setq p (point))
     (while (and (< p end) (null lang))
-      (setq p (next-single-property-change p 'egg-lang nil end))
-      (setq lang (get-text-property p 'egg-lang))
+      (setq p (next-single-property-change p 'its-lang nil end))
+      (setq lang (get-text-property p 'its-lang))
       (if (null (or (equal lang "Chinese-GB")
                    (equal lang "Chinese-CNS")))
          (setq lang nil)))
       egg-default-language)
      (t "Chinese-GB"))))
 \f
-(require 'its-keydef)
-
+(defvar egg-conversion-face nil)
 (defvar egg-conversion-map
   (let ((map (make-sparse-keymap))
        (i 33))
     (define-key map "\C-n"   'egg-next-candidate)
     (define-key map "\C-o"   'egg-enlarge-bunsetsu)
     (define-key map "\C-p"   'egg-previous-candidate)
-    (define-key map "\C-r"   'egg-reverse-convert-bunsetu)
-    (define-key map "\M-r"   'egg-reconvert-bunsetsu)
     (define-key map "\M-s"   'egg-select-candidate)
     (define-key map [return] 'egg-exit-conversion)
+;;    (define-key map "\C-\\"  'egg-exit-mode-no-egg)
     (define-key map [right]  'egg-forward-bunsetsu)
     (define-key map [left]   'egg-backward-bunsetsu)
     (define-key map " "      'egg-next-candidate)
-    (its-define-select-keys map)
+    (define-key map "/"      'egg-exit-conversion)
     map)
   "Keymap for EGG Conversion mode.")
 
 
 (defun egg-insert-bunsetsu (bunsetsu-info last)
   (let ((bunsetsu (egg-get-bunsetsu-converted bunsetsu-info))
-       (p (point)) p1)
+       (p (point)))
     (insert bunsetsu)
-    (setq p1 (point))
     (if (null (eq last t))
        (insert egg-conversion-separator))
-    (set-text-properties p (point)
-                        (list 'read-only          t
-                              (egg-bunsetsu-info) bunsetsu-info
-                              'egg-backend        egg-conversion-backend
-                              'egg-lang           egg-current-language
-                              'egg-bunsetsu-last  last
-                              'local-map          egg-conversion-map))
-    (if egg-conversion-face
-       (put-text-property p p1 'face (egg-get-conversion-face)))))
+    (add-text-properties p (point)
+                        (list 'face      egg-conversion-face
+                              'local-map egg-conversion-map
+                              (egg-bunsetsu-info) (cons egg-conversion-backend
+                                                        bunsetsu-info)
+                              'egg-bunsetsu-last last))))
 
 (defun egg-insert-bunsetsu-list (bunsetsu-info-list &optional last)
   (let ((l bunsetsu-info-list)
-       bunsetsu-info)
+       bunsetsu-info bunsetsu p)
     (while l
       (setq bunsetsu-info (car l)
-           l (cdr l))
+           l (cdr l)
+           p (point))
       (egg-insert-bunsetsu bunsetsu-info (and (null l) last)))))
 
-(defun egg-beginning-of-conversion-buffer (n)
-  (interactive "p")
-  (cond
-   ((<= n 0)
-    (egg-end-of-conversion-buffer 1))
-   ((null (get-text-property (1- (point)) 'egg-start))
-    (goto-char (previous-single-property-change (1- (point)) 'egg-start)))))
-
-(defun egg-end-of-conversion-buffer(n)
-  (interactive "p")
-  (cond
-   ((<= n 0)
-    (egg-beginning-of-conversion-buffer 1))
-   (t
-    (goto-char (next-single-property-change (point) 'egg-end))
-    (backward-char))))
-
 (defun egg-backward-bunsetsu (n)
   (interactive "p")
   (let (start)
 
 (defun egg-enlarge-bunsetsu (n)
   (interactive "p")
-  (let* ((inhibit-read-only t)
-        (b0 (egg-get-previous-bunsetsu (point)))
+  (let* ((b0 (egg-get-previous-bunsetsu (point)))
         (b1 (egg-get-bunsetsu-info (point)))
         (s1 (egg-get-bunsetsu-source b1))
         (s1len (egg-separate-characters s1))
 
 (defun egg-next-candidate (n)
   (interactive "p")
-  (let ((inhibit-read-only t)
-       (last (get-text-property (point) 'egg-bunsetsu-last))
+  (let ((last (get-text-property (point) 'egg-bunsetsu-last))
        (b (egg-get-bunsetsu-info (point)))
        new i max+ p beep)
     (setq max+ (egg-get-number-of-candidates b))
          (setq max+ (egg-get-number-of-candidates b)))
       (setq i (egg-get-current-candidate-number b))
       (setq i (+ n i)))
-    (if (null max+)
-       (setq beep t)
-      (if (< i 0)                      ; go backward as if it is ring
-         (while (< i 0)
-           (setq i (+ i max+))))
-      (if (>= i max+)                  ; don't go forward 
-         (setq i (1- max+)
-               beep t))
-      (setq new (egg-decide-candidate b i))
-      (setq p (point))
-      (delete-region p (progn (forward-char) (point)))
-      (egg-insert-bunsetsu new last)
-      (goto-char p))
+    (if (< i 0)                                ; go backward as if it is ring
+       (while (< i 0)
+         (setq i (+ i max+))))
+    (if (>= i max+)                    ; don't go forward 
+       (setq i (1- max+)
+             beep t))
+    (setq new (egg-decide-candidate b i))
+    (setq p (point))
+    (delete-region p (progn (forward-char) (point)))
+    (egg-insert-bunsetsu new last)
+    (goto-char p)
     (if beep
        (ding))))
 
   (interactive "p")
   (egg-next-candidate (- n)))
 
-(defun egg-reconvert-bunsetsu-internal (n func)
-  (let ((inhibit-read-only t)
-       (p (point))
-       source last bunsetsu-list)
-    (if (<= n 0)
-       (beep)
-      (while (and (null last) (> n 0))
-       (setq source (concat source
-                            (egg-get-bunsetsu-converted
-                             (egg-get-bunsetsu-info (point))))
-             last (get-text-property (point) 'egg-bunsetsu-last)
-             n (1- n))
-       (forward-char))
-      (cond
-       ((> n 0)
-       (beep))
-       ((setq bunsetsu-list (funcall func source egg-current-language))
-       (delete-region p (point))
-       (egg-insert-bunsetsu-list bunsetsu-list (if (eq last t) t 'contine))
-       (goto-char p)
-       (if (egg-get-previous-bunsetsu p)
-           (progn
-             (backward-char)
-             (put-text-property (point) p 'egg-bunsetsu-last 'contine)
-             (forward-char))))))))
-
-(defun egg-reverse-convert-bunsetu (n)
-  (interactive "p")
-  (egg-reconvert-bunsetsu-internal n 'egg-start-reverse-conversion))
-
-(defun egg-reconvert-bunsetsu (n)
-  (interactive "p")
-  (egg-reconvert-bunsetsu-internal n 'egg-start-conversion))
+;; Bogus function 980220
+(defun egg-decide-bunsetsu (&optional end-marker)
+  (let ((in-loop t)
+       p bunsetsu-info-list bl)
+    (setq p (point))
+    (while in-loop
+      (let ((bl1 (cons (egg-get-bunsetsu-info p) nil)))
+       (if bl
+           (setq bl (setcdr bl bl1))
+         (setq bunsetsu-info-list (setq bl bl1))))
+      (forward-char)
+      (remove-text-properties p (point) '(face nil
+                                         intangible nil
+                                         local-map nil
+                                         egg-bunsetsu-last nil))
+      (setq p (point))
+      (if (or (and end-marker (= p end-marker))
+             (get-text-property p 'egg-end))
+         (setq in-loop nil)
+       (setq p (1- p))
+       (delete-region p (1+ p))))      ; Delete bunsetsu separator
+    bunsetsu-info-list))
 
 (defun egg-decide-before-point ()
   (interactive)
-  (let ((inhibit-read-only t)
-       (len (length egg-conversion-open))
-       bunsetsu-list bl (p (point)) source lang s)
+  (let (bunsetsu-list bl (p (point)) source (dlen 0) l s)
     (save-restriction
       (if (null (get-text-property (1- (point)) 'egg-start))
          (goto-char (previous-single-property-change (point) 'egg-start)))
-      (narrow-to-region (- (point) len) p)
+      (narrow-to-region (1- (point)) p)
+      (setq source (get-text-property (1- (point)) 'egg-source))
       (setq bunsetsu-list (setq bl (list nil)))
       (while (< (point) (point-max))
        ;; delete sparator/open marker
-       (delete-region (- (point) len) (point))
-       (setq len 1
-             bl (setcdr bl (list (egg-get-bunsetsu-info (point)))))
+       (delete-region (1- (point)) (point))
+       (setq bl (setcdr bl (list (egg-get-bunsetsu-info (point)))))
+       (setq dlen (+ dlen (length (egg-get-bunsetsu-source (car bl)))))
        (if (get-text-property (point) 'egg-bunsetsu-last)
            (progn
              (egg-end-conversion (cdr bunsetsu-list))
              (setq bunsetsu-list (setq bl (list nil)))))
        (setq p (point))
        (forward-char)
-       (set-text-properties p (point) nil)))
-    (if (cdr bunsetsu-list)
-       (egg-end-conversion (cdr bunsetsu-list)))
+       (remove-text-properties p (point) '(face nil
+                                                intangible nil
+                                                local-map nil
+                                                egg-bunsetsu-last nil))))
     (if (get-text-property (point) 'egg-end)
        (progn
          ;; delete close marker
-         (delete-region (point) (+ (point) (length egg-conversion-close)))
+         (delete-region (point) (1+ (point)))
          (egg-do-auto-fill)
          (run-hooks 'input-method-after-insert-chunk-hook))
-      ;; delete from last speparater
-      (delete-region (1- (point)) (point))
-      (setq source "")
-      (while (null (get-text-property (point) 'egg-end))
-       (setq s (egg-get-bunsetsu-source (egg-get-bunsetsu-info (point))))
-       (put-text-property 0 (length s) 'egg-lang egg-current-language s)
-       (setq source (concat source s))
-       (setq p (point))
-       (forward-char)
-       (delete-region p (point)))
-      ;; delete close marker
-      (delete-region (point) (+ (point) (length egg-conversion-close)))
-      (its-restart source t))))
+      ;; delete last from speparater to close marker
+      (delete-region (1- (point))
+                    (1+ (next-single-property-change (point) 'egg-end)))
+      ;; rebuild fence mode string
+      (setq p 0)
+      (while (< p dlen)
+       (setq s (car (get-text-property p 'its-syl source))
+             l (length s)
+             p (+ p l))
+       (if (> p dlen)
+           (put-text-property dlen p
+                              'its-syl (list (substring s (- dlen p)))
+                              source)))
+      (its-restart (substring source dlen)))))
 
 (defun egg-exit-conversion ()
   (interactive)
 
 (defun egg-abort-conversion ()
   (interactive)
-  (let ((inhibit-read-only t) source)
-    (goto-char (- (if (get-text-property (1- (point)) 'egg-start)
-                     (point)
-                   (previous-single-property-change (point) 'egg-start))
-                 (length egg-conversion-open)))
-    (setq source (get-text-property (point) 'egg-source))
-    (delete-region (point) (+ (next-single-property-change (point) 'egg-end)
-                             (length egg-conversion-close)))
-    (its-restart source)))
+  (if (null (get-text-property (1- (point)) 'egg-start))
+      (goto-char (previous-single-property-change (point) 'egg-start)))
+  (egg-decide-before-point))
 
 (defun egg-select-candidate ()
   (interactive)
-  (let ((inhibit-read-only t)
-       (last (get-text-property (point) 'egg-bunsetsu-last))
+  (let ((last (get-text-property (point) 'egg-bunsetsu-last))
        (b (egg-get-bunsetsu-info (point)))
        (in-loop t)
        new i max+ p)
          (setq i (egg-list-candidates b prev-b))
          (setq max+ (egg-get-number-of-candidates b)))
       (setq i (egg-get-current-candidate-number b)))
-    (let (candidate-list candidate l)
-      (if (null max+)
-         ;; fake 1 candidate
-         (menudiag-select (list 'menu "\e$B8uJd\e(B:"
-                                (list (egg-get-bunsetsu-converted b))
-                                (list (egg-get-bunsetsu-converted b))))
-       (setq candidate-list (egg-get-all-candidates b)
-             l candidate-list
-             candidate (menudiag-select (list 'menu "\e$B8uJd\e(B:" l)
-                                        (list (nth i l))))
-       (setq i 0)
-       (while in-loop
-         (if (eq candidate (car l))
-             (setq in-loop nil)
-           (setq l (cdr l)
-                 i (1+ i))))
-       (setq new (egg-decide-candidate b i))
-       (setq p (point))
-       (delete-region p (progn (forward-char) (point)))
-       (egg-insert-bunsetsu new last)
-       (goto-char p)))))
+    (let* ((candidate-list (egg-get-all-candidates b))
+          (l candidate-list)
+          (candidate (menudiag-select (list 'menu "\e$B8uJd\e(B:" l) (list (nth i l)))))
+      (setq i 0)
+      (while in-loop
+       (if (eq candidate (car l))
+           (setq in-loop nil)
+         (setq l (cdr l)
+               i (1+ i))))
+      (setq new (egg-decide-candidate b i))
+      (setq p (point))
+      (delete-region p (progn (forward-char) (point)))
+      (egg-insert-bunsetsu new last)
+      (goto-char p))))
 
 (provide 'egg-cnv)
 ;;; egg-cnv.el ends here.
index d9a97fe..a15ba79 100644 (file)
     ("X" . 20) ("Y" . 21) ("Z"  . 22) ("Zh" . 23)))
 
 (defconst yincode-pinyin-yunmu
-  '(("\e(0@\e(B"      0 0) ("\e(0@\e(B"      0 1) ("\e(0@\e(B"      0 3) ("\e(0@\e(B"      0 5) ("\e(0@\e(B"      0 7)
-    ("a\e(0@\e(B"     1 0) ("\e(0!@\e(B"     1 1) ("\e(0"@\e(B"     1 3) ("\e(0#@\e(B"     1 5) ("\e(0$@\e(B"     1 7)
-    ("ai\e(0@\e(B"    2 0) ("\e(0!\e(Bi\e(0@\e(B"    2 1) ("\e(0"\e(Bi\e(0@\e(B"    2 3) ("\e(0#\e(Bi\e(0@\e(B"    2 5) ("\e(0$\e(Bi\e(0@\e(B"    2 7)
-    ("an\e(0@\e(B"    3 0) ("\e(0!\e(Bn\e(0@\e(B"    3 1) ("\e(0"\e(Bn\e(0@\e(B"    3 3) ("\e(0#\e(Bn\e(0@\e(B"    3 5) ("\e(0$\e(Bn\e(0@\e(B"    3 7)
-    ("ang\e(0@\e(B"   4 0) ("\e(0!\e(Bng\e(0@\e(B"   4 1) ("\e(0"\e(Bng\e(0@\e(B"   4 3) ("\e(0#\e(Bng\e(0@\e(B"   4 5) ("\e(0$\e(Bng\e(0@\e(B"   4 7)
-    ("ao\e(0@\e(B"    5 0) ("\e(0!\e(Bo\e(0@\e(B"    5 1) ("\e(0"\e(Bo\e(0@\e(B"    5 3) ("\e(0#\e(Bo\e(0@\e(B"    5 5) ("\e(0$\e(Bo\e(0@\e(B"    5 7)
-    ("e\e(0@\e(B"     6 0) ("\e(0%@\e(B"     6 1) ("\e(0&@\e(B"     6 3) ("\e(0'@\e(B"     6 5) ("\e(0(@\e(B"     6 7)
-    ("ei\e(0@\e(B"    7 0) ("\e(0%\e(Bi\e(0@\e(B"    7 1) ("\e(0&\e(Bi\e(0@\e(B"    7 3) ("\e(0'\e(Bi\e(0@\e(B"    7 5) ("\e(0(\e(Bi\e(0@\e(B"    7 7)
-    ("en\e(0@\e(B"    8 0) ("\e(0%\e(Bn\e(0@\e(B"    8 1) ("\e(0&\e(Bn\e(0@\e(B"    8 3) ("\e(0'\e(Bn\e(0@\e(B"    8 5) ("\e(0(\e(Bn\e(0@\e(B"    8 7)
-    ("eng\e(0@\e(B"   9 0) ("\e(0%\e(Bng\e(0@\e(B"   9 1) ("\e(0&\e(Bng\e(0@\e(B"   9 3) ("\e(0'\e(Bng\e(0@\e(B"   9 5) ("\e(0(\e(Bng\e(0@\e(B"   9 7)
-    ("er\e(0@\e(B"   10 0) ("\e(0%\e(Br\e(0@\e(B"   10 1) ("\e(0&\e(Br\e(0@\e(B"   10 3) ("\e(0'\e(Br\e(0@\e(B"   10 5) ("\e(0(\e(Br\e(0@\e(B"   10 7)
-    ("i\e(0@\e(B"    11 0) ("\e(0)@\e(B"    11 1) ("\e(0*@\e(B"    11 3) ("\e(0+@\e(B"    11 5) ("\e(0,@\e(B"    11 7)
-    ("ia\e(0@\e(B"   12 0) ("i\e(0!@\e(B"   12 1) ("i\e(0"@\e(B"   12 3) ("i\e(0#@\e(B"   12 5) ("i\e(0$@\e(B"   12 7)
-    ("ian\e(0@\e(B"  13 0) ("i\e(0!\e(Bn\e(0@\e(B"  13 1) ("i\e(0"\e(Bn\e(0@\e(B"  13 3) ("i\e(0#\e(Bn\e(0@\e(B"  13 5) ("i\e(0$\e(Bn\e(0@\e(B"  13 7)
-    ("iang\e(0@\e(B" 14 0) ("i\e(0!\e(Bng\e(0@\e(B" 14 1) ("i\e(0"\e(Bng\e(0@\e(B" 14 3) ("i\e(0#\e(Bng\e(0@\e(B" 14 5) ("i\e(0$\e(Bng\e(0@\e(B" 14 7)
-    ("iao\e(0@\e(B"  15 0) ("i\e(0!\e(Bo\e(0@\e(B"  15 1) ("i\e(0"\e(Bo\e(0@\e(B"  15 3) ("i\e(0#\e(Bo\e(0@\e(B"  15 5) ("i\e(0$\e(Bo\e(0@\e(B"  15 7)
-    ("ie\e(0@\e(B"   16 0) ("i\e(0%@\e(B"   16 1) ("i\e(0&@\e(B"   16 3) ("i\e(0'@\e(B"   16 5) ("i\e(0(@\e(B"   16 7)
-    ("in\e(0@\e(B"   17 0) ("\e(0)\e(Bn\e(0@\e(B"   17 1) ("\e(0*\e(Bn\e(0@\e(B"   17 3) ("\e(0+\e(Bn\e(0@\e(B"   17 5) ("\e(0,\e(Bn\e(0@\e(B"   17 7)
-    ("ing\e(0@\e(B"  18 0) ("\e(0)\e(Bng\e(0@\e(B"  18 1) ("\e(0*\e(Bng\e(0@\e(B"  18 3) ("\e(0+\e(Bng\e(0@\e(B"  18 5) ("\e(0,\e(Bng\e(0@\e(B"  18 7)
-    ("iong\e(0@\e(B" 19 0) ("i\e(0-\e(Bng\e(0@\e(B" 19 1) ("i\e(0.\e(Bng\e(0@\e(B" 19 3) ("i\e(0/\e(Bng\e(0@\e(B" 19 5) ("i\e(00\e(Bng\e(0@\e(B" 19 7)
-    ("iu\e(0@\e(B"   20 0) ("i\e(01@\e(B"   20 1) ("i\e(02@\e(B"   20 3) ("i\e(03@\e(B"   20 5) ("i\e(04@\e(B"   20 7)
-    ("m\e(0@\e(B"    21 0) ("m\e(0@\e(B"    21 1) ("m\e(0@\e(B"    21 3) ("m\e(0@\e(B"    21 5) ("m\e(0@\e(B"    21 7)
-    ("n\e(0@\e(B"    22 0) ("n\e(0@\e(B"    22 1) ("\e(0=@\e(B"    22 3) ("\e(0>@\e(B"    22 5) ("\e(0?@\e(B"    22 7)
-    ("ng\e(0@\e(B"   23 0) ("ng\e(0@\e(B"   23 1) ("ng\e(0@\e(B"   23 3) ("ng\e(0@\e(B"   23 5) ("ng\e(0@\e(B"   23 7)
-    ("o\e(0@\e(B"    24 0) ("\e(0-@\e(B"    24 1) ("\e(0.@\e(B"    24 3) ("\e(0/@\e(B"    24 5) ("\e(00@\e(B"    24 7)
-    ("ong\e(0@\e(B"  25 0) ("\e(0-\e(Bng\e(0@\e(B"  25 1) ("\e(0.\e(Bng\e(0@\e(B"  25 3) ("\e(0/\e(Bng\e(0@\e(B"  25 5) ("\e(00\e(Bng\e(0@\e(B"  25 7)
-    ("ou\e(0@\e(B"   26 0) ("\e(0-\e(Bu\e(0@\e(B"   26 1) ("\e(0.\e(Bu\e(0@\e(B"   26 3) ("\e(0/\e(Bu\e(0@\e(B"   26 5) ("\e(00\e(Bu\e(0@\e(B"   26 7)
-    ("u\e(0@\e(B"    27 0) ("\e(01@\e(B"    27 1) ("\e(02@\e(B"    27 3) ("\e(03@\e(B"    27 5) ("\e(04@\e(B"    27 7)
-    ("ua\e(0@\e(B"   28 0) ("u\e(0!@\e(B"   28 1) ("u\e(0"@\e(B"   28 3) ("u\e(0#@\e(B"   28 5) ("u\e(0$@\e(B"   28 7)
-    ("uai\e(0@\e(B"  29 0) ("u\e(0!\e(Bi\e(0@\e(B"  29 1) ("u\e(0"\e(Bi\e(0@\e(B"  29 3) ("u\e(0#\e(Bi\e(0@\e(B"  29 5) ("u\e(0$\e(Bi\e(0@\e(B"  29 7)
-    ("uan\e(0@\e(B"  30 0) ("u\e(0!\e(Bn\e(0@\e(B"  30 1) ("u\e(0"\e(Bn\e(0@\e(B"  30 3) ("u\e(0#\e(Bn\e(0@\e(B"  30 5) ("u\e(0$\e(Bn\e(0@\e(B"  30 7)
-    ("uang\e(0@\e(B" 31 0) ("u\e(0!\e(Bng\e(0@\e(B" 31 1) ("u\e(0"\e(Bng\e(0@\e(B" 31 3) ("u\e(0#\e(Bng\e(0@\e(B" 31 5) ("u\e(0$\e(Bng\e(0@\e(B" 31 7)
-    ("ue\e(0@\e(B"   32 0) ("u\e(0%@\e(B"   32 1) ("u\e(0&@\e(B"   32 3) ("u\e(0'@\e(B"   32 5) ("u\e(0(@\e(B"   32 7)
-    ("ui\e(0@\e(B"   33 0) ("u\e(0)@\e(B"   33 1) ("u\e(0*@\e(B"   33 3) ("u\e(0+@\e(B"   33 5) ("u\e(0,@\e(B"   33 7)
-    ("un\e(0@\e(B"   34 0) ("\e(01\e(Bn\e(0@\e(B"   34 1) ("\e(02\e(Bn\e(0@\e(B"   34 3) ("\e(03\e(Bn\e(0@\e(B"   34 5) ("\e(04\e(Bn\e(0@\e(B"   34 7)
-    ("uo\e(0@\e(B"   35 0) ("u\e(0-@\e(B"   35 1) ("u\e(0.@\e(B"   35 3) ("u\e(0/@\e(B"   35 5) ("u\e(00@\e(B"   35 7)
-    ("\e(09@\e(B"    36 0) ("\e(05@\e(B"    36 1) ("\e(06@\e(B"    36 3) ("\e(07@\e(B"    36 5) ("\e(08@\e(B"    36 7)
-    ("\e(09\e(Be\e(0@\e(B"   37 0) ("\e(09%@\e(B"   37 1) ("\e(09&@\e(B"   37 3) ("\e(09'@\e(B"   37 5) ("\e(09(@\e(B"   37 7)
-    ("0\e(0@\e(B"    38 0) ("1\e(0@\e(B"    38 1) ("2\e(0@\e(B"    38 3) ("3\e(0@\e(B"    38 5) ("4\e(0@\e(B"    38 7)))
+  '(("\9a À"      0 0) ("\9a À"      0 1) ("\9a À"      0 3) ("\9a À"      0 5) ("\9a À"      0 7)
+    ("a\9a À"     1 0) ("\9a ¡\9a À"     1 1) ("\9a ¢\9a À"     1 3) ("\9a £\9a À"     1 5) ("\9a ¤\9a À"     1 7)
+    ("ai\9a À"    2 0) ("\9a ¡i\9a À"    2 1) ("\9a ¢i\9a À"    2 3) ("\9a £i\9a À"    2 5) ("\9a ¤i\9a À"    2 7)
+    ("an\9a À"    3 0) ("\9a ¡n\9a À"    3 1) ("\9a ¢n\9a À"    3 3) ("\9a £n\9a À"    3 5) ("\9a ¤n\9a À"    3 7)
+    ("ang\9a À"   4 0) ("\9a ¡ng\9a À"   4 1) ("\9a ¢ng\9a À"   4 3) ("\9a £ng\9a À"   4 5) ("\9a ¤ng\9a À"   4 7)
+    ("ao\9a À"    5 0) ("\9a ¡o\9a À"    5 1) ("\9a ¢o\9a À"    5 3) ("\9a £o\9a À"    5 5) ("\9a ¤o\9a À"    5 7)
+    ("e\9a À"     6 0) ("\9a ¥\9a À"     6 1) ("\9a ¦\9a À"     6 3) ("\9a §\9a À"     6 5) ("\9a ¨\9a À"     6 7)
+    ("ei\9a À"    7 0) ("\9a ¥i\9a À"    7 1) ("\9a ¦i\9a À"    7 3) ("\9a §i\9a À"    7 5) ("\9a ¨i\9a À"    7 7)
+    ("en\9a À"    8 0) ("\9a ¥n\9a À"    8 1) ("\9a ¦n\9a À"    8 3) ("\9a §n\9a À"    8 5) ("\9a ¨n\9a À"    8 7)
+    ("eng\9a À"   9 0) ("\9a ¥ng\9a À"   9 1) ("\9a ¦ng\9a À"   9 3) ("\9a §ng\9a À"   9 5) ("\9a ¨ng\9a À"   9 7)
+    ("er\9a À"   10 0) ("\9a ¥r\9a À"   10 1) ("\9a ¦r\9a À"   10 3) ("\9a §r\9a À"   10 5) ("\9a ¨r\9a À"   10 7)
+    ("i\9a À"    11 0) ("\9a ©\9a À"    11 1) ("\9a ª\9a À"    11 3) ("\9a «\9a À"    11 5) ("\9a ¬\9a À"    11 7)
+    ("ia\9a À"   12 0) ("i\9a ¡\9a À"   12 1) ("i\9a ¢\9a À"   12 3) ("i\9a £\9a À"   12 5) ("i\9a ¤\9a À"   12 7)
+    ("ian\9a À"  13 0) ("i\9a ¡n\9a À"  13 1) ("i\9a ¢n\9a À"  13 3) ("i\9a £n\9a À"  13 5) ("i\9a ¤n\9a À"  13 7)
+    ("iang\9a À" 14 0) ("i\9a ¡ng\9a À" 14 1) ("i\9a ¢ng\9a À" 14 3) ("i\9a £ng\9a À" 14 5) ("i\9a ¤ng\9a À" 14 7)
+    ("iao\9a À"  15 0) ("i\9a ¡o\9a À"  15 1) ("i\9a ¢o\9a À"  15 3) ("i\9a £o\9a À"  15 5) ("i\9a ¤o\9a À"  15 7)
+    ("ie\9a À"   16 0) ("i\9a ¥\9a À"   16 1) ("i\9a ¦\9a À"   16 3) ("i\9a §\9a À"   16 5) ("i\9a ¨\9a À"   16 7)
+    ("in\9a À"   17 0) ("\9a ©n\9a À"   17 1) ("\9a ªn\9a À"   17 3) ("\9a «n\9a À"   17 5) ("\9a ¬n\9a À"   17 7)
+    ("ing\9a À"  18 0) ("\9a ©ng\9a À"  18 1) ("\9a ªng\9a À"  18 3) ("\9a «ng\9a À"  18 5) ("\9a ¬ng\9a À"  18 7)
+    ("iong\9a À" 19 0) ("i\9a ­ng\9a À" 19 1) ("i\9a ®ng\9a À" 19 3) ("i\9a ¯ng\9a À" 19 5) ("i\9a °ng\9a À" 19 7)
+    ("iu\9a À"   20 0) ("i\9a ±\9a À"   20 1) ("i\9a ²\9a À"   20 3) ("i\9a ³\9a À"   20 5) ("i\9a ´\9a À"   20 7)
+    ("m\9a À"    21 0) ("m\9a À"    21 1) ("m\9a À"    21 3) ("m\9a À"    21 5) ("m\9a À"    21 7)
+    ("n\9a À"    22 0) ("n\9a À"    22 1) ("\9a ½\9a À"    22 3) ("\9a ¾\9a À"    22 5) ("\9a ¿\9a À"    22 7)
+    ("ng\9a À"   23 0) ("ng\9a À"   23 1) ("ng\9a À"   23 3) ("ng\9a À"   23 5) ("ng\9a À"   23 7)
+    ("o\9a À"    24 0) ("\9a ­\9a À"    24 1) ("\9a ®\9a À"    24 3) ("\9a ¯\9a À"    24 5) ("\9a °\9a À"    24 7)
+    ("ong\9a À"  25 0) ("\9a ­ng\9a À"  25 1) ("\9a ®ng\9a À"  25 3) ("\9a ¯ng\9a À"  25 5) ("\9a °ng\9a À"  25 7)
+    ("ou\9a À"   26 0) ("\9a ­u\9a À"   26 1) ("\9a ®u\9a À"   26 3) ("\9a ¯u\9a À"   26 5) ("\9a °u\9a À"   26 7)
+    ("u\9a À"    27 0) ("\9a ±\9a À"    27 1) ("\9a ²\9a À"    27 3) ("\9a ³\9a À"    27 5) ("\9a ´\9a À"    27 7)
+    ("ua\9a À"   28 0) ("u\9a ¡\9a À"   28 1) ("u\9a ¢\9a À"   28 3) ("u\9a £\9a À"   28 5) ("u\9a ¤\9a À"   28 7)
+    ("uai\9a À"  29 0) ("u\9a ¡i\9a À"  29 1) ("u\9a ¢i\9a À"  29 3) ("u\9a £i\9a À"  29 5) ("u\9a ¤i\9a À"  29 7)
+    ("uan\9a À"  30 0) ("u\9a ¡n\9a À"  30 1) ("u\9a ¢n\9a À"  30 3) ("u\9a £n\9a À"  30 5) ("u\9a ¤n\9a À"  30 7)
+    ("uang\9a À" 31 0) ("u\9a ¡ng\9a À" 31 1) ("u\9a ¢ng\9a À" 31 3) ("u\9a £ng\9a À" 31 5) ("u\9a ¤ng\9a À" 31 7)
+    ("ue\9a À"   32 0) ("u\9a ¥\9a À"   32 1) ("u\9a ¦\9a À"   32 3) ("u\9a §\9a À"   32 5) ("u\9a ¨\9a À"   32 7)
+    ("ui\9a À"   33 0) ("u\9a ©\9a À"   33 1) ("u\9a ª\9a À"   33 3) ("u\9a «\9a À"   33 5) ("u\9a ¬\9a À"   33 7)
+    ("un\9a À"   34 0) ("\9a ±n\9a À"   34 1) ("\9a ²n\9a À"   34 3) ("\9a ³n\9a À"   34 5) ("\9a ´n\9a À"   34 7)
+    ("uo\9a À"   35 0) ("u\9a ­\9a À"   35 1) ("u\9a ®\9a À"   35 3) ("u\9a ¯\9a À"   35 5) ("u\9a °\9a À"   35 7)
+    ("\9a ¹\9a À"    36 0) ("\9a µ\9a À"    36 1) ("\9a ¶\9a À"    36 3) ("\9a ·\9a À"    36 5) ("\9a ¸\9a À"    36 7)
+    ("\9a ¹e\9a À"   37 0) ("\9a ¹\9a ¥\9a À"   37 1) ("\9a ¹\9a ¦\9a À"   37 3) ("\9a ¹\9a §\9a À"   37 5) ("\9a ¹\9a ¨\9a À"   37 7)
+    ("0\9a À"    38 0) ("1\9a À"    38 1) ("2\9a À"    38 3) ("3\9a À"    38 5) ("4\9a À"    38 7)))
 
 (defconst yincode-pinyin-table
   [
    ])
 
 (defconst yincode-zhuyin-shengmu
-  '((""  .  0) ("\e(0E\e(B" .  1) ("\e(0X\e(B" .  2) ("\e(0T\e(B" .  3) ("\e(0I\e(B" .  4)
-    ("\e(0H\e(B" .  5) ("\e(0M\e(B" .  6) ("\e(0O\e(B" .  7) ("\e(0P\e(B" .  8) ("\e(0N\e(B" .  9)
-    ("\e(0L\e(B" . 10) ("\e(0G\e(B" . 11) ("\e(0K\e(B" . 12) ("\e(0F\e(B" . 13) ("\e(0Q\e(B" . 14)
-    ("\e(0V\e(B" . 15) ("\e(0Y\e(B" . 16) ("\e(0U\e(B" . 17) ("\e(0J\e(B" . 18) ("\e(0h\e(B" . 19)
-    ("\e(0R\e(B" . 20) ("\e(0g\e(B" . 21) ("\e(0W\e(B" . 22) ("\e(0S\e(B" . 23)))
+  '((""  .  0) ("\9a Å" .  1) ("\9a Ø" .  2) ("\9a Ô" .  3) ("\9a É" .  4)
+    ("\9a È" .  5) ("\9a Í" .  6) ("\9a Ï" .  7) ("\9a Ð" .  8) ("\9a Î" .  9)
+    ("\9a Ì" . 10) ("\9a Ç" . 11) ("\9a Ë" . 12) ("\9a Æ" . 13) ("\9a Ñ" . 14)
+    ("\9a Ö" . 15) ("\9a Ù" . 16) ("\9a Õ" . 17) ("\9a Ê" . 18) ("\9a è" . 19)
+    ("\9a Ò" . 20) ("\9a ç" . 21) ("\9a ×" . 22) ("\9a Ó" . 23)))
 
 (defconst yincode-zhuyin-yunmu
-  '(("\e(0@\e(B"    0 0) ("\e(0A\e(B"    0 1) ("\e(0B\e(B"    0 3) ("\e(0C\e(B"    0 5) ("\e(0D\e(B"    0 7) ; i
-    ("\e(0Z@\e(B"   1 0) ("\e(0ZA\e(B"   1 1) ("\e(0ZB\e(B"   1 3) ("\e(0ZC\e(B"   1 5) ("\e(0ZD\e(B"   1 7) ; a
-    ("\e(0^@\e(B"   2 0) ("\e(0^A\e(B"   2 1) ("\e(0^B\e(B"   2 3) ("\e(0^C\e(B"   2 5) ("\e(0^D\e(B"   2 7) ; ai
-    ("\e(0b@\e(B"   3 0) ("\e(0bA\e(B"   3 1) ("\e(0bB\e(B"   3 3) ("\e(0bC\e(B"   3 5) ("\e(0bD\e(B"   3 7) ; an
-    ("\e(0d@\e(B"   4 0) ("\e(0dA\e(B"   4 1) ("\e(0dB\e(B"   4 3) ("\e(0dC\e(B"   4 5) ("\e(0dD\e(B"   4 7) ; ang
-    ("\e(0`@\e(B"   5 0) ("\e(0`A\e(B"   5 1) ("\e(0`B\e(B"   5 3) ("\e(0`C\e(B"   5 5) ("\e(0`D\e(B"   5 7) ; ao
-    ("\e(0\@\e(B"   6 0) ("\e(0\A\e(B"   6 1) ("\e(0\B\e(B"   6 3) ("\e(0\C\e(B"   6 5) ("\e(0\D\e(B"   6 7) ; e
-    ("\e(0_@\e(B"   7 0) ("\e(0_A\e(B"   7 1) ("\e(0_B\e(B"   7 3) ("\e(0_C\e(B"   7 5) ("\e(0_D\e(B"   7 7) ; ei
-    ("\e(0c@\e(B"   8 0) ("\e(0cA\e(B"   8 1) ("\e(0cB\e(B"   8 3) ("\e(0cC\e(B"   8 5) ("\e(0cD\e(B"   8 7) ; en
-    ("\e(0e@\e(B"   9 0) ("\e(0eA\e(B"   9 1) ("\e(0eB\e(B"   9 3) ("\e(0eC\e(B"   9 5) ("\e(0eD\e(B"   9 7) ; eng
-    ("\e(0f@\e(B"  10 0) ("\e(0fA\e(B"  10 1) ("\e(0fB\e(B"  10 3) ("\e(0fC\e(B"  10 5) ("\e(0fD\e(B"  10 7) ; er
-    ("\e(0g@\e(B"  11 0) ("\e(0gA\e(B"  11 1) ("\e(0gB\e(B"  11 3) ("\e(0gC\e(B"  11 5) ("\e(0gD\e(B"  11 7) ; i
-    ("\e(0gZ@\e(B" 12 0) ("\e(0gZA\e(B" 12 1) ("\e(0gZB\e(B" 12 3) ("\e(0gZC\e(B" 12 5) ("\e(0gZD\e(B" 12 7) ; ia
-    ("\e(0gb@\e(B" 13 0) ("\e(0gbA\e(B" 13 1) ("\e(0gbB\e(B" 13 3) ("\e(0gbC\e(B" 13 5) ("\e(0gbD\e(B" 13 7) ; ian
-    ("\e(0gd@\e(B" 14 0) ("\e(0gdA\e(B" 14 1) ("\e(0gdB\e(B" 14 3) ("\e(0gdC\e(B" 14 5) ("\e(0gdD\e(B" 14 7) ; iang
-    ("\e(0g`@\e(B" 15 0) ("\e(0g`A\e(B" 15 1) ("\e(0g`B\e(B" 15 3) ("\e(0g`C\e(B" 15 5) ("\e(0g`D\e(B" 15 7) ; iao
-    ("\e(0g]@\e(B" 16 0) ("\e(0g]A\e(B" 16 1) ("\e(0g]B\e(B" 16 3) ("\e(0g]C\e(B" 16 5) ("\e(0g]D\e(B" 16 7) ; ie
-    ("\e(0gc@\e(B" 17 0) ("\e(0gcA\e(B" 17 1) ("\e(0gcB\e(B" 17 3) ("\e(0gcC\e(B" 17 5) ("\e(0gcD\e(B" 17 7) ; in
-    ("\e(0ge@\e(B" 18 0) ("\e(0geA\e(B" 18 1) ("\e(0geB\e(B" 18 3) ("\e(0geC\e(B" 18 5) ("\e(0geD\e(B" 18 7) ; ing
-    ("\e(0ie@\e(B" 19 0) ("\e(0ieA\e(B" 19 1) ("\e(0ieB\e(B" 19 3) ("\e(0ieC\e(B" 19 5) ("\e(0ieD\e(B" 19 7) ; iong
-    ("\e(0ga@\e(B" 20 0) ("\e(0gaA\e(B" 20 1) ("\e(0gaB\e(B" 20 3) ("\e(0gaC\e(B" 20 5) ("\e(0gaD\e(B" 20 7) ; iu
-    ("\e(0G@\e(B"  21 0) ("\e(0GA\e(B"  21 1) ("\e(0GB\e(B"  21 3) ("\e(0GC\e(B"  21 5) ("\e(0GD\e(B"  21 7) ; m
-    ("\e(0K@\e(B"  22 0) ("\e(0KA\e(B"  22 1) ("\e(0KB\e(B"  22 3) ("\e(0KC\e(B"  22 5) ("\e(0KD\e(B"  22 7) ; n
-    ("@\e(0@\e(B"  23 0) ("@\e(0A\e(B"  23 1) ("@\e(0B\e(B"  23 3) ("@\e(0C\e(B"  23 5) ("@\e(0D\e(B"  23 7) ; ng
-    ("\e(0[@\e(B"  24 0) ("\e(0[A\e(B"  24 1) ("\e(0[B\e(B"  24 3) ("\e(0[C\e(B"  24 5) ("\e(0[D\e(B"  24 7) ; o
-    ("\e(0he@\e(B" 25 0) ("\e(0heA\e(B" 25 1) ("\e(0heB\e(B" 25 3) ("\e(0heC\e(B" 25 5) ("\e(0heD\e(B" 25 7) ; ong
-    ("\e(0a@\e(B"  26 0) ("\e(0aA\e(B"  26 1) ("\e(0aB\e(B"  26 3) ("\e(0aC\e(B"  26 5) ("\e(0aD\e(B"  26 7) ; ou
-    ("\e(0h@\e(B"  27 0) ("\e(0hA\e(B"  27 1) ("\e(0hB\e(B"  27 3) ("\e(0hC\e(B"  27 5) ("\e(0hD\e(B"  27 7) ; u
-    ("\e(0hZ@\e(B" 28 0) ("\e(0hZA\e(B" 28 1) ("\e(0hZB\e(B" 28 3) ("\e(0hZC\e(B" 28 5) ("\e(0hZD\e(B" 28 7) ; ua
-    ("\e(0h^@\e(B" 29 0) ("\e(0h^A\e(B" 29 1) ("\e(0h^B\e(B" 29 3) ("\e(0h^C\e(B" 29 5) ("\e(0h^D\e(B" 29 7) ; uai
-    ("\e(0hb@\e(B" 30 0) ("\e(0hbA\e(B" 30 1) ("\e(0hbB\e(B" 30 3) ("\e(0hbC\e(B" 30 5) ("\e(0hbD\e(B" 30 7) ; uan
-    ("\e(0hd@\e(B" 31 0) ("\e(0hdA\e(B" 31 1) ("\e(0hdB\e(B" 31 3) ("\e(0hdC\e(B" 31 5) ("\e(0hdD\e(B" 31 7) ; uang
-    ("\e(0i]@\e(B" 37 0) ("\e(0i]A\e(B" 37 1) ("\e(0i]B\e(B" 37 3) ("\e(0i]C\e(B" 37 5) ("\e(0i]D\e(B" 37 7) ; ue
-    ("\e(0h_@\e(B" 33 0) ("\e(0h_A\e(B" 33 1) ("\e(0h_B\e(B" 33 3) ("\e(0h_C\e(B" 33 5) ("\e(0h_D\e(B" 33 7) ; ui
-    ("\e(0hc@\e(B" 34 0) ("\e(0hcA\e(B" 34 1) ("\e(0hcB\e(B" 34 3) ("\e(0hcC\e(B" 34 5) ("\e(0hcD\e(B" 34 7) ; un
-    ("\e(0h[@\e(B" 35 0) ("\e(0h[A\e(B" 35 1) ("\e(0h[B\e(B" 35 3) ("\e(0h[C\e(B" 35 5) ("\e(0h[D\e(B" 35 7) ; uo
-    ("\e(0i@\e(B"  36 0) ("\e(0iA\e(B"  36 1) ("\e(0iB\e(B"  36 3) ("\e(0iC\e(B"  36 5) ("\e(0iD\e(B"  36 7) ; \e(09\e(B
-    ("\e(0i]@\e(B" 37 0) ("\e(0i]A\e(B" 37 1) ("\e(0i]B\e(B" 37 3) ("\e(0i]C\e(B" 37 5) ("\e(0i]D\e(B" 37 7) ; \e(09\e(Be
-    ("0\e(0@\e(B"  38 0) ("1\e(0A\e(B"  38 1) ("2\e(0B\e(B"  38 3) ("3\e(0C\e(B"  38 5) ("4\e(0D\e(B"  38 7) ; undefined
-    ("\e(0ib@\e(B" 39 0) ("\e(0ibA\e(B" 39 1) ("\e(0ibB\e(B" 39 3) ("\e(0ibC\e(B" 39 5) ("\e(0ibD\e(B" 39 7) ; \e(09\e(Ban
-    ("\e(0ic@\e(B" 40 0) ("\e(0icA\e(B" 40 1) ("\e(0icB\e(B" 40 3) ("\e(0icC\e(B" 40 5) ("\e(0icD\e(B" 40 7) ; \e(09\e(Bn
+  '(("\9a À"    0 0) ("\9a Á"    0 1) ("\9a Â"    0 3) ("\9a Ã"    0 5) ("\9a Ä"    0 7) ; i
+    ("\9a Ú\9a À"   1 0) ("\9a Ú\9a Á"   1 1) ("\9a Ú\9a Â"   1 3) ("\9a Ú\9a Ã"   1 5) ("\9a Ú\9a Ä"   1 7) ; a
+    ("\9a Þ\9a À"   2 0) ("\9a Þ\9a Á"   2 1) ("\9a Þ\9a Â"   2 3) ("\9a Þ\9a Ã"   2 5) ("\9a Þ\9a Ä"   2 7) ; ai
+    ("\9a â\9a À"   3 0) ("\9a â\9a Á"   3 1) ("\9a â\9a Â"   3 3) ("\9a â\9a Ã"   3 5) ("\9a â\9a Ä"   3 7) ; an
+    ("\9a ä\9a À"   4 0) ("\9a ä\9a Á"   4 1) ("\9a ä\9a Â"   4 3) ("\9a ä\9a Ã"   4 5) ("\9a ä\9a Ä"   4 7) ; ang
+    ("\9a à\9a À"   5 0) ("\9a à\9a Á"   5 1) ("\9a à\9a Â"   5 3) ("\9a à\9a Ã"   5 5) ("\9a à\9a Ä"   5 7) ; ao
+    ("\9a Ü\9a À"   6 0) ("\9a Ü\9a Á"   6 1) ("\9a Ü\9a Â"   6 3) ("\9a Ü\9a Ã"   6 5) ("\9a Ü\9a Ä"   6 7) ; e
+    ("\9a ß\9a À"   7 0) ("\9a ß\9a Á"   7 1) ("\9a ß\9a Â"   7 3) ("\9a ß\9a Ã"   7 5) ("\9a ß\9a Ä"   7 7) ; ei
+    ("\9a ã\9a À"   8 0) ("\9a ã\9a Á"   8 1) ("\9a ã\9a Â"   8 3) ("\9a ã\9a Ã"   8 5) ("\9a ã\9a Ä"   8 7) ; en
+    ("\9a å\9a À"   9 0) ("\9a å\9a Á"   9 1) ("\9a å\9a Â"   9 3) ("\9a å\9a Ã"   9 5) ("\9a å\9a Ä"   9 7) ; eng
+    ("\9a æ\9a À"  10 0) ("\9a æ\9a Á"  10 1) ("\9a æ\9a Â"  10 3) ("\9a æ\9a Ã"  10 5) ("\9a æ\9a Ä"  10 7) ; er
+    ("\9a ç\9a À"  11 0) ("\9a ç\9a Á"  11 1) ("\9a ç\9a Â"  11 3) ("\9a ç\9a Ã"  11 5) ("\9a ç\9a Ä"  11 7) ; i
+    ("\9a ç\9a Ú\9a À" 12 0) ("\9a ç\9a Ú\9a Á" 12 1) ("\9a ç\9a Ú\9a Â" 12 3) ("\9a ç\9a Ú\9a Ã" 12 5) ("\9a ç\9a Ú\9a Ä" 12 7) ; ia
+    ("\9a ç\9a â\9a À" 13 0) ("\9a ç\9a â\9a Á" 13 1) ("\9a ç\9a â\9a Â" 13 3) ("\9a ç\9a â\9a Ã" 13 5) ("\9a ç\9a â\9a Ä" 13 7) ; ian
+    ("\9a ç\9a ä\9a À" 14 0) ("\9a ç\9a ä\9a Á" 14 1) ("\9a ç\9a ä\9a Â" 14 3) ("\9a ç\9a ä\9a Ã" 14 5) ("\9a ç\9a ä\9a Ä" 14 7) ; iang
+    ("\9a ç\9a à\9a À" 15 0) ("\9a ç\9a à\9a Á" 15 1) ("\9a ç\9a à\9a Â" 15 3) ("\9a ç\9a à\9a Ã" 15 5) ("\9a ç\9a à\9a Ä" 15 7) ; iao
+    ("\9a ç\9a Ý\9a À" 16 0) ("\9a ç\9a Ý\9a Á" 16 1) ("\9a ç\9a Ý\9a Â" 16 3) ("\9a ç\9a Ý\9a Ã" 16 5) ("\9a ç\9a Ý\9a Ä" 16 7) ; ie
+    ("\9a ç\9a ã\9a À" 17 0) ("\9a ç\9a ã\9a Á" 17 1) ("\9a ç\9a ã\9a Â" 17 3) ("\9a ç\9a ã\9a Ã" 17 5) ("\9a ç\9a ã\9a Ä" 17 7) ; in
+    ("\9a ç\9a å\9a À" 18 0) ("\9a ç\9a å\9a Á" 18 1) ("\9a ç\9a å\9a Â" 18 3) ("\9a ç\9a å\9a Ã" 18 5) ("\9a ç\9a å\9a Ä" 18 7) ; ing
+    ("\9a é\9a å\9a À" 19 0) ("\9a é\9a å\9a Á" 19 1) ("\9a é\9a å\9a Â" 19 3) ("\9a é\9a å\9a Ã" 19 5) ("\9a é\9a å\9a Ä" 19 7) ; iong
+    ("\9a ç\9a á\9a À" 20 0) ("\9a ç\9a á\9a Á" 20 1) ("\9a ç\9a á\9a Â" 20 3) ("\9a ç\9a á\9a Ã" 20 5) ("\9a ç\9a á\9a Ä" 20 7) ; iu
+    ("\9a Ç\9a À"  21 0) ("\9a Ç\9a Á"  21 1) ("\9a Ç\9a Â"  21 3) ("\9a Ç\9a Ã"  21 5) ("\9a Ç\9a Ä"  21 7) ; m
+    ("\9a Ë\9a À"  22 0) ("\9a Ë\9a Á"  22 1) ("\9a Ë\9a Â"  22 3) ("\9a Ë\9a Ã"  22 5) ("\9a Ë\9a Ä"  22 7) ; n
+    ("@\9a À"  23 0) ("@\9a Á"  23 1) ("@\9a Â"  23 3) ("@\9a Ã"  23 5) ("@\9a Ä"  23 7) ; ng
+    ("\9a Û\9a À"  24 0) ("\9a Û\9a Á"  24 1) ("\9a Û\9a Â"  24 3) ("\9a Û\9a Ã"  24 5) ("\9a Û\9a Ä"  24 7) ; o
+    ("\9a è\9a å\9a À" 25 0) ("\9a è\9a å\9a Á" 25 1) ("\9a è\9a å\9a Â" 25 3) ("\9a è\9a å\9a Ã" 25 5) ("\9a è\9a å\9a Ä" 25 7) ; ong
+    ("\9a á\9a À"  26 0) ("\9a á\9a Á"  26 1) ("\9a á\9a Â"  26 3) ("\9a á\9a Ã"  26 5) ("\9a á\9a Ä"  26 7) ; ou
+    ("\9a è\9a À"  27 0) ("\9a è\9a Á"  27 1) ("\9a è\9a Â"  27 3) ("\9a è\9a Ã"  27 5) ("\9a è\9a Ä"  27 7) ; u
+    ("\9a è\9a Ú\9a À" 28 0) ("\9a è\9a Ú\9a Á" 28 1) ("\9a è\9a Ú\9a Â" 28 3) ("\9a è\9a Ú\9a Ã" 28 5) ("\9a è\9a Ú\9a Ä" 28 7) ; ua
+    ("\9a è\9a Þ\9a À" 29 0) ("\9a è\9a Þ\9a Á" 29 1) ("\9a è\9a Þ\9a Â" 29 3) ("\9a è\9a Þ\9a Ã" 29 5) ("\9a è\9a Þ\9a Ä" 29 7) ; uai
+    ("\9a è\9a â\9a À" 30 0) ("\9a è\9a â\9a Á" 30 1) ("\9a è\9a â\9a Â" 30 3) ("\9a è\9a â\9a Ã" 30 5) ("\9a è\9a â\9a Ä" 30 7) ; uan
+    ("\9a è\9a ä\9a À" 31 0) ("\9a è\9a ä\9a Á" 31 1) ("\9a è\9a ä\9a Â" 31 3) ("\9a è\9a ä\9a Ã" 31 5) ("\9a è\9a ä\9a Ä" 31 7) ; uang
+    ("\9a é\9a Ý\9a À" 37 0) ("\9a é\9a Ý\9a Á" 37 1) ("\9a é\9a Ý\9a Â" 37 3) ("\9a é\9a Ý\9a Ã" 37 5) ("\9a é\9a Ý\9a Ä" 37 7) ; ue
+    ("\9a è\9a ß\9a À" 33 0) ("\9a è\9a ß\9a Á" 33 1) ("\9a è\9a ß\9a Â" 33 3) ("\9a è\9a ß\9a Ã" 33 5) ("\9a è\9a ß\9a Ä" 33 7) ; ui
+    ("\9a è\9a ã\9a À" 34 0) ("\9a è\9a ã\9a Á" 34 1) ("\9a è\9a ã\9a Â" 34 3) ("\9a è\9a ã\9a Ã" 34 5) ("\9a è\9a ã\9a Ä" 34 7) ; un
+    ("\9a è\9a Û\9a À" 35 0) ("\9a è\9a Û\9a Á" 35 1) ("\9a è\9a Û\9a Â" 35 3) ("\9a è\9a Û\9a Ã" 35 5) ("\9a è\9a Û\9a Ä" 35 7) ; uo
+    ("\9a é\9a À"  36 0) ("\9a é\9a Á"  36 1) ("\9a é\9a Â"  36 3) ("\9a é\9a Ã"  36 5) ("\9a é\9a Ä"  36 7) ; \9a ¹
+    ("\9a é\9a Ý\9a À" 37 0) ("\9a é\9a Ý\9a Á" 37 1) ("\9a é\9a Ý\9a Â" 37 3) ("\9a é\9a Ý\9a Ã" 37 5) ("\9a é\9a Ý\9a Ä" 37 7) ; \9a ¹e
+    ("0\9a À"  38 0) ("1\9a Á"  38 1) ("2\9a Â"  38 3) ("3\9a Ã"  38 5) ("4\9a Ä"  38 7) ; undefined
+    ("\9a é\9a â\9a À" 39 0) ("\9a é\9a â\9a Á" 39 1) ("\9a é\9a â\9a Â" 39 3) ("\9a é\9a â\9a Ã" 39 5) ("\9a é\9a â\9a Ä" 39 7) ; \9a ¹an
+    ("\9a é\9a ã\9a À" 40 0) ("\9a é\9a ã\9a Á" 40 1) ("\9a é\9a ã\9a Â" 40 3) ("\9a é\9a ã\9a Ã" 40 5) ("\9a é\9a ã\9a Ä" 40 7) ; \9a ¹n
     ))
 
 (defconst yincode-zhuyin-table
 
 (defun egg-pinyin-syllable (str)
   (let (s y end)
-    (if (string-match "^[A-Za-z\e(0!\e(B-\e(0?\e(B]+\e(0@\e(B" str)
+    (if (string-match "^[A-Za-z\9a ¡-\9a ¿]+\9a À" str)
        (progn
          (setq end (match-end 0))
          (cond
 
 (defun egg-zhuyin-syllable (str)
   (let (end s y c z (zhuyin-len (charset-bytes 'chinese-sisheng)))
-    (if (string-match "^[\e(0E\e(B-\e(0i\e(B@0-4]+[\e(0@ABCD\e(B]" str)
+    (if (string-match "^[\9a Å-\9a é@0-4]+[\9a À\9a Á\9a Â\9a Ã\9a Ä]" str)
        (progn
          (setq end (match-end 0)
                c (substring str 0 zhuyin-len)
 
 (defun encode-fixed-euc-china-region (beg end type)
   "Encode the text in the region to EUC-CN/TW."
-  (let (s syl c cset (maxlen (max (length "Zhu\e(0!\e(Bng\e(0@\e(B") (length "\e(0ShdA\e(B"))))
+  (let (s syl c cset (maxlen (max (length "Zhu\9a ¡ng\9a À") (length "\9a Ó\9a è\9a ä\9a Á"))))
     (save-excursion
       (save-restriction
        (narrow-to-region beg end)
diff --git a/egg-edep.el b/egg-edep.el
new file mode 100644 (file)
index 0000000..2d1e3d9
--- /dev/null
@@ -0,0 +1,44 @@
+;; This file serves Emacs version dependent definitions
+
+(if (and (fboundp 'set-buffer-multibyte)
+        (subrp (symbol-function 'set-buffer-multibyte)))
+    ;; Emacs 20.3
+    (progn
+      (defun egg-char-bytes (x) 1)
+      (defun egg-charset-bytes (x) 1)
+      (defun egg-char-bytes-at (str pos) 1)
+      (defun egg-chars-in-period (str pos len) len)
+      (defalias 'egg-string-to-vector 'identity)
+      (defalias 'egg-string-to-char-at 'aref)
+      )
+  ;; Emacs 20.2
+  (defun set-buffer-multibyte (flag)
+    (setq enable-multibyte-characters flag))
+  (defalias 'string-as-unibyte 'identity)
+  (defalias 'string-as-multibyte 'identity)
+  (defalias 'coding-system-put 'put)
+
+  (defalias 'egg-char-bytes 'char-bytes)
+  (defalias 'egg-charset-bytes 'charset-bytes)
+  (defun egg-char-bytes-at (str pos)
+    (char-bytes (egg-string-to-char-at str pos)))
+  (defun egg-chars-in-period (str pos len)
+    (chars-in-string (substring str pos (+ pos len))))
+  (defalias 'egg-string-to-vector 'string-to-vector)
+  (defun egg-string-to-char-at (str pos)
+    (let ((c (aref str pos)))
+      (if (or (< c ?\200)
+             (>= c ?\240)
+             (>= (1+ pos) (length str))
+             (< (aref str (1+ pos)) ?\240))
+         c
+       (string-match "[\240-\377]+" str (1+ pos))
+       (string-to-char (substring str pos (match-end 0))))))
+  )
+
+;; Elisp bug fix
+
+(defun egg-next-single-property-change (pos prop &optional object limit)
+  (min limit (next-single-property-change pos prop object (1+ limit))))
+
+(provide 'egg-edep)
index a520acf..588e9db 100644 (file)
@@ -6,7 +6,6 @@
 ;; Project Leader: Satoru Tomura <tomura@etl.go.jp>
 
 ;; Author: NIIBE Yutaka <gniibe@mri.co.jp>
-;;         KATAYAMA Yoshio <kate@pfu.co.jp>      ; Multilingual Enhancement
 ;; Maintainer: NIIBE Yutaka <gniibe@mri.co.jp>
 ;; Keywords: mule, multilingual, input method
 
@@ -39,9 +38,7 @@ Do `mlh-backward-henkan'.  Then, invoke appropriate conversion, if needed.
 Or else, execute command that space-bar invokes usually."
   (interactive)
   (let ((henkan-begin nil)
-        (inhibit-henkan t)
-        (its-disable-special-action t))
-    (its-select-hiragana)    ;; force to Japanese
+        (inhibit-henkan t))
     (mlh-backward-henkan)
     (if henkan-begin
         (if (or inhibit-henkan (= henkan-begin (point)))
@@ -49,6 +46,7 @@ Or else, execute command that space-bar invokes usually."
           (progn
             (message "Converting...")
             (sit-for 0)
+           (put-text-property henkan-begin (point) 'its-lang "Japanese")
            (egg-convert-region henkan-begin (point))
             (message "") ))
       (setq this-command 'self-insert-command)
@@ -93,7 +91,7 @@ Or else, execute command that space-bar invokes usually."
     (?q . mlh-quit)
 ;    (?r . mlh-)
     (?s . mlh-small-letter)
-    (?t . mlh-zhongwen-tw)
+;    (?t . mlh-)
     (?u . mlh-kanji)
 ;    (?v . mlh-)
     (?w . mlh-white-space)
@@ -446,7 +444,7 @@ CHAR.  MNEMONIC             CONVERSION SCHEME
   (setq beg (point))
   (goto-char end-marker)
   (forward-char -1)
-  (its-translate-region-internal beg (point))
+  (its-translate-region beg (point))
   (delete-region (point) end-marker)
   (if (null henkan-begin)
       (setq henkan-begin beg)))
@@ -458,7 +456,7 @@ CHAR.  MNEMONIC             CONVERSION SCHEME
   (setq beg (point))
   (goto-char end-marker)
   (forward-char -2)
-  (its-translate-region-internal beg (point))
+  (its-translate-region beg (point))
   (delete-region (point) end-marker)
   (setq henkan-begin (point)))
 
@@ -480,7 +478,7 @@ CHAR.  MNEMONIC             CONVERSION SCHEME
   (setq beg (point))
   (goto-char end-marker)
   (forward-char -2)
-  (its-translate-region-internal beg (point))
+  (its-translate-region beg (point))
   (insert (mlh-hira-to-kata
           (prog1
               (buffer-substring beg (point))
@@ -509,50 +507,5 @@ CHAR.  MNEMONIC             CONVERSION SCHEME
       (setq i (+ i 3)))
     result))
 
-(defun mlh-hangul ()
-  (forward-char -1)
-  (skip-chars-backward "a-zEO-RTW,.[]")
-  (mlh-backward-henkan)
-  (setq beg (point))
-  (setq inhibit-henkan nil)
-  (goto-char end-marker)
-  (forward-char -2)
-  (let (its-current-map its-current-language)
-    (its-select-hangul t)
-    (its-translate-region-internal beg (point)))
-  (delete-region (point) end-marker)
-  (if (null henkan-begin)
-      (setq henkan-begin beg)))
-
-(defun mlh-zhongwen ()
-  (forward-char -1)
-  (skip-chars-backward "a-z0-4 ,.[]")
-  (mlh-backward-henkan)
-  (setq beg (point))
-  (setq inhibit-henkan nil)
-  (goto-char end-marker)
-  (forward-char -2)
-  (let (its-current-map its-current-language)
-    (its-select-pinyin-cn t)
-    (its-translate-region-internal beg (point)))
-  (delete-region (point) end-marker)
-  (if (null henkan-begin)
-      (setq henkan-begin beg)))
-
-(defun mlh-zhongwen-tw ()
-  (forward-char -1)
-  (skip-chars-backward "a-z0-4,.[]")
-  (mlh-backward-henkan)
-  (setq beg (point))
-  (setq inhibit-henkan nil)
-  (goto-char end-marker)
-  (forward-char -2)
-  (let (its-current-map its-current-language)
-    (its-select-pinyin-tw t)
-    (its-translate-region-internal beg (point)))
-  (delete-region (point) end-marker)
-  (if (null henkan-begin)
-      (setq henkan-begin beg)))
-
 (provide 'egg-mlh)
 ;;; egg-mlh.el ends here.
diff --git a/egg.el b/egg.el
index a88bcf2..c8403a0 100644 (file)
--- a/egg.el
+++ b/egg.el
@@ -35,6 +35,8 @@
 (defvar egg-default-language "Japanese")
 (defvar egg-last-method-name)
 (make-variable-buffer-local 'egg-last-method-name)
+(defvar egg-mode-line-title)
+(make-variable-buffer-local 'egg-mode-line-title)
 
 ;;;###autoload
 (defun egg-mode (&rest arg)
          (egg-exit-conversion)))
        (setq describe-current-input-method-function nil)
        (setq current-input-method nil)
-       (use-local-map (keymap-parent (current-local-map)))
-       (force-mode-line-update))
+       (let ((orig-local-map (keymap-parent (current-local-map))))
+         (use-local-map orig-local-map))
+       (run-hooks 'input-method-inactivate-hook))
     ;; Turn on
     (if (null (string= (car arg) egg-last-method-name))
        (progn
          (funcall (nth 1 arg))
-         (egg-set-conversion-backend nil (list its-current-language) t)
-         (setq egg-default-language its-current-language)))
+        (setq egg-default-language its-current-language)))
     (setq egg-last-method-name (car arg))
     (use-local-map (if egg-mode-preference
                       (egg-modefull-map)
                     (egg-modeless-map)))
     (setq inactivate-current-input-method-function 'egg-mode)
     (setq describe-current-input-method-function 'egg-help)
-    (add-hook 'input-method-activate-hook 'its-set-mode-line-title)))
+    (run-hooks 'input-method-activate-hook))
+  (force-mode-line-update))
+
+(defun egg-set-mode-line-title (title)
+  (setq egg-mode-line-title title)
+  (force-mode-line-update))
+
+(defun egg-check-language (lang)
+  (if (null (member lang egg-support-languages))
+      (error "%S is not supported" lang)))
 
 (defun egg-modefull-map ()
   "Generate modefull keymap for EGG mode."  
@@ -76,7 +87,6 @@
     (while (< i 127)
       (define-key map (vector i) 'egg-self-insert-char)
       (setq i (1+ i)))
-    (its-define-select-keys map)
     (set-keymap-parent map (current-local-map))
     map))
 
diff --git a/egg/canna.el b/egg/canna.el
new file mode 100644 (file)
index 0000000..c401aa2
--- /dev/null
@@ -0,0 +1,287 @@
+;;; egg/canna.el --- Canna Support (high level interface) in
+;;;                  Egg Input Method Architecture
+
+;; Copyright (C) 1998 Mule Project,
+;; Powered by Electrotechnical Laboratory, JAPAN.
+;; Project Leader: Satoru Tomura <tomura@etl.go.jp>
+
+;; Author: NIIBE Yutaka <gniibe@mri.co.jp>
+;; Maintainer: NIIBE Yutaka <gniibe@mri.co.jp>
+
+;; This file is part of EGG.
+
+;; EGG is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; 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 General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+
+;;; Code:
+
+(require 'egg-edep)
+
+(defconst canna-support-languages '(Japanese))
+
+(eval-when-compile
+  (defmacro CANNA-const (c)
+    (cond ((eq c 'FileNotExist) xxxxxxxxxxxxxx)
+         )))
+
+(defconst canna-conversion-backend
+  [ canna-init
+
+    canna-start-conversion
+      canna-get-bunsetsu-converted
+      canna-get-bunsetsu-source
+      canna-list-candidates
+          canna-get-number-of-candidates
+          canna-get-current-candidate-number
+          canna-get-all-candidates
+          canna-decide-candidate
+      canna-change-bunsetsu-length
+    canna-end-conversion
+    nil
+
+    canna-fini
+ ])
+
+(defconst canna-server-port 5680 "Port number of Canna server")
+(defvar canna-hostname "localhost"
+  "Hostname of Canna server")
+
+(defun canna-open (hostname)
+  "Establish the connection to CANNA server.  Return environment object."
+  (let* ((buf (generate-new-buffer " *CANNA*"))
+        (proc (open-network-stream "CANNA" buf hostname canna-server-port))
+        result)
+    (process-kill-without-query proc)
+    (set-process-coding-system proc 'no-conversion 'no-conversion)
+    (set-marker-insertion-type (process-mark proc) t)
+    (save-excursion
+      (set-buffer buf)
+      (erase-buffer)
+      (buffer-disable-undo)
+      (set-buffer-multibyte nil))
+    (setq result (cannarpc-open proc (user-login-name)))
+    (if (< result 0)
+       (let ((msg (cannarpc-get-error-message (- result))))
+         (delete-process proc)
+         (kill-buffer buf)
+         (error "Can't open CANNA session (%s): %s" hostname msg)))
+    (vector proc result)))
+
+;; XXX: Should support multiple outstanding context
+;; <env> ::= [ <proc> <context> ]
+(defvar canna-environment nil
+  "Environment for CANNA kana-kanji conversion")
+
+(defsubst cannaenv-get-proc (env)
+  (aref env 0))
+(defsubst cannaenv-get-context (env)
+  (aref env 1))
+
+;; <bunsetsu> ::=
+;;  [ <env> <converted> <bunsetsu-pos>
+;;    <source> <zenkouho-pos> <zenkouho> ]
+(defsubst canna-make-bunsetsu (env converted bunsetsu-pos)
+  (vector env converted bunsetsu-pos nil nil nil))
+
+(defsubst cannabunsetsu-get-env (b)
+  (aref b 0))
+(defsubst cannabunsetsu-get-converted (b)
+  (aref b 1))
+(defsubst cannabunsetsu-get-bunsetsu-pos (b)
+  (aref b 2))
+(defsubst cannabunsetsu-get-source (b)
+  (aref b 3))
+(defsubst cannabunsetsu-set-source (b s)
+  (aset b 3 s))
+(defsubst cannabunsetsu-get-zenkouho-pos (b)
+  (aref b 4))
+(defsubst cannabunsetsu-set-zenkouho-pos (b p)
+  (aset b 4 p))
+(defsubst cannabunsetsu-get-zenkouho (b)
+  (aref b 5))
+(defsubst cannabunsetsu-set-zenkouho (b z)
+  (aset b 5 z))
+
+(defun canna-get-bunsetsu-source (b)
+  (let ((s (cannabunsetsu-get-source b)))
+    (or s
+       (let* ((env (cannabunsetsu-get-env b))
+              (bp (cannabunsetsu-get-bunsetsu-pos b))
+              (s (cannarpc-get-bunsetsu-source env bp)))
+         (cannabunsetsu-set-source b s)))))
+
+(defun canna-get-bunsetsu-converted (b)
+  (cannabunsetsu-get-converted b))
+
+(defconst canna-dictionary-specification
+  '("iroha"
+    "fuzokugo"
+    "hojomwd"
+    "hojoswd"
+    "bushu"
+    ("user")
+    )
+  "Dictionary specification of CANNA.")
+
+(defun canna-filename (p)
+  ""
+  (cond ((consp p) (concat (car p) "/" (user-login-name)))
+       (t p)))
+
+(defun canna-get-environment ()
+  "Return the backend of CANNA environment."
+  (if canna-environment
+      canna-environment
+    (let* ((env (canna-open canna-hostname))
+          (l canna-dictionary-specification)
+          dict-list)
+      (while l
+       (let ((dic (car l))
+             result)
+         (setq result
+               (canna-open-dictionary env (canna-filename dic)))
+         (if (= result 255)
+             (error "Damedamedame")            ; XXX
+           (setq l (cdr l)))))
+      (setq canna-environment env))))
+
+(defun canna-open-dictionary (env name)
+  (let ((trying t)
+       ret)
+    (while trying
+      (setq ret (cannarpc-open-dictionary env name 0)) ; XXX MODE=0
+      (if (= ret 0)
+         (setq trying nil)
+       (message "\e$B<-=q%U%!%$%k\e(B(%s)\e$B$,$"$j$^$;$s\e(B" name)
+       (setq ret (- ret))              ; Get error code.
+       (if (and (y-or-n-p
+                 (format "\e$B<-=q%U%!%$%k\e(B(%s)\e$B$,$"$j$^$;$s!#:n$j$^$9$+\e(B? "
+                         name))
+                (= (cannarpc-make-dictionary env name) 0))
+           (message "\e$B<-=q%U%!%$%k\e(B(%s)\e$B$r:n$j$^$7$?\e(B" name)
+         (error "Fatal"))))
+    ret))
+
+(defun canna-init ()
+  )
+
+(defun canna-start-conversion (yomi lang)
+  "Convert YOMI string to kanji, and enter conversion mode.
+Return the list of bunsetsu."
+  (let ((env (canna-get-environment)))
+    (cannarpc-begin-conversion env yomi)))
+
+(defun canna-end-conversion (bunsetsu-list abort)
+  (let* ((env (cannabunsetsu-get-env (car bunsetsu-list)))
+        (l bunsetsu-list)
+        (len (length bunsetsu-list))
+        (zenkouho-pos-vector (make-vector (* 2 len) 0))
+        (i 0)
+        (mode 1) ;XXX MODE=1 attru?
+        bunsetsu zenkouho-pos)
+    (if abort
+       (setq mode 0))
+    (while l
+      (setq bunsetsu (car l))
+      (setq l (cdr l))
+      (setq zenkouho-pos (cannabunsetsu-get-zenkouho-pos bunsetsu))
+      (if (null zenkouho-pos)
+         () ; XXX: NIL--> 0 atteru???
+       (aset zenkouho-pos-vector i 0)  ; XXX Don't support >=256
+       (aset zenkouho-pos-vector (1+ i) zenkouho-pos))
+      (setq i (+ i 2)))
+    (cannarpc-end-conversion env len zenkouho-pos-vector 0)))
+
+(defun canna-list-candidates (bunsetsu prev-bunsetsu)
+  (let* ((env (cannabunsetsu-get-env bunsetsu))
+        (bunsetsu-pos (cannabunsetsu-get-bunsetsu-pos bunsetsu))
+        (z (cannarpc-get-bunsetsu-candidates env bunsetsu-pos)))
+    (cannabunsetsu-set-zenkouho bunsetsu z)
+    (cannabunsetsu-set-zenkouho-pos bunsetsu 0)
+    0))
+
+(defun canna-get-number-of-candidates (bunsetsu)
+  (let ((l (cannabunsetsu-get-zenkouho bunsetsu)))
+    (if l
+       (length l)
+      nil)))
+
+(defun canna-decide-candidate (bunsetsu candidate-pos)
+  (let* ((candidate-list (cannabunsetsu-get-zenkouho bunsetsu))
+        (candidate (nth candidate-pos candidate-list)))
+    (cannabunsetsu-set-zenkouho candidate candidate-list)
+    (cannabunsetsu-set-zenkouho-pos candidate candidate-pos)
+    candidate))
+
+(defun canna-get-current-candidate-number (bunsetsu)
+  (cannabunsetsu-get-zenkouho-pos bunsetsu))
+
+(defun canna-get-all-candidates (bunsetsu)
+  (let* ((l (cannabunsetsu-get-zenkouho bunsetsu))
+        (result (cons nil nil))
+        (r result))
+    (catch 'break
+      (while t
+       (let ((candidate (car l)))
+         (setcar r (cannabunsetsu-get-converted candidate))
+         (if (null (setq l (cdr l)))
+             (throw 'break nil)
+           (setq r (setcdr r (cons nil nil)))))))
+    result))
+
+;;;;;;;;;;;;;;;;;;;;;;; MADAMADA zenzendame, just copy from SJ3
+(defun canna-change-bunsetsu-length (b0 b1 b2 len)
+  (let ((yomi (concat
+              (cannabunsetsu-get-source b1)
+              (if b2 (cannabunsetsu-get-source b2))))
+       (env (cannabunsetsu-get-env b1))
+       yomi1 yomi2
+       bunsetsu1 bunsetsu2)
+    (setq yomi1 (substring yomi 0 len)
+         yomi2 (substring yomi len))
+    (setq bunsetsu1
+         (cannarpc-tanbunsetsu-conversion env yomi1))
+    ;; Only set once (memory original length of the bunsetsu).
+    (cannabunsetsu-set-kugiri-changed bunsetsu1
+                                   (or (cannabunsetsu-get-kugiri-changed b1)
+                                       (length (cannabunsetsu-get-source b1))))
+    (if (< 0 (length yomi2))
+       (setq bunsetsu2 (cannarpc-tanbunsetsu-conversion env yomi2))
+      (setq bunsetsu2 nil))
+    (if bunsetsu2
+       (list bunsetsu1 bunsetsu2)
+      (list bunsetsu1))))
+
+;;;;;;;;;;;;;; MADAMADA
+(defun canna-fini (lang)
+)
+
+;;; setup
+
+(require 'egg)
+(load "egg/cannarpc")
+
+;;;###autoload
+(defun egg-activate-canna (&rest arg)
+  "Activate CANNA backend of Tamagotchy."
+  (egg-set-support-languages canna-support-languages)
+  (egg-set-conversion-backend canna-conversion-backend 
+                             canna-support-languages
+                             nil)
+  (apply 'egg-mode arg))
+
+;;; egg/canna.el ends here.
index 0342dce..6f059a7 100644 (file)
           sj3-decide-candidate
       sj3-change-bunsetsu-length
     sj3-end-conversion
-    nil
 
     sj3-fini
  ])
 
-(defvar sj3-server-port 3000 "Port number of SJ3 server")
+(defconst sj3-server-port 3000 "Port number of SJ3 server")
 (defvar sj3-stdy-size 0 "STDYSIZE of SJ3 server")
 (defvar sj3-hostname "localhost"
   "Hostname of SJ3 server")
 
-(defvar sj3-open-message)
-
-(defun sj3-open (hostname-list)
+(defun sj3-open (hostname)
   "Establish the connection to SJ3 server.  Return process object."
   (let* ((buf (generate-new-buffer " *SJ3*"))
-        (msg-form "SJ3: connecting to sj3serv at %s...")
-        hostname proc result msg)
+        (proc (open-network-stream "SJ3" buf hostname sj3-server-port))
+        result)
+    (process-kill-without-query proc)
+    (set-process-coding-system proc 'no-conversion 'no-conversion)
+    (set-marker-insertion-type (process-mark proc) t)
     (save-excursion
       (set-buffer buf)
       (erase-buffer)
       (buffer-disable-undo)
       (setq enable-multibyte-characters nil))
-    (cond
-     ((null hostname-list)
-      (setq hostname-list '("localhost")))
-     ((null (listp hostname-list))
-      (setq hostname-list (list hostname-list))))
-    (while (and hostname-list (null proc))
-      (setq hostname (car hostname-list)
-           hostname-list (cdr hostname-list))
-      (message msg-form hostname)
-      (sit-for 0)
-      (condition-case result
-         (setq proc (open-network-stream "SJ3" buf hostname sj3-server-port))
-       (error nil))
-      (if proc
-         (progn
-           (process-kill-without-query proc)
-           (set-process-coding-system proc 'no-conversion 'no-conversion)
-           (set-marker-insertion-type (process-mark proc) t)
-           ;; Initialize dictionaries
-           (setq sj3-sys-dict-list nil)
-           (setq sj3-user-dict-list nil)
-           (setq result (sj3rpc-open proc (system-name) (user-login-name)))
-           (if (< result 0)
-               (progn
-                 (delete-process proc)
-                 (setq proc nil
-                       msg (format "Can't open SJ3 session (%s): %s"
-                                   hostname msg)))
-             (setq result (sj3rpc-get-stdy-size proc))
-             (if (< result 0)
-                 (progn
-                   (delete-process proc)
-                   (setq proc nil
-                         msg (format "Can't get SJ3 STDYSIZE: %s"
-                                     (sj3rpc-get-error-message (- result)))))
-               (setq sj3-stdy-size result))))))
-    (if proc
-       (progn
-         (setq sj3-open-message (format (concat msg-form "done") hostname))
-         proc)
-      (kill-buffer buf)
-      (error "%s" (or msg "no sj3serv available")))))
+    ;; Initialize dictionaries
+    (setq sj3-sys-dict-list nil)
+    (setq sj3-user-dict-list nil)
+    (setq result (sj3rpc-open proc (system-name) (user-login-name)))
+    (if (< result 0)
+       (let ((msg (sj3rpc-get-error-message (- result))))
+         (delete-process proc)
+         (kill-buffer buf)
+         (error "Can't open SJ3 session (%s): %s" hostname msg)))
+    (setq result (sj3rpc-get-stdy-size proc))
+    (if (< result 0)
+       (let ((msg (sj3rpc-get-error-message (- result))))
+         (delete-process proc)
+         (kill-buffer buf)
+         (error "Can't get SJ3 STDYSIZE: %s"msg)))
+    (setq sj3-stdy-size result)
+    proc))
 
 ;; <env> ::= [ <proc> <dictionary-list> ]
 (defvar sj3-environment nil
            (if (< dic-id 0)
                (error "Dame2")         ; XXX
              (setq dict-list (cons dic-id dict-list)
-                   l (cdr l)))))
-       (message "%s" sj3-open-message)
-       (setq sj3-environment (vector proc dict-list))))))
+                   l (cdr l))))))
+       (setq sj3-environment (vector proc dict-list)))))
 
 (defun sj3-init ()
   )
 
-(defun sj3-start-conversion (yomi &optional lang)
+(defun sj3-start-conversion (yomi lang)
   "Convert YOMI string to kanji, and enter conversion mode.
 Return the list of bunsetsu."
   (let ((env (sj3-get-environment)))
@@ -279,7 +253,8 @@ Return the list of bunsetsu."
   "Activate SJ3 backend of Tamagotchy."
   (egg-set-support-languages sj3-support-languages)
   (egg-set-conversion-backend sj3-conversion-backend 
-                             sj3-support-languages)
+                             sj3-support-languages
+                             nil)
   (apply 'egg-mode arg))
 
 ;;; egg/sj3.el ends here.
index a7eda4c..c92dbb7 100644 (file)
          ((eq c 'VERSION)       103)
          (t (error "No such constant")))))
 
-;; XXX
-(defconst sj3rpc-error-message (vector ))
-
 (defun sj3rpc-get-error-message (errno)
-  (or (and (>= errno 0)
-          (< errno (length sj3rpc-error-message))
-          (aref sj3rpc-error-message errno))
-      (format "#%d" errno)))
+  (or (aref sj3rpc-error-message errno) (format "#%d" errno)))
 
 (defmacro sj3rpc-call-with-environment (e vlist send-expr &rest receive-exprs)
   (let ((v (append
index 22822b3..a07977e 100644 (file)
@@ -60,7 +60,6 @@
           wnn-decide-candidate
       wnn-change-bunsetsu-length
     wnn-end-conversion
-    wnn-start-reverse-conversion
 
     wnn-fini
  ])
 (defvar wnn-environments nil
   "Environment for WNN kana-kanji conversion")
 
-(defcustom wnn-jserver nil "jserver host list" :group 'wnn :type 'string)
-(defcustom wnn-cserver nil "cserver host list" :group 'wnn :type 'string)
-(defcustom wnn-tserver nil "tserver host list" :group 'wnn :type 'string)
-(defcustom wnn-kserver nil "kserver host list" :group 'wnn :type 'string)
-
-(defcustom wnn-jport 22273 "jserver port number" :group 'wnn :type 'integer)
-(defcustom wnn-cport 22289 "cserver port number" :group 'wnn :type 'integer)
-(defcustom wnn-tport 22321 "tserver port number" :group 'wnn :type 'integer)
-(defcustom wnn-kport 22305 "kserver port number" :group 'wnn :type 'integer)
+(defcustom wnn-jserver "localhost" "jserver host" :group 'wnn :type 'string)
+(defcustom wnn-cserver "localhost" "cserver host" :group 'wnn :type 'string)
+(defcustom wnn-tserver "localhost" "tserver host" :group 'wnn :type 'string)
+(defcustom wnn-kserver "localhost" "kserver host" :group 'wnn :type 'string)
 
 ;; The port number should be initialized from $WNNLIB/serverdefs by wnn-init
 (defconst wnn-server-info-list
-  ;; language      locale  server  port     stream coding-system hostname
-  '(("Japanese"    "ja_JP" jserver wnn-jport "Wnn"  fixed-euc-jp wnn-jserver)
-    ("Chinese-GB"  "zh_CN" cserver wnn-cport "cWnn" fixed-euc-cn wnn-cserver)
-    ("Chinese-CNS" "zh_TW" tserver wnn-tport "tWnn" fixed-euc-tw wnn-tserver)
-    ("Korean"      "ko_KR" kserver wnn-kport "kWnn" fixed-euc-kr wnn-kserver)))
+  ;; language      locale  server  port  stream coding-system hostname
+  '(("Japanese"    "ja_JP" jserver 22273 "Wnn"  fixed-euc-jp wnn-jserver)
+    ("Chinese-GB"  "zh_CN" cserver 22289 "cWnn" fixed-euc-cn wnn-cserver)
+    ("Chinese-CNS" "zh_TW" tserver 22321 "tWnn" fixed-euc-tw wnn-tserver)
+    ("Korean"      "ko_KR" kserver 22305 "kWnn" fixed-euc-kr wnn-kserver)))
 
 (defun wnn-get-server-info (lang)
   (let (info)
   (nth 2 info))
 
 (defsubst wnn-server-port (info)
-  (symbol-value (nth 3 info)))
+  (nth 3 info))
 
 (defsubst wnn-server-stream-name (info)
   (nth 4 info))
@@ -213,9 +207,6 @@ Return the list of bunsetsu."
     (wnnenv-set-daibunsetsu-info env (car result))
     (cdr result)))
 
-(defun wnn-start-reverse-conversion (yomi &optional language dic-set)
-  (wnn-start-conversion yomi language dic-set t))
-
 (defun wnn-get-bunsetsu-converted (bunsetsu)
   (concat (wnn-bunsetsu-get-converted bunsetsu)
          (wnn-bunsetsu-get-fuzokugo  bunsetsu)))
@@ -399,65 +390,43 @@ Return the list of bunsetsu."
              l (cdr l))))))
 
 ;;
-(defvar wnn-open-message)
-
 (defun wnn-open (server-info)
   "Establish the connection to WNN server.  Return process object."
   ;; Open the session to WNN server, 
   (let ((buf (generate-new-buffer (wnn-server-buffer-name server-info)))
-       (server-type (wnn-server-type server-info))
-       (hostname-list (wnn-server-hostname server-info))
-       (msg-form "WNN: connecting to %S at %s...")
-       hostname proc result msg)
+       (hostname (wnn-server-hostname server-info))
+       proc result)
+    (condition-case result
+       (setq proc (open-network-stream (wnn-server-stream-name server-info)
+                                       buf
+                                       hostname
+                                       (wnn-server-port server-info)))
+      (error (progn
+              (kill-buffer buf)
+              (signal (car result) (cdr result)))))
+    (process-kill-without-query proc)
+    (set-process-coding-system proc 'no-conversion 'no-conversion)
+    (set-process-sentinel proc 'wnn-comm-sentinel)
+    (set-marker-insertion-type (process-mark proc) t)
     (save-excursion
       (set-buffer buf)
       (erase-buffer)
       (buffer-disable-undo)
       (setq enable-multibyte-characters nil
            egg-fixed-euc (wnn-server-coding-system server-info)))
-    (cond
-     ((null hostname-list)
-      (setq hostname-list '("localhost")))
-     ((null (listp hostname-list))
-      (setq hostname-list (list hostname-list))))
-    (while (and hostname-list (null proc))
-      (setq hostname (car hostname-list)
-           hostname-list (cdr hostname-list))
-      (message msg-form server-type hostname)
-      (sit-for 0)
-      (condition-case result
-         (setq proc (open-network-stream (wnn-server-stream-name server-info)
-                                         buf
-                                         hostname
-                                         (wnn-server-port server-info)))
-       (error nil))
-      (if proc
-         (progn
-           (process-kill-without-query proc)
-           (set-process-coding-system proc 'no-conversion 'no-conversion)
-           (set-process-sentinel proc 'wnn-comm-sentinel)
-           (set-marker-insertion-type (process-mark proc) t)
-           (setq result (wnnrpc-open proc
-                                     (if (equal hostname "localhost")
-                                         "unix"
-                                       (system-name))
-                                     (user-login-name)))
-           (if (< result 0)
-               (progn
-                 (delete-process proc)
-                 (setq proc nil
-                       msg (format "Can't open WNN session (%s %S): %s"
-                                   hostname
-                                   (wnn-server-type server-info)
-                                   msg)))))))
-    (if proc
-       (progn
-         (setq wnn-open-message (format (concat msg-form "done")
-                                        server-type
-                                        hostname))
-         proc)
-      (kill-buffer buf)
-      (error "%s" (or msg (format "no %S available" server-type))))))
+    (setq result (wnnrpc-open proc
+                             (if (equal hostname "localhost")
+                                 "unix"
+                               (system-name))
+                             (user-login-name)))
+    (if (< result 0)
+       (let ((msg (wnnrpc-get-error-message (- result))))
+         (delete-process proc)
+         (kill-buffer buf)
+         (error "Can't open WNN session (%s %S): %s"
+                hostname
+                (wnn-server-type server-info) msg))
+      proc)))
 
 (defvar wnn-dictionary-specification-list
   '((jserver
@@ -753,12 +722,6 @@ REVERSE specifies reverse conversion, if non nil."
                 (eq (wnn-dic-spec-reverse s) reverse))
            (setq env e))
        (setq spec (cdr spec)))
-      (if (null env)
-         (error "WNN: environment for %S%s (%s) not found"
-                server-type
-                (if dic-set (format "(%S)" dic-set) "")
-                (if reverse 'reverse 'normal)))
-      (message "%s" wnn-open-message)
       env)))
 
 (defun wnn-create-environment (proc server-type spec)
@@ -921,6 +884,7 @@ REVERSE specifies reverse conversion, if non nil."
   "Activate Wnn backend of Tamagotchy."
   (egg-set-support-languages wnn-support-languages)
   (egg-set-conversion-backend wnn-conversion-backend
+                             (list (nth 2 arg))
                              wnn-support-languages)
   (apply 'egg-mode arg))
 
diff --git a/euc-china.el b/euc-china.el
new file mode 100644 (file)
index 0000000..ebcfb00
--- /dev/null
@@ -0,0 +1,484 @@
+;;; euc-china.el --- Fixed EUC-CN/TW handling routines.
+
+;; Copyright (C) 1997, 1998 Mule Project,
+;; Powered by Electrotechnical Laboratory, JAPAN.
+;; Project Leader: Satoru Tomura <tomura@etl.go.jp>
+
+;; Author: KATAYAMA Yoshio <kate@pfu.co.jp>
+;; Maintainer: KATAYAMA Yoshio <kate@pfu.co.jp>
+;; Keywords: mule, multilingual, input method, chinese
+
+;; This file will be part of GNU Emacs (in future).
+
+;; EGG is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; 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 General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+
+
+;;; Code:
+
+(defvar egg-zhuyin nil)
+
+(defconst yincode-pinyin-shengmu
+  '((""  . 0)  ("B" . 1)  ("C"  . 2)  ("Ch" . 3)  ("D" . 4)
+    ("F" . 5)  ("G" . 6)  ("H"  . 7)  ("J"  . 8)  ("K" . 9)
+    ("L" . 10) ("M" . 11) ("N"  . 12) ("P"  . 13) ("Q" . 14)
+    ("R" . 15) ("S" . 16) ("Sh" . 17) ("T"  . 18) ("W" . 19)
+    ("X" . 20) ("Y" . 21) ("Z"  . 22) ("Zh" . 23)))
+
+(defconst yincode-pinyin-yunmu
+  '(("\e(0@\e(B"      0 0) ("\e(0@\e(B"      0 1) ("\e(0@\e(B"      0 3) ("\e(0@\e(B"      0 5) ("\e(0@\e(B"      0 7)
+    ("a\e(0@\e(B"     1 0) ("\e(0!@\e(B"     1 1) ("\e(0"@\e(B"     1 3) ("\e(0#@\e(B"     1 5) ("\e(0$@\e(B"     1 7)
+    ("ai\e(0@\e(B"    2 0) ("\e(0!\e(Bi\e(0@\e(B"    2 1) ("\e(0"\e(Bi\e(0@\e(B"    2 3) ("\e(0#\e(Bi\e(0@\e(B"    2 5) ("\e(0$\e(Bi\e(0@\e(B"    2 7)
+    ("an\e(0@\e(B"    3 0) ("\e(0!\e(Bn\e(0@\e(B"    3 1) ("\e(0"\e(Bn\e(0@\e(B"    3 3) ("\e(0#\e(Bn\e(0@\e(B"    3 5) ("\e(0$\e(Bn\e(0@\e(B"    3 7)
+    ("ang\e(0@\e(B"   4 0) ("\e(0!\e(Bng\e(0@\e(B"   4 1) ("\e(0"\e(Bng\e(0@\e(B"   4 3) ("\e(0#\e(Bng\e(0@\e(B"   4 5) ("\e(0$\e(Bng\e(0@\e(B"   4 7)
+    ("ao\e(0@\e(B"    5 0) ("\e(0!\e(Bo\e(0@\e(B"    5 1) ("\e(0"\e(Bo\e(0@\e(B"    5 3) ("\e(0#\e(Bo\e(0@\e(B"    5 5) ("\e(0$\e(Bo\e(0@\e(B"    5 7)
+    ("e\e(0@\e(B"     6 0) ("\e(0%@\e(B"     6 1) ("\e(0&@\e(B"     6 3) ("\e(0'@\e(B"     6 5) ("\e(0(@\e(B"     6 7)
+    ("ei\e(0@\e(B"    7 0) ("\e(0%\e(Bi\e(0@\e(B"    7 1) ("\e(0&\e(Bi\e(0@\e(B"    7 3) ("\e(0'\e(Bi\e(0@\e(B"    7 5) ("\e(0(\e(Bi\e(0@\e(B"    7 7)
+    ("en\e(0@\e(B"    8 0) ("\e(0%\e(Bn\e(0@\e(B"    8 1) ("\e(0&\e(Bn\e(0@\e(B"    8 3) ("\e(0'\e(Bn\e(0@\e(B"    8 5) ("\e(0(\e(Bn\e(0@\e(B"    8 7)
+    ("eng\e(0@\e(B"   9 0) ("\e(0%\e(Bng\e(0@\e(B"   9 1) ("\e(0&\e(Bng\e(0@\e(B"   9 3) ("\e(0'\e(Bng\e(0@\e(B"   9 5) ("\e(0(\e(Bng\e(0@\e(B"   9 7)
+    ("er\e(0@\e(B"   10 0) ("\e(0%\e(Br\e(0@\e(B"   10 1) ("\e(0&\e(Br\e(0@\e(B"   10 3) ("\e(0'\e(Br\e(0@\e(B"   10 5) ("\e(0(\e(Br\e(0@\e(B"   10 7)
+    ("i\e(0@\e(B"    11 0) ("\e(0)@\e(B"    11 1) ("\e(0*@\e(B"    11 3) ("\e(0+@\e(B"    11 5) ("\e(0,@\e(B"    11 7)
+    ("ia\e(0@\e(B"   12 0) ("i\e(0!@\e(B"   12 1) ("i\e(0"@\e(B"   12 3) ("i\e(0#@\e(B"   12 5) ("i\e(0$@\e(B"   12 7)
+    ("ian\e(0@\e(B"  13 0) ("i\e(0!\e(Bn\e(0@\e(B"  13 1) ("i\e(0"\e(Bn\e(0@\e(B"  13 3) ("i\e(0#\e(Bn\e(0@\e(B"  13 5) ("i\e(0$\e(Bn\e(0@\e(B"  13 7)
+    ("iang\e(0@\e(B" 14 0) ("i\e(0!\e(Bng\e(0@\e(B" 14 1) ("i\e(0"\e(Bng\e(0@\e(B" 14 3) ("i\e(0#\e(Bng\e(0@\e(B" 14 5) ("i\e(0$\e(Bng\e(0@\e(B" 14 7)
+    ("iao\e(0@\e(B"  15 0) ("i\e(0!\e(Bo\e(0@\e(B"  15 1) ("i\e(0"\e(Bo\e(0@\e(B"  15 3) ("i\e(0#\e(Bo\e(0@\e(B"  15 5) ("i\e(0$\e(Bo\e(0@\e(B"  15 7)
+    ("ie\e(0@\e(B"   16 0) ("i\e(0%@\e(B"   16 1) ("i\e(0&@\e(B"   16 3) ("i\e(0'@\e(B"   16 5) ("i\e(0(@\e(B"   16 7)
+    ("in\e(0@\e(B"   17 0) ("\e(0)\e(Bn\e(0@\e(B"   17 1) ("\e(0*\e(Bn\e(0@\e(B"   17 3) ("\e(0+\e(Bn\e(0@\e(B"   17 5) ("\e(0,\e(Bn\e(0@\e(B"   17 7)
+    ("ing\e(0@\e(B"  18 0) ("\e(0)\e(Bng\e(0@\e(B"  18 1) ("\e(0*\e(Bng\e(0@\e(B"  18 3) ("\e(0+\e(Bng\e(0@\e(B"  18 5) ("\e(0,\e(Bng\e(0@\e(B"  18 7)
+    ("iong\e(0@\e(B" 19 0) ("i\e(0-\e(Bng\e(0@\e(B" 19 1) ("i\e(0.\e(Bng\e(0@\e(B" 19 3) ("i\e(0/\e(Bng\e(0@\e(B" 19 5) ("i\e(00\e(Bng\e(0@\e(B" 19 7)
+    ("iu\e(0@\e(B"   20 0) ("i\e(01@\e(B"   20 1) ("i\e(02@\e(B"   20 3) ("i\e(03@\e(B"   20 5) ("i\e(04@\e(B"   20 7)
+    ("m\e(0@\e(B"    21 0) ("m\e(0@\e(B"    21 1) ("m\e(0@\e(B"    21 3) ("m\e(0@\e(B"    21 5) ("m\e(0@\e(B"    21 7)
+    ("n\e(0@\e(B"    22 0) ("n\e(0@\e(B"    22 1) ("\e(0=@\e(B"    22 3) ("\e(0>@\e(B"    22 5) ("\e(0?@\e(B"    22 7)
+    ("ng\e(0@\e(B"   23 0) ("ng\e(0@\e(B"   23 1) ("ng\e(0@\e(B"   23 3) ("ng\e(0@\e(B"   23 5) ("ng\e(0@\e(B"   23 7)
+    ("o\e(0@\e(B"    24 0) ("\e(0-@\e(B"    24 1) ("\e(0.@\e(B"    24 3) ("\e(0/@\e(B"    24 5) ("\e(00@\e(B"    24 7)
+    ("ong\e(0@\e(B"  25 0) ("\e(0-\e(Bng\e(0@\e(B"  25 1) ("\e(0.\e(Bng\e(0@\e(B"  25 3) ("\e(0/\e(Bng\e(0@\e(B"  25 5) ("\e(00\e(Bng\e(0@\e(B"  25 7)
+    ("ou\e(0@\e(B"   26 0) ("\e(0-\e(Bu\e(0@\e(B"   26 1) ("\e(0.\e(Bu\e(0@\e(B"   26 3) ("\e(0/\e(Bu\e(0@\e(B"   26 5) ("\e(00\e(Bu\e(0@\e(B"   26 7)
+    ("u\e(0@\e(B"    27 0) ("\e(01@\e(B"    27 1) ("\e(02@\e(B"    27 3) ("\e(03@\e(B"    27 5) ("\e(04@\e(B"    27 7)
+    ("ua\e(0@\e(B"   28 0) ("u\e(0!@\e(B"   28 1) ("u\e(0"@\e(B"   28 3) ("u\e(0#@\e(B"   28 5) ("u\e(0$@\e(B"   28 7)
+    ("uai\e(0@\e(B"  29 0) ("u\e(0!\e(Bi\e(0@\e(B"  29 1) ("u\e(0"\e(Bi\e(0@\e(B"  29 3) ("u\e(0#\e(Bi\e(0@\e(B"  29 5) ("u\e(0$\e(Bi\e(0@\e(B"  29 7)
+    ("uan\e(0@\e(B"  30 0) ("u\e(0!\e(Bn\e(0@\e(B"  30 1) ("u\e(0"\e(Bn\e(0@\e(B"  30 3) ("u\e(0#\e(Bn\e(0@\e(B"  30 5) ("u\e(0$\e(Bn\e(0@\e(B"  30 7)
+    ("uang\e(0@\e(B" 31 0) ("u\e(0!\e(Bng\e(0@\e(B" 31 1) ("u\e(0"\e(Bng\e(0@\e(B" 31 3) ("u\e(0#\e(Bng\e(0@\e(B" 31 5) ("u\e(0$\e(Bng\e(0@\e(B" 31 7)
+    ("ue\e(0@\e(B"   32 0) ("u\e(0%@\e(B"   32 1) ("u\e(0&@\e(B"   32 3) ("u\e(0'@\e(B"   32 5) ("u\e(0(@\e(B"   32 7)
+    ("ui\e(0@\e(B"   33 0) ("u\e(0)@\e(B"   33 1) ("u\e(0*@\e(B"   33 3) ("u\e(0+@\e(B"   33 5) ("u\e(0,@\e(B"   33 7)
+    ("un\e(0@\e(B"   34 0) ("\e(01\e(Bn\e(0@\e(B"   34 1) ("\e(02\e(Bn\e(0@\e(B"   34 3) ("\e(03\e(Bn\e(0@\e(B"   34 5) ("\e(04\e(Bn\e(0@\e(B"   34 7)
+    ("uo\e(0@\e(B"   35 0) ("u\e(0-@\e(B"   35 1) ("u\e(0.@\e(B"   35 3) ("u\e(0/@\e(B"   35 5) ("u\e(00@\e(B"   35 7)
+    ("\e(09@\e(B"    36 0) ("\e(05@\e(B"    36 1) ("\e(06@\e(B"    36 3) ("\e(07@\e(B"    36 5) ("\e(08@\e(B"    36 7)
+    ("\e(09\e(Be\e(0@\e(B"   37 0) ("\e(09%@\e(B"   37 1) ("\e(09&@\e(B"   37 3) ("\e(09'@\e(B"   37 5) ("\e(09(@\e(B"   37 7)
+    ("0\e(0@\e(B"    38 0) ("1\e(0@\e(B"    38 1) ("2\e(0@\e(B"    38 3) ("3\e(0@\e(B"    38 5) ("4\e(0@\e(B"    38 7)))
+
+(defconst yincode-pinyin-table
+  [
+   0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0
+   0 1 1 1 1 1 0 1 1 1 0 1 0 1 0 1 1 1 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 1
+   0 1 1 1 1 1 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 0 0 1 1 1 0 0 1
+   0 1 1 1 1 1 1 0 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 1 1 1 0 0 1
+   0 1 1 1 1 1 1 1 1 1 0 1 1 1 0 1 1 0 1 0 1 0 0 0 0 1 1 1 0 0 1 0 0 1 1 1 0 0 1
+   0 1 0 1 1 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 1
+   0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 1 1 1 0 0 1
+   0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 1 1 1 1 1 1 0 1 1 1 0 0 1
+   0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 0 0 1 0 1 0 1 0 0 0 1
+   0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 1 1 1 0 0 1
+   0 1 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 1 0 1 0 0 0 1 1 1 1 0 0 1 0 0 0 1 1 1 1 1
+   0 1 1 1 1 1 1 1 1 1 0 1 0 1 0 1 1 1 1 0 1 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 1
+   0 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 0 1 0 0 0 0 1 1 1 0 0 1 0 0 0 0 1 1 1 1
+   0 1 1 1 1 1 0 1 1 1 0 1 0 1 0 1 1 1 1 0 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 1
+   0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 0 0 1 0 1 0 1 0 0 0 1
+   0 0 0 1 1 1 1 0 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 1 0 0 1 1 1 0 0 1
+   0 1 1 1 1 1 1 0 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 0 0 1 1 1 0 0 1
+   0 1 1 1 1 1 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 1 1 1 0 0 1
+   0 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 0 1 0 0 0 0 0 0 1 1 1 0 0 1 0 0 1 1 1 0 0 1
+   0 1 1 1 1 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 1
+   0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 0 0 1 0 1 0 1 0 0 0 1
+   0 1 0 1 1 1 1 0 0 0 0 1 0 0 0 0 0 1 1 0 0 0 0 0 1 1 1 1 0 0 1 0 1 0 1 0 0 0 1
+   0 1 1 1 1 1 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 0 0 1 1 1 0 0 1
+   0 1 1 1 1 1 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 1 1 1 0 0 1
+   ])
+
+(defconst yincode-zhuyin-shengmu
+  '((""  .  0) ("\e(0E\e(B" .  1) ("\e(0X\e(B" .  2) ("\e(0T\e(B" .  3) ("\e(0I\e(B" .  4)
+    ("\e(0H\e(B" .  5) ("\e(0M\e(B" .  6) ("\e(0O\e(B" .  7) ("\e(0P\e(B" .  8) ("\e(0N\e(B" .  9)
+    ("\e(0L\e(B" . 10) ("\e(0G\e(B" . 11) ("\e(0K\e(B" . 12) ("\e(0F\e(B" . 13) ("\e(0Q\e(B" . 14)
+    ("\e(0V\e(B" . 15) ("\e(0Y\e(B" . 16) ("\e(0U\e(B" . 17) ("\e(0J\e(B" . 18) ("\e(0h\e(B" . 19)
+    ("\e(0R\e(B" . 20) ("\e(0g\e(B" . 21) ("\e(0W\e(B" . 22) ("\e(0S\e(B" . 23)))
+
+(defconst yincode-zhuyin-yunmu
+  '(("\e(0@\e(B"    0 0) ("\e(0A\e(B"    0 1) ("\e(0B\e(B"    0 3) ("\e(0C\e(B"    0 5) ("\e(0D\e(B"    0 7) ; i
+    ("\e(0Z@\e(B"   1 0) ("\e(0ZA\e(B"   1 1) ("\e(0ZB\e(B"   1 3) ("\e(0ZC\e(B"   1 5) ("\e(0ZD\e(B"   1 7) ; a
+    ("\e(0^@\e(B"   2 0) ("\e(0^A\e(B"   2 1) ("\e(0^B\e(B"   2 3) ("\e(0^C\e(B"   2 5) ("\e(0^D\e(B"   2 7) ; ai
+    ("\e(0b@\e(B"   3 0) ("\e(0bA\e(B"   3 1) ("\e(0bB\e(B"   3 3) ("\e(0bC\e(B"   3 5) ("\e(0bD\e(B"   3 7) ; an
+    ("\e(0d@\e(B"   4 0) ("\e(0dA\e(B"   4 1) ("\e(0dB\e(B"   4 3) ("\e(0dC\e(B"   4 5) ("\e(0dD\e(B"   4 7) ; ang
+    ("\e(0`@\e(B"   5 0) ("\e(0`A\e(B"   5 1) ("\e(0`B\e(B"   5 3) ("\e(0`C\e(B"   5 5) ("\e(0`D\e(B"   5 7) ; ao
+    ("\e(0\@\e(B"   6 0) ("\e(0\A\e(B"   6 1) ("\e(0\B\e(B"   6 3) ("\e(0\C\e(B"   6 5) ("\e(0\D\e(B"   6 7) ; e
+    ("\e(0_@\e(B"   7 0) ("\e(0_A\e(B"   7 1) ("\e(0_B\e(B"   7 3) ("\e(0_C\e(B"   7 5) ("\e(0_D\e(B"   7 7) ; ei
+    ("\e(0c@\e(B"   8 0) ("\e(0cA\e(B"   8 1) ("\e(0cB\e(B"   8 3) ("\e(0cC\e(B"   8 5) ("\e(0cD\e(B"   8 7) ; en
+    ("\e(0e@\e(B"   9 0) ("\e(0eA\e(B"   9 1) ("\e(0eB\e(B"   9 3) ("\e(0eC\e(B"   9 5) ("\e(0eD\e(B"   9 7) ; eng
+    ("\e(0f@\e(B"  10 0) ("\e(0fA\e(B"  10 1) ("\e(0fB\e(B"  10 3) ("\e(0fC\e(B"  10 5) ("\e(0fD\e(B"  10 7) ; er
+    ("\e(0g@\e(B"  11 0) ("\e(0gA\e(B"  11 1) ("\e(0gB\e(B"  11 3) ("\e(0gC\e(B"  11 5) ("\e(0gD\e(B"  11 7) ; i
+    ("\e(0gZ@\e(B" 12 0) ("\e(0gZA\e(B" 12 1) ("\e(0gZB\e(B" 12 3) ("\e(0gZC\e(B" 12 5) ("\e(0gZD\e(B" 12 7) ; ia
+    ("\e(0gb@\e(B" 13 0) ("\e(0gbA\e(B" 13 1) ("\e(0gbB\e(B" 13 3) ("\e(0gbC\e(B" 13 5) ("\e(0gbD\e(B" 13 7) ; ian
+    ("\e(0gd@\e(B" 14 0) ("\e(0gdA\e(B" 14 1) ("\e(0gdB\e(B" 14 3) ("\e(0gdC\e(B" 14 5) ("\e(0gdD\e(B" 14 7) ; iang
+    ("\e(0g`@\e(B" 15 0) ("\e(0g`A\e(B" 15 1) ("\e(0g`B\e(B" 15 3) ("\e(0g`C\e(B" 15 5) ("\e(0g`D\e(B" 15 7) ; iao
+    ("\e(0g]@\e(B" 16 0) ("\e(0g]A\e(B" 16 1) ("\e(0g]B\e(B" 16 3) ("\e(0g]C\e(B" 16 5) ("\e(0g]D\e(B" 16 7) ; ie
+    ("\e(0gc@\e(B" 17 0) ("\e(0gcA\e(B" 17 1) ("\e(0gcB\e(B" 17 3) ("\e(0gcC\e(B" 17 5) ("\e(0gcD\e(B" 17 7) ; in
+    ("\e(0ge@\e(B" 18 0) ("\e(0geA\e(B" 18 1) ("\e(0geB\e(B" 18 3) ("\e(0geC\e(B" 18 5) ("\e(0geD\e(B" 18 7) ; ing
+    ("\e(0ie@\e(B" 19 0) ("\e(0ieA\e(B" 19 1) ("\e(0ieB\e(B" 19 3) ("\e(0ieC\e(B" 19 5) ("\e(0ieD\e(B" 19 7) ; iong
+    ("\e(0ga@\e(B" 20 0) ("\e(0gaA\e(B" 20 1) ("\e(0gaB\e(B" 20 3) ("\e(0gaC\e(B" 20 5) ("\e(0gaD\e(B" 20 7) ; iu
+    ("\e(0G@\e(B"  21 0) ("\e(0GA\e(B"  21 1) ("\e(0GB\e(B"  21 3) ("\e(0GC\e(B"  21 5) ("\e(0GD\e(B"  21 7) ; m
+    ("\e(0K@\e(B"  22 0) ("\e(0KA\e(B"  22 1) ("\e(0KB\e(B"  22 3) ("\e(0KC\e(B"  22 5) ("\e(0KD\e(B"  22 7) ; n
+    ("@\e(0@\e(B"  23 0) ("@\e(0A\e(B"  23 1) ("@\e(0B\e(B"  23 3) ("@\e(0C\e(B"  23 5) ("@\e(0D\e(B"  23 7) ; ng
+    ("\e(0[@\e(B"  24 0) ("\e(0[A\e(B"  24 1) ("\e(0[B\e(B"  24 3) ("\e(0[C\e(B"  24 5) ("\e(0[D\e(B"  24 7) ; o
+    ("\e(0he@\e(B" 25 0) ("\e(0heA\e(B" 25 1) ("\e(0heB\e(B" 25 3) ("\e(0heC\e(B" 25 5) ("\e(0heD\e(B" 25 7) ; ong
+    ("\e(0a@\e(B"  26 0) ("\e(0aA\e(B"  26 1) ("\e(0aB\e(B"  26 3) ("\e(0aC\e(B"  26 5) ("\e(0aD\e(B"  26 7) ; ou
+    ("\e(0h@\e(B"  27 0) ("\e(0hA\e(B"  27 1) ("\e(0hB\e(B"  27 3) ("\e(0hC\e(B"  27 5) ("\e(0hD\e(B"  27 7) ; u
+    ("\e(0hZ@\e(B" 28 0) ("\e(0hZA\e(B" 28 1) ("\e(0hZB\e(B" 28 3) ("\e(0hZC\e(B" 28 5) ("\e(0hZD\e(B" 28 7) ; ua
+    ("\e(0h^@\e(B" 29 0) ("\e(0h^A\e(B" 29 1) ("\e(0h^B\e(B" 29 3) ("\e(0h^C\e(B" 29 5) ("\e(0h^D\e(B" 29 7) ; uai
+    ("\e(0hb@\e(B" 30 0) ("\e(0hbA\e(B" 30 1) ("\e(0hbB\e(B" 30 3) ("\e(0hbC\e(B" 30 5) ("\e(0hbD\e(B" 30 7) ; uan
+    ("\e(0hd@\e(B" 31 0) ("\e(0hdA\e(B" 31 1) ("\e(0hdB\e(B" 31 3) ("\e(0hdC\e(B" 31 5) ("\e(0hdD\e(B" 31 7) ; uang
+    ("\e(0i]@\e(B" 37 0) ("\e(0i]A\e(B" 37 1) ("\e(0i]B\e(B" 37 3) ("\e(0i]C\e(B" 37 5) ("\e(0i]D\e(B" 37 7) ; ue
+    ("\e(0h_@\e(B" 33 0) ("\e(0h_A\e(B" 33 1) ("\e(0h_B\e(B" 33 3) ("\e(0h_C\e(B" 33 5) ("\e(0h_D\e(B" 33 7) ; ui
+    ("\e(0hc@\e(B" 34 0) ("\e(0hcA\e(B" 34 1) ("\e(0hcB\e(B" 34 3) ("\e(0hcC\e(B" 34 5) ("\e(0hcD\e(B" 34 7) ; un
+    ("\e(0h[@\e(B" 35 0) ("\e(0h[A\e(B" 35 1) ("\e(0h[B\e(B" 35 3) ("\e(0h[C\e(B" 35 5) ("\e(0h[D\e(B" 35 7) ; uo
+    ("\e(0i@\e(B"  36 0) ("\e(0iA\e(B"  36 1) ("\e(0iB\e(B"  36 3) ("\e(0iC\e(B"  36 5) ("\e(0iD\e(B"  36 7) ; \e(09\e(B
+    ("\e(0i]@\e(B" 37 0) ("\e(0i]A\e(B" 37 1) ("\e(0i]B\e(B" 37 3) ("\e(0i]C\e(B" 37 5) ("\e(0i]D\e(B" 37 7) ; \e(09\e(Be
+    ("0\e(0@\e(B"  38 0) ("1\e(0A\e(B"  38 1) ("2\e(0B\e(B"  38 3) ("3\e(0C\e(B"  38 5) ("4\e(0D\e(B"  38 7) ; undefined
+    ("\e(0ib@\e(B" 39 0) ("\e(0ibA\e(B" 39 1) ("\e(0ibB\e(B" 39 3) ("\e(0ibC\e(B" 39 5) ("\e(0ibD\e(B" 39 7) ; \e(09\e(Ban
+    ("\e(0ic@\e(B" 40 0) ("\e(0icA\e(B" 40 1) ("\e(0icB\e(B" 40 3) ("\e(0icC\e(B" 40 5) ("\e(0icD\e(B" 40 7) ; \e(09\e(Bn
+    ))
+
+(defconst yincode-zhuyin-table
+  [
+   ;; empty ShengMu
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x8000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x9586 ?\x0000 ?\x9592 ?\x9599
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x8000 ?\x0000 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x959b ?\x95a0 ?\x0000 ?\x959e
+   ?\x95a2
+   ;; ShengMu B
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x8000
+   ?\x0000 ?\x8000 ?\x0000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu C
+   ?\x828b ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x0000 ?\x0280 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000
+   ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu Ch
+   ?\x838b ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x8000 ?\x8000
+   ?\x0000 ?\x0380 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x8000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu D
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x0000 ?\x8000 ?\x0000
+   ?\x8000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000
+   ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu F
+   ?\x0000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu G
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x8000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu H
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000
+   ?\x0000 ?\x8000 ?\x0000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x8000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu J
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x8000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x08a4 ?\x0000 ?\x0000
+   ?\x08a7 ?\x0000 ?\x08a5 ?\x0000 ?\x08a8 ?\x0000 ?\x889b ?\x88a0 ?\x8000 ?\x889e
+   ?\x88a2
+   ;; ShengMu K
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x8000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu L
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x8000
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000
+   ?\x8000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000
+   ?\x8000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu M
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x0000 ?\x8000 ?\x0000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000
+   ?\x8000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu N
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x0000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000
+   ?\x8000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000
+   ?\x8000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu P
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x8000
+   ?\x0000 ?\x8000 ?\x0000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000 
+   ;; ShengMu Q
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x8000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0ea4 ?\x0000 ?\x0000
+   ?\x0ea7 ?\x0000 ?\x0ea5 ?\x0000 ?\x0ea8 ?\x0000 ?\x8e9b ?\x8ea0 ?\x8000 ?\x8e9e
+   ?\x8ea2
+   ;; ShengMu R
+   ?\x8f8b ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x8000 ?\x8000
+   ?\x0000 ?\x0f80 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000
+   ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu S
+   ?\x908b ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x8000 ?\x8000
+   ?\x0000 ?\x1080 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000
+   ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu Sh
+   ?\x918b ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x0000 ?\x1180 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x8000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu T
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x8000
+   ?\x0000 ?\x8000 ?\x0000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000
+   ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu W
+   ?\x939b ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x0000 ?\x0000 ?\x1380 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu X
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x8000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x14a4 ?\x0000 ?\x0000
+   ?\x14a7 ?\x0000 ?\x14a5 ?\x0000 ?\x14a8 ?\x0000 ?\x949b ?\x94a0 ?\x8000 ?\x949e
+   ?\x94a2
+   ;; ShengMu Y 
+   ?\x958b ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0090 ?\x0000 ?\x9591 ?\x9592
+   ?\x0000 ?\x1580 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x1588 ?\x1589 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x0093 ?\x8000 ?\x00a4 ?\x0000 ?\x0000
+   ?\x00a7 ?\x0000 ?\x00a5 ?\x0000 ?\x00a8 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu Z
+   ?\x968b ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x0000 ?\x1680 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000
+   ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu Zh 
+   ?\x978b ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x0000 ?\x1780 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x8000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ])
+
+(defun egg-chinese-syllable (str &optional start)
+  (if start
+      (setq str (substring str start)))
+  (or (car (egg-pinyin-syllable str))
+      (car (egg-zhuyin-syllable str))))
+
+(defsubst egg-make-fixed-euc-china-code (s y)
+  (concat (list
+          (+ (* 2 (nth 1 y)) (logand (nth 2 y) 1) 32)
+          (+ (* 4 (if (= s 0) 20 s)) (lsh (nth 2 y) -1) 156))))
+
+(defun egg-pinyin-syllable (str)
+  (let (s y end)
+    (if (string-match "^[A-Za-z\e(0!\e(B-\e(0?\e(B]+\e(0@\e(B" str)
+       (progn
+         (setq end (match-end 0))
+         (cond
+          ((setq s (cdr (assoc (substring str 0 2) yincode-pinyin-shengmu)))
+           (setq y (substring str 2 end)))
+          ((setq s (cdr (assoc (substring str 0 1) yincode-pinyin-shengmu)))
+           (setq y (substring str 1 end)))
+          (t
+           (setq s 0 y (substring str 0 end))))
+         (if (and (setq y (assoc y yincode-pinyin-yunmu))
+                  (= (aref yincode-pinyin-table (+ (* 39 s) (nth 1 y))) 1))
+             (cons end (egg-make-fixed-euc-china-code s y)))))))
+
+(defun egg-zhuyin-syllable (str)
+  (let (end s y c z (zhuyin-len (charset-bytes 'chinese-sisheng)))
+    (if (string-match "^[\e(0E\e(B-\e(0i\e(B@0-4]+[\e(0@ABCD\e(B]" str)
+       (progn
+         (setq end (match-end 0)
+               c (substring str 0 zhuyin-len)
+               s (cdr (assoc c yincode-zhuyin-shengmu))
+               y (assoc (substring str zhuyin-len end) yincode-zhuyin-yunmu))
+         (if (null (and s y))
+             (setq s 0
+                   y (assoc (substring str 0 end) yincode-zhuyin-yunmu)))
+         (if (and y
+                  (setq z (aref yincode-zhuyin-table (+ (* 41 s) (nth 1 y))))
+                  (/= (logand z ?\x8000) 0))
+             (if (/= (logand z ?\x80) 0)
+                 (cons end (egg-make-fixed-euc-china-code
+                            (logand (lsh z -8) ?\x7f)
+                            (list nil (logand z ?\x7f) (nth 2 y))))
+               (cons end (egg-make-fixed-euc-china-code s y))))))))
+
+(defun encode-fixed-euc-china-region (beg end type)
+  "Encode the text in the region to EUC-CN/TW."
+  (let (s syl c cset (maxlen (max (length "Zhu\e(0!\e(Bng\e(0@\e(B") (length "\e(0ShdA\e(B"))))
+    (save-excursion
+      (save-restriction
+       (narrow-to-region beg end)
+       (goto-char (point-min))
+       (while (< (point) (point-max))
+         (setq s (buffer-substring (point) 
+                                   (min (+ (point) maxlen) (point-max))))
+         (cond
+          ((setq syl (egg-pinyin-syllable s))
+           (delete-region (point) (+ (point) (car syl)))
+           (insert (cdr syl)))
+          ((setq syl (egg-zhuyin-syllable s))
+           (delete-region (point) (+ (point) (car syl)))
+           (insert (cdr syl)))
+          (t
+           (setq c (split-char (following-char))
+                 cset (car c))
+           (cond
+            ((or (and (eq cset 'chinese-gb2312) (eq type 'cn))
+                 (and (eq cset 'chinese-cns11643-1) (eq type 'tw)))
+             (delete-char 1)
+             (insert (+ (nth 1 c) 128) (+ (nth 2 c) 128)))
+            ((and (eq cset 'chinese-cns11643-2) (eq type 'tw))
+             (delete-char 1)
+             (insert (+ (nth 1 c) 128) (nth 2 c)))
+            ((eq cset 'chinese-sisheng)
+             (delete-char 1)
+             (insert 0 (+ (nth 1 c) 128)))
+            (t
+             (delete-region (point) (1+ (point)))
+             (insert 0 (nth 1 c)))))))
+       (- (point-max) (point-min))))))
+
+(defun pre-write-encode-fixed-euc-china (from to type)
+  (let ((buf (current-buffer))
+       (work (get-buffer-create " *pre-write-encoding-work*")))
+    (set-buffer work)
+    (erase-buffer)
+    (if (stringp from)
+       (insert from)
+      (insert-buffer-substring buf from to))
+    (encode-fixed-euc-china-region 1 (point-max) type)
+    nil))
+
+(defun pre-write-encode-euc-cn (from to)
+  (pre-write-encode-fixed-euc-china from to 'cn))
+
+(defun pre-write-encode-euc-tw (from to)
+  (pre-write-encode-fixed-euc-china from to 'tw))
+
+(defun decode-fixed-euc-china-region (beg end type)
+  "Decode EUC-CN/TW encoded text in the region.
+Return the length of resulting text."
+  (interactive "r")
+  (prog1
+      (let (c0 c1 s y ss)
+       (save-restriction
+         (narrow-to-region beg end)
+         (goto-char (point-min))
+         (while (< (point) (point-max))
+           (setq c1 (buffer-substring (point) (+ (point) 2))
+                 c0 (aref c1 0)
+                 c1 (aref c1 1))
+           (delete-region (point) (+ (point) 2))
+           (cond
+            ((eq c0 0)
+             (if (> c1 ?\xa0)
+                 (insert leading-code-private-11
+                         (charset-id 'chinese-sisheng)
+                         c1)
+               (insert c1)))
+            ((>= c0 ?\x80)
+             (cond
+              ((eq type 'cn)
+               (insert (charset-id 'chinese-gb2312) c0 (logior c1 ?\x80)))
+              ((>= c0 ?\x80)
+               (insert (charset-id 'chinese-cns11643-1) c0 c1))
+              (t
+               (insert (charset-id 'chinese-cns11643-2) c0 (+ c1 ?\x80)))))
+            (t
+             (setq c1 (logand c1 ?\x7f))
+             (setq s (- (lsh c1 -2) 7)  ;;(+ (lsh (- c1 32) -2) 1)
+                   y (- (lsh c0 -1) 16) ;;(lsh (- c0 32) -1)
+                   ss (+ (logand c0 1) (logand c1 3)))
+             (if egg-zhuyin
+                  (progn
+                   (setq c0 (aref yincode-zhuyin-table (+ (* 41 s) y)))
+                    (if (eq (logand c0 ?\x8080) ?\x80)
+                        (setq s (lsh c0 -8)
+                              y (logand c0 ?\x7f)))
+                    (if (and (eq s 20)
+                             (eq (aref yincode-pinyin-table (+ (* 39 s) y)) 0))
+                        (setq s 0))
+                    (insert (car (nth s yincode-zhuyin-shengmu))
+                            (car (nth (+ (* 5 y) ss) yincode-zhuyin-yunmu))))
+                (if (and (eq s 20)
+                         (eq (aref yincode-pinyin-table (+ (* 39 s) y)) 0))
+                    (setq s 0))
+               (insert (car (nth s yincode-pinyin-shengmu))
+                       (car (nth (+ (* 5 y) ss) yincode-pinyin-yunmu)))))))
+         (- (point-max) (point-min))))
+    (if (looking-at "\0\0") (forward-char 2))))
+
+(defun post-read-decode-fixed-euc-china (len type)
+  (let ((pos (point))
+       (buffer-modified-p (buffer-modified-p)))
+    (prog1
+       (decode-fixed-euc-china-region pos (+ pos len) type)
+      (set-buffer-modified-p buffer-modified-p))))
+
+(defun post-read-decode-euc-cn (len)
+  (post-read-decode-fixed-euc-china len 'cn))
+
+(defun post-read-decode-euc-tw (len)
+  (post-read-decode-fixed-euc-china len 'tw))
+
+(make-coding-system 'fixed-euc-cn 5 ?W "Coding System for fixed EUC Chinese-gb2312")
+(put 'fixed-euc-cn 'pre-write-conversion 'pre-write-encode-euc-cn)
+(put 'fixed-euc-cn 'post-read-conversion 'post-read-decode-euc-cn)
+
+(make-coding-system 'fixed-euc-tw 5 ?W "Coding System for fixed EUC Chinese-cns11643")
+(put 'fixed-euc-tw 'pre-write-conversion 'pre-write-encode-euc-tw)
+(put 'fixed-euc-tw 'post-read-conversion 'post-read-decode-euc-tw)
+
+;;; euc-china.el ends here.
diff --git a/euc-cn.el b/euc-cn.el
new file mode 100644 (file)
index 0000000..e001daa
--- /dev/null
+++ b/euc-cn.el
@@ -0,0 +1,449 @@
+;;; euc-cn.el --- Fixed EUC-CN handling routines.
+
+;; Copyright (C) 1997 Mule Project,
+;; Powered by Electrotechnical Laboratory, JAPAN.
+;; Project Leader: Satoru Tomura <tomura@etl.go.jp>
+
+;; Author: KATAYAMA Yoshio <kate@pfu.co.jp>
+;; Maintainer: KATAYAMA Yoshio <kate@pfu.co.jp>
+;; Keywords: mule, multilingual, input method, chinese
+
+;; This file will be part of GNU Emacs (in future).
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; GNU Emacs 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 General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+
+
+;;; Code:
+
+(defvar cwnn-zhuyin nil)
+
+(defconst chinese-sisheng-leading-chars
+  (concat (char-to-string (aref (charset-info 'chinese-sisheng) 6))
+         (char-to-string (aref (charset-info 'chinese-sisheng) 7))))
+(defconst yincoding-pinyin-shengmu
+  '((""  . 0)  ("B" . 1)  ("C"  . 2)  ("Ch" . 3)  ("D" . 4)
+    ("F" . 5)  ("G" . 6)  ("H"  . 7)  ("J"  . 8)  ("K" . 9)
+    ("L" . 10) ("M" . 11) ("N"  . 12) ("P"  . 13) ("Q" . 14)
+    ("R" . 15) ("S" . 16) ("Sh" . 17) ("T"  . 18) ("W" . 19)
+    ("X" . 20) ("Y" . 21) ("Z"  . 22) ("Zh" . 23)))
+
+(defconst yincoding-pinyin-yunmu
+  '(("\e(0@\e(B"      0) ("\e(0@\e(B"      0 0) ("\e(0@\e(B"      0 1) ("\e(0@\e(B"      0 2) ("\e(0@\e(B"      0 3)
+    ("a\e(0@\e(B"     1) ("\e(0!@\e(B"     1 0) ("\e(0"@\e(B"     1 1) ("\e(0#@\e(B"     1 2) ("\e(0$@\e(B"     1 3)
+    ("ai\e(0@\e(B"    2) ("\e(0!\e(Bi\e(0@\e(B"    2 0) ("\e(0"\e(Bi\e(0@\e(B"    2 1) ("\e(0#\e(Bi\e(0@\e(B"    2 2) ("\e(0$\e(Bi\e(0@\e(B"    2 3)
+    ("an\e(0@\e(B"    3) ("\e(0!\e(Bn\e(0@\e(B"    3 0) ("\e(0"\e(Bn\e(0@\e(B"    3 1) ("\e(0#\e(Bn\e(0@\e(B"    3 2) ("\e(0$\e(Bn\e(0@\e(B"    3 3)
+    ("ang\e(0@\e(B"   4) ("\e(0!\e(Bng\e(0@\e(B"   4 0) ("\e(0"\e(Bng\e(0@\e(B"   4 1) ("\e(0#\e(Bng\e(0@\e(B"   4 2) ("\e(0$\e(Bng\e(0@\e(B"   4 3)
+    ("ao\e(0@\e(B"    5) ("\e(0!\e(Bo\e(0@\e(B"    5 0) ("\e(0"\e(Bo\e(0@\e(B"    5 1) ("\e(0#\e(Bo\e(0@\e(B"    5 2) ("\e(0$\e(Bo\e(0@\e(B"    5 3)
+    ("e\e(0@\e(B"     6) ("\e(0%@\e(B"     6 0) ("\e(0&@\e(B"     6 1) ("\e(0'@\e(B"     6 2) ("\e(0(@\e(B"     6 3)
+    ("ei\e(0@\e(B"    7) ("\e(0%\e(Bi\e(0@\e(B"    7 0) ("\e(0&\e(Bi\e(0@\e(B"    7 1) ("\e(0'\e(Bi\e(0@\e(B"    7 2) ("\e(0(\e(Bi\e(0@\e(B"    7 3)
+    ("en\e(0@\e(B"    8) ("\e(0%\e(Bn\e(0@\e(B"    8 0) ("\e(0&\e(Bn\e(0@\e(B"    8 1) ("\e(0'\e(Bn\e(0@\e(B"    8 2) ("\e(0(\e(Bn\e(0@\e(B"    8 3)
+    ("eng\e(0@\e(B"   9) ("\e(0%\e(Bng\e(0@\e(B"   9 0) ("\e(0&\e(Bng\e(0@\e(B"   9 1) ("\e(0'\e(Bng\e(0@\e(B"   9 2) ("\e(0(\e(Bng\e(0@\e(B"   9 3)
+    ("er\e(0@\e(B"   10) ("\e(0%\e(Br\e(0@\e(B"   10 0) ("\e(0&\e(Br\e(0@\e(B"   10 1) ("\e(0'\e(Br\e(0@\e(B"   10 2) ("\e(0(\e(Br\e(0@\e(B"   10 3)
+    ("i\e(0@\e(B"    11) ("\e(0)@\e(B"    11 0) ("\e(0*@\e(B"    11 1) ("\e(0+@\e(B"    11 2) ("\e(0,@\e(B"    11 3)
+    ("ia\e(0@\e(B"   12) ("i\e(0!@\e(B"   12 0) ("i\e(0"@\e(B"   12 1) ("i\e(0#@\e(B"   12 2) ("i\e(0$@\e(B"   12 3)
+    ("ian\e(0@\e(B"  13) ("i\e(0!\e(Bn\e(0@\e(B"  13 0) ("i\e(0"\e(Bn\e(0@\e(B"  13 1) ("i\e(0#\e(Bn\e(0@\e(B"  13 2) ("i\e(0$\e(Bn\e(0@\e(B"  13 3)
+    ("iang\e(0@\e(B" 14) ("i\e(0!\e(Bng\e(0@\e(B" 14 0) ("i\e(0"\e(Bng\e(0@\e(B" 14 1) ("i\e(0#\e(Bng\e(0@\e(B" 14 2) ("i\e(0$\e(Bng\e(0@\e(B" 14 3)
+    ("iao\e(0@\e(B"  15) ("i\e(0!\e(Bo\e(0@\e(B"  15 0) ("i\e(0"\e(Bo\e(0@\e(B"  15 1) ("i\e(0#\e(Bo\e(0@\e(B"  15 2) ("i\e(0$\e(Bo\e(0@\e(B"  15 3)
+    ("ie\e(0@\e(B"   16) ("i\e(0%@\e(B"   16 0) ("i\e(0&@\e(B"   16 1) ("i\e(0'@\e(B"   16 2) ("i\e(0(@\e(B"   16 3)
+    ("in\e(0@\e(B"   17) ("\e(0)\e(Bn\e(0@\e(B"   17 0) ("\e(0*\e(Bn\e(0@\e(B"   17 1) ("\e(0+\e(Bn\e(0@\e(B"   17 2) ("\e(0,\e(Bn\e(0@\e(B"   17 3)
+    ("ing\e(0@\e(B"  18) ("\e(0)\e(Bng\e(0@\e(B"  18 0) ("\e(0*\e(Bng\e(0@\e(B"  18 1) ("\e(0+\e(Bng\e(0@\e(B"  18 2) ("\e(0,\e(Bng\e(0@\e(B"  18 3)
+    ("iong\e(0@\e(B" 19) ("i\e(0-\e(Bng\e(0@\e(B" 19 0) ("i\e(0.\e(Bng\e(0@\e(B" 19 1) ("i\e(0/\e(Bng\e(0@\e(B" 19 2) ("i\e(00\e(Bng\e(0@\e(B" 19 3)
+    ("iu\e(0@\e(B"   20) ("i\e(01@\e(B"   20 0) ("i\e(02@\e(B"   20 1) ("i\e(03@\e(B"   20 2) ("i\e(04@\e(B"   20 3)
+    ("m\e(0@\e(B"    21) ("m\e(0@\e(B"    21 0) ("m\e(0@\e(B"    21 1) ("m\e(0@\e(B"    21 2) ("m\e(0@\e(B"    21 3)
+    ("n\e(0@\e(B"    22) ("n\e(0@\e(B"    22 0) ("\e(0=@\e(B"    22 1) ("\e(0>@\e(B"    22 2) ("\e(0?@\e(B"    22 3)
+    ("ng\e(0@\e(B"   23) ("ng\e(0@\e(B"   23 0) ("ng\e(0@\e(B"   23 1) ("ng\e(0@\e(B"   23 2) ("ng\e(0@\e(B"   23 3)
+    ("o\e(0@\e(B"    24) ("\e(0-@\e(B"    24 0) ("\e(0.@\e(B"    24 1) ("\e(0/@\e(B"    24 2) ("\e(00@\e(B"    24 3)
+    ("ong\e(0@\e(B"  25) ("\e(0-\e(Bng\e(0@\e(B"  25 0) ("\e(0.\e(Bng\e(0@\e(B"  25 1) ("\e(0/\e(Bng\e(0@\e(B"  25 2) ("\e(00\e(Bng\e(0@\e(B"  25 3)
+    ("ou\e(0@\e(B"   26) ("\e(0-\e(Bu\e(0@\e(B"   26 0) ("\e(0.\e(Bu\e(0@\e(B"   26 1) ("\e(0/\e(Bu\e(0@\e(B"   26 2) ("\e(00\e(Bu\e(0@\e(B"   26 3)
+    ("u\e(0@\e(B"    27) ("\e(01@\e(B"    27 0) ("\e(02@\e(B"    27 1) ("\e(03@\e(B"    27 2) ("\e(04@\e(B"    27 3)
+    ("ua\e(0@\e(B"   28) ("u\e(0!@\e(B"   28 0) ("u\e(0"@\e(B"   28 1) ("u\e(0#@\e(B"   28 2) ("u\e(0$@\e(B"   28 3)
+    ("uai\e(0@\e(B"  29) ("u\e(0!\e(Bi\e(0@\e(B"  29 0) ("u\e(0"\e(Bi\e(0@\e(B"  29 1) ("u\e(0#\e(Bi\e(0@\e(B"  29 2) ("u\e(0$\e(Bi\e(0@\e(B"  29 3)
+    ("uan\e(0@\e(B"  30) ("u\e(0!\e(Bn\e(0@\e(B"  30 0) ("u\e(0"\e(Bn\e(0@\e(B"  30 1) ("u\e(0#\e(Bn\e(0@\e(B"  30 2) ("u\e(0$\e(Bn\e(0@\e(B"  30 3)
+    ("uang\e(0@\e(B" 31) ("u\e(0!\e(Bng\e(0@\e(B" 31 0) ("u\e(0"\e(Bng\e(0@\e(B" 31 1) ("u\e(0#\e(Bng\e(0@\e(B" 31 2) ("u\e(0$\e(Bng\e(0@\e(B" 31 3)
+    ("ue\e(0@\e(B"   32) ("u\e(0%@\e(B"   32 0) ("u\e(0&@\e(B"   32 1) ("u\e(0'@\e(B"   32 2) ("u\e(0(@\e(B"   32 3)
+    ("ui\e(0@\e(B"   33) ("u\e(0)@\e(B"   33 0) ("u\e(0*@\e(B"   33 1) ("u\e(0+@\e(B"   33 2) ("u\e(0,@\e(B"   33 3)
+    ("un\e(0@\e(B"   34) ("\e(01\e(Bn\e(0@\e(B"   34 0) ("\e(02\e(Bn\e(0@\e(B"   34 1) ("\e(03\e(Bn\e(0@\e(B"   34 2) ("\e(04\e(Bn\e(0@\e(B"   34 3)
+    ("uo\e(0@\e(B"   35) ("u\e(0-@\e(B"   35 0) ("u\e(0.@\e(B"   35 1) ("u\e(0/@\e(B"   35 2) ("u\e(00@\e(B"   35 3)
+    ("\e(09@\e(B"    36) ("\e(05@\e(B"    36 0) ("\e(06@\e(B"    36 1) ("\e(07@\e(B"    36 2) ("\e(08@\e(B"    36 3)
+    ("\e(09\e(Be\e(0@\e(B"   37) ("\e(09%@\e(B"   37 0) ("\e(09&@\e(B"   37 1) ("\e(09'@\e(B"   37 2) ("\e(09(@\e(B"   37 3)
+    ("0\e(0@\e(B"    38) ("1\e(0@\e(B"    38 0) ("2\e(0@\e(B"    38 1) ("3\e(0@\e(B"    38 2) ("4\e(0@\e(B"    38 3)))
+
+(defconst yincoding-pinyin-table
+  [
+   0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0
+   0 1 1 1 1 1 0 1 1 1 0 1 0 1 0 1 1 1 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 1
+   0 1 1 1 1 1 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 0 0 1 1 1 0 0 1
+   0 1 1 1 1 1 1 0 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 1 1 1 0 0 1
+   0 1 1 1 1 1 1 1 1 1 0 1 1 1 0 1 1 0 1 0 1 0 0 0 0 1 1 1 0 0 1 0 0 1 1 1 0 0 1
+   0 1 0 1 1 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 1
+   0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 1 1 1 0 0 1
+   0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 1 1 1 1 1 1 0 1 1 1 0 0 1
+   0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 0 0 1 0 1 0 1 0 0 0 1
+   0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 1 1 1 0 0 1
+   0 1 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 1 0 1 0 0 0 1 1 1 1 0 0 1 0 0 0 1 1 1 1 1
+   0 1 1 1 1 1 1 1 1 1 0 1 0 1 0 1 1 1 1 0 1 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 1
+   0 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 0 1 0 0 0 0 1 1 1 0 0 1 0 0 0 0 1 1 1 1
+   0 1 1 1 1 1 0 1 1 1 0 1 0 1 0 1 1 1 1 0 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 1
+   0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 0 0 1 0 1 0 1 0 0 0 1
+   0 0 0 1 1 1 1 0 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 1 0 0 1 1 1 0 0 1
+   0 1 1 1 1 1 1 0 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 0 0 1 1 1 0 0 1
+   0 1 1 1 1 1 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 1 1 1 0 0 1
+   0 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 0 1 0 0 0 0 0 0 1 1 1 0 0 1 0 0 1 1 1 0 0 1
+   0 1 1 1 1 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 1
+   0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 0 0 1 0 1 0 1 0 0 0 1
+   0 1 0 1 1 1 1 0 0 0 0 1 0 0 0 0 0 1 1 0 0 0 0 0 1 1 1 1 0 0 1 0 1 0 1 0 0 0 1
+   0 1 1 1 1 1 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 0 0 1 1 1 0 0 1
+   0 1 1 1 1 1 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 1 1 1 0 0 1
+   ])
+
+(defconst yincoding-zhuyin-length (charset-bytes 'chinese-sisheng))
+
+(defconst yincoding-zhuyin-shengmu
+  '((""  .  0) ("\e(0E\e(B" .  1) ("\e(0X\e(B" .  2) ("\e(0T\e(B" .  3) ("\e(0I\e(B" .  4)
+    ("\e(0H\e(B" .  5) ("\e(0M\e(B" .  6) ("\e(0O\e(B" .  7) ("\e(0P\e(B" .  8) ("\e(0N\e(B" .  9)
+    ("\e(0L\e(B" . 10) ("\e(0G\e(B" . 11) ("\e(0K\e(B" . 12) ("\e(0F\e(B" . 13) ("\e(0Q\e(B" . 14)
+    ("\e(0V\e(B" . 15) ("\e(0Y\e(B" . 16) ("\e(0U\e(B" . 17) ("\e(0J\e(B" . 18) ("\e(0h\e(B" . 19)
+    ("\e(0R\e(B" . 20) ("\e(0g\e(B" . 21) ("\e(0W\e(B" . 22) ("\e(0S\e(B" . 23)))
+
+(defconst yincoding-zhuyin-yunmu
+  '(("\e(0@\e(B"    0) ("\e(0A\e(B"    0 0) ("\e(0B\e(B"    0 1) ("\e(0C\e(B"    0 2) ("\e(0D\e(B"    0 3) ; i
+    ("\e(0Z@\e(B"   1) ("\e(0ZA\e(B"   1 0) ("\e(0ZB\e(B"   1 1) ("\e(0ZC\e(B"   1 2) ("\e(0ZD\e(B"   1 3) ; a
+    ("\e(0^@\e(B"   2) ("\e(0^A\e(B"   2 0) ("\e(0^B\e(B"   2 1) ("\e(0^C\e(B"   2 2) ("\e(0^D\e(B"   2 3) ; ai
+    ("\e(0b@\e(B"   3) ("\e(0bA\e(B"   3 0) ("\e(0bB\e(B"   3 1) ("\e(0bC\e(B"   3 2) ("\e(0bD\e(B"   3 3) ; an
+    ("\e(0d@\e(B"   4) ("\e(0dA\e(B"   4 0) ("\e(0dB\e(B"   4 1) ("\e(0dC\e(B"   4 2) ("\e(0dD\e(B"   4 3) ; ang
+    ("\e(0`@\e(B"   5) ("\e(0`A\e(B"   5 0) ("\e(0`B\e(B"   5 1) ("\e(0`C\e(B"   5 2) ("\e(0`D\e(B"   5 3) ; ao
+    ("\e(0\@\e(B"   6) ("\e(0\A\e(B"   6 0) ("\e(0\B\e(B"   6 1) ("\e(0\C\e(B"   6 2) ("\e(0\D\e(B"   6 3) ; e
+    ("\e(0_@\e(B"   7) ("\e(0_A\e(B"   7 0) ("\e(0_B\e(B"   7 1) ("\e(0_C\e(B"   7 2) ("\e(0_D\e(B"   7 3) ; ei
+    ("\e(0c@\e(B"   8) ("\e(0cA\e(B"   8 0) ("\e(0cB\e(B"   8 1) ("\e(0cC\e(B"   8 2) ("\e(0cD\e(B"   8 3) ; en
+    ("\e(0e@\e(B"   9) ("\e(0eA\e(B"   9 0) ("\e(0eB\e(B"   9 1) ("\e(0eC\e(B"   9 2) ("\e(0eD\e(B"   9 3) ; eng
+    ("\e(0f@\e(B"  10) ("\e(0fA\e(B"  10 0) ("\e(0fB\e(B"  10 1) ("\e(0fC\e(B"  10 2) ("\e(0fD\e(B"  10 3) ; er
+    ("\e(0g@\e(B"  11) ("\e(0gA\e(B"  11 0) ("\e(0gB\e(B"  11 1) ("\e(0gC\e(B"  11 2) ("\e(0gD\e(B"  11 3) ; i
+    ("\e(0gZ@\e(B" 12) ("\e(0gZA\e(B" 12 0) ("\e(0gZB\e(B" 12 1) ("\e(0gZC\e(B" 12 2) ("\e(0gZD\e(B" 12 3) ; ia
+    ("\e(0gb@\e(B" 13) ("\e(0gbA\e(B" 13 0) ("\e(0gbB\e(B" 13 1) ("\e(0gbC\e(B" 13 2) ("\e(0gbD\e(B" 13 3) ; ian
+    ("\e(0gd@\e(B" 14) ("\e(0gdA\e(B" 14 0) ("\e(0gdB\e(B" 14 1) ("\e(0gdC\e(B" 14 2) ("\e(0gdD\e(B" 14 3) ; iang
+    ("\e(0g`@\e(B" 15) ("\e(0g`A\e(B" 15 0) ("\e(0g`B\e(B" 15 1) ("\e(0g`C\e(B" 15 2) ("\e(0g`D\e(B" 15 3) ; iao
+    ("\e(0g]@\e(B" 16) ("\e(0g]A\e(B" 16 0) ("\e(0g]B\e(B" 16 1) ("\e(0g]C\e(B" 16 2) ("\e(0g]D\e(B" 16 3) ; ie
+    ("\e(0gc@\e(B" 17) ("\e(0gcA\e(B" 17 0) ("\e(0gcB\e(B" 17 1) ("\e(0gcC\e(B" 17 2) ("\e(0gcD\e(B" 17 3) ; in
+    ("\e(0ge@\e(B" 18) ("\e(0geA\e(B" 18 0) ("\e(0geB\e(B" 18 1) ("\e(0geC\e(B" 18 2) ("\e(0geD\e(B" 18 3) ; ing
+    ("\e(0ie@\e(B" 19) ("\e(0ieA\e(B" 19 0) ("\e(0ieB\e(B" 19 1) ("\e(0ieC\e(B" 19 2) ("\e(0ieD\e(B" 19 3) ; iong
+    ("\e(0ga@\e(B" 20) ("\e(0gaA\e(B" 20 0) ("\e(0gaB\e(B" 20 1) ("\e(0gaC\e(B" 20 2) ("\e(0gaD\e(B" 20 3) ; iu
+    ("\e(0G@\e(B"  21) ("\e(0GA\e(B"  21 0) ("\e(0GB\e(B"  21 1) ("\e(0GC\e(B"  21 2) ("\e(0GD\e(B"  21 3) ; m
+    ("\e(0K@\e(B"  22) ("\e(0KA\e(B"  22 0) ("\e(0KB\e(B"  22 1) ("\e(0KC\e(B"  22 2) ("\e(0KD\e(B"  22 3) ; n
+    ("@\e(0@\e(B"  23) ("@\e(0A\e(B"  23 0) ("@\e(0B\e(B"  23 1) ("@\e(0C\e(B"  23 2) ("@\e(0D\e(B"  23 3) ; ng
+    ("\e(0[@\e(B"  24) ("\e(0[A\e(B"  24 0) ("\e(0[B\e(B"  24 1) ("\e(0[C\e(B"  24 2) ("\e(0[D\e(B"  24 3) ; o
+    ("\e(0he@\e(B" 25) ("\e(0heA\e(B" 25 0) ("\e(0heB\e(B" 25 1) ("\e(0heC\e(B" 25 2) ("\e(0heD\e(B" 25 3) ; ong
+    ("\e(0a@\e(B"  26) ("\e(0aA\e(B"  26 0) ("\e(0aB\e(B"  26 1) ("\e(0aC\e(B"  26 2) ("\e(0aD\e(B"  26 3) ; ou
+    ("\e(0h@\e(B"  27) ("\e(0hA\e(B"  27 0) ("\e(0hB\e(B"  27 1) ("\e(0hC\e(B"  27 2) ("\e(0hD\e(B"  27 3) ; u
+    ("\e(0hZ@\e(B" 28) ("\e(0hZA\e(B" 28 0) ("\e(0hZB\e(B" 28 1) ("\e(0hZC\e(B" 28 2) ("\e(0hZD\e(B" 28 3) ; ua
+    ("\e(0h^@\e(B" 29) ("\e(0h^A\e(B" 29 0) ("\e(0h^B\e(B" 29 1) ("\e(0h^C\e(B" 29 2) ("\e(0h^D\e(B" 29 3) ; uai
+    ("\e(0hb@\e(B" 30) ("\e(0hbA\e(B" 30 0) ("\e(0hbB\e(B" 30 1) ("\e(0hbC\e(B" 30 2) ("\e(0hbD\e(B" 30 3) ; uan
+    ("\e(0hd@\e(B" 31) ("\e(0hdA\e(B" 31 0) ("\e(0hdB\e(B" 31 1) ("\e(0hdC\e(B" 31 2) ("\e(0hdD\e(B" 31 3) ; uang
+    ("\e(0i]@\e(B" 37) ("\e(0i]A\e(B" 37 0) ("\e(0i]B\e(B" 37 1) ("\e(0i]C\e(B" 37 2) ("\e(0i]D\e(B" 37 3) ; ue
+    ("\e(0h_@\e(B" 33) ("\e(0h_A\e(B" 33 0) ("\e(0h_B\e(B" 33 1) ("\e(0h_C\e(B" 33 2) ("\e(0h_D\e(B" 33 3) ; ui
+    ("\e(0hc@\e(B" 34) ("\e(0hcA\e(B" 34 0) ("\e(0hcB\e(B" 34 1) ("\e(0hcC\e(B" 34 2) ("\e(0hcD\e(B" 34 3) ; un
+    ("\e(0h[@\e(B" 35) ("\e(0h[A\e(B" 35 0) ("\e(0h[B\e(B" 35 1) ("\e(0h[C\e(B" 35 2) ("\e(0h[D\e(B" 35 3) ; uo
+    ("\e(0i@\e(B"  36) ("\e(0iA\e(B"  36 0) ("\e(0iB\e(B"  36 1) ("\e(0iC\e(B"  36 2) ("\e(0iD\e(B"  36 3) ; \e(09\e(B
+    ("\e(0i]@\e(B" 37) ("\e(0i]A\e(B" 37 0) ("\e(0i]B\e(B" 37 1) ("\e(0i]C\e(B" 37 2) ("\e(0i]D\e(B" 37 3) ; \e(09\e(Be
+    ("0\e(0@\e(B"  38) ("1\e(0A\e(B"  38 0) ("2\e(0B\e(B"  38 1) ("3\e(0C\e(B"  38 2) ("4\e(0D\e(B"  38 3) ; undefined YunMu
+    ("\e(0ib@\e(B" 39) ("\e(0ibA\e(B" 39 0) ("\e(0ibB\e(B" 39 1) ("\e(0ibC\e(B" 39 2) ("\e(0ibD\e(B" 39 3) ; \e(09\e(Ban
+    ("\e(0ic@\e(B" 40) ("\e(0icA\e(B" 40 0) ("\e(0icB\e(B" 40 1) ("\e(0icC\e(B" 40 2) ("\e(0icD\e(B" 40 3) ; \e(09\e(Bn
+    ))
+
+(defconst yincoding-zhuyin-table
+  [
+   ;; empty ShengMu
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x8000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x9586 ?\x0000 ?\x9592 ?\x9599
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x8000 ?\x0000 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x959b ?\x95a0 ?\x0000 ?\x959e
+   ?\x95a2
+   ;; ShengMu B
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x8000
+   ?\x0000 ?\x8000 ?\x0000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu C
+   ?\x828b ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x0000 ?\x0280 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000
+   ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu Ch
+   ?\x838b ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x8000 ?\x8000
+   ?\x0000 ?\x0380 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x8000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu D
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x0000 ?\x8000 ?\x0000
+   ?\x8000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000
+   ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu F
+   ?\x0000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu G
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x8000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu H
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000
+   ?\x0000 ?\x8000 ?\x0000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x8000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu J
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x8000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x08a4 ?\x0000 ?\x0000
+   ?\x08a7 ?\x0000 ?\x08a5 ?\x0000 ?\x08a8 ?\x0000 ?\x889b ?\x88a0 ?\x8000 ?\x889e
+   ?\x88a2
+   ;; ShengMu K
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x8000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu L
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x8000
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000
+   ?\x8000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000
+   ?\x8000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu M
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x0000 ?\x8000 ?\x0000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000
+   ?\x8000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu N
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x0000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000
+   ?\x8000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000
+   ?\x8000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu P
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x8000
+   ?\x0000 ?\x8000 ?\x0000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000 
+   ;; ShengMu Q
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x8000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0ea4 ?\x0000 ?\x0000
+   ?\x0ea7 ?\x0000 ?\x0ea5 ?\x0000 ?\x0ea8 ?\x0000 ?\x8e9b ?\x8ea0 ?\x8000 ?\x8e9e
+   ?\x8ea2
+   ;; ShengMu R
+   ?\x8f8b ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x8000 ?\x8000
+   ?\x0000 ?\x0f80 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000
+   ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu S
+   ?\x908b ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x8000 ?\x8000
+   ?\x0000 ?\x1080 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000
+   ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu Sh
+   ?\x918b ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x0000 ?\x1180 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x8000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu T
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x8000
+   ?\x0000 ?\x8000 ?\x0000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000
+   ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu W
+   ?\x939b ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x0000 ?\x0000 ?\x1380 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu X
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000
+   ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x8000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x14a4 ?\x0000 ?\x0000
+   ?\x14a7 ?\x0000 ?\x14a5 ?\x0000 ?\x14a8 ?\x0000 ?\x949b ?\x94a0 ?\x8000 ?\x949e
+   ?\x94a2
+   ;; ShengMu Y 
+   ?\x958b ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0090 ?\x0000 ?\x9591 ?\x9592
+   ?\x0000 ?\x1580 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x1588 ?\x1589 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x0093 ?\x8000 ?\x00a4 ?\x0000 ?\x0000
+   ?\x00a7 ?\x0000 ?\x00a5 ?\x0000 ?\x00a8 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu Z
+   ?\x968b ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x0000 ?\x1680 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000
+   ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ;; ShengMu Zh 
+   ?\x978b ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x0000 ?\x1780 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000
+   ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x8000 ?\x8000
+   ?\x8000 ?\x8000 ?\x0000 ?\x8000 ?\x8000 ?\x8000 ?\x0000 ?\x0000 ?\x8000 ?\x0000
+   ?\x0000
+   ])
+
+(defun encode-euc-cwnn-region (beg end)
+  "Encode the text in the current region to EUC-cWnn.
+Return the length of resulting text."
+  (interactive "r")
+  (let (sylend s y z (enable-multibyte-characters t))
+    (save-excursion
+      (save-restriction
+       (narrow-to-region beg end)
+       (goto-char (point-min))
+       (while (< (point) (point-max))
+         (cond
+          ((looking-at "[A-Za-z\e(0!\e(B-\e(0?\e(B]+\e(0@\e(B")
+           ;; PinYin
+           (setq sylend (match-end 0))
+           (if (and (looking-at "[B-Z]h?")
+                    (setq s (assoc (buffer-substring (match-beginning 0) (match-end 0))
+                                   yincoding-pinyin-shengmu)))
+               (setq s (cdr s) y (buffer-substring (match-end 0) sylend))
+             (setq s 0 y (buffer-substring (point) sylend)))
+           (if (and (setq y (assoc y yincoding-pinyin-yunmu))
+                    (= (aref yincoding-pinyin-table (+ (* 39 s) (nth 1 y))) 1))
+               (progn
+                 (delete-region (point) sylend)
+                 (insert (char-to-string (+ (* 2 (nth 1 y)) 32 (if (nth 2 y) 1 0)))
+                         (char-to-string (+ (* 4 (if (= s 0) 20 s)) 156 (if (nth 2 y) (nth 2 y) 0)))))
+             (encode-euc-cwnn-1-char)))
+          ((looking-at "[\e(0E\e(B-\e(0i\e(B@0-4]+[\e(0@ABCD\e(B]")
+           ;; ZhuYin
+            (setq sylend (match-end 0))
+            (if (setq y (assoc (buffer-substring (point) sylend) yincoding-zhuyin-yunmu))
+                (setq s 0)
+              (if (setq s (assoc (char-to-string (following-char)) yincoding-zhuyin-shengmu))
+                  (setq s (cdr s) y (buffer-substring (+ (point) yincoding-zhuyin-length) sylend))
+                (setq s 0 y (buffer-substring (point) sylend)))
+              (setq y (assoc y yincoding-zhuyin-yunmu)))
+           (if (and y
+                    (/= (logand (setq z (aref yincoding-zhuyin-table (+ (* 41 s) (nth 1 y)))) ?\x8000) 0))
+               (progn
+                 (delete-region (point) sylend)
+                 (if (/= (logand z ?\x80) 0)
+                     (setq s (logand (lsh z -8) 127) y (list nil (logand z 127) (nth 2 y))))
+                 (insert (+ (* 2 (nth 1 y)) 32 (if (nth 2 y) 1 0))
+                         (+ (* 4 (if (= s 0) 20 s)) 156 (if (nth 2 y) (nth 2 y) 0))))
+             (encode-euc-cwnn-1-char)))
+          (t (encode-euc-cwnn-1-char))))
+       (- (point-max) (point-min))))))
+
+(defun encode-euc-cwnn-1-char ()
+  (let ((enable-multibyte-characters nil))
+    (cond
+     ((eq (following-char) (charset-id 'chinese-gb2312))
+      (delete-char 1)
+      (forward-char 2))
+     ((looking-at chinese-sisheng-leading-chars)
+      (delete-region (match-beginning 0) (match-end 0))
+      (insert 0)
+      (forward-char))
+     (t
+      (insert 0)
+      (forward-char)))))
+
+(defun pre-write-encode-euc-cwnn (from to)
+  (let ((buf (current-buffer))
+       (work (get-buffer-create " *pre-write-encoding-work*")))
+    (set-buffer work)
+    (erase-buffer)
+    (if (stringp from)
+       (insert from)
+      (insert-buffer-substring buf from to))
+    (encode-euc-cwnn-region 1 (point-max))
+    nil))
+
+(defun decode-euc-cwnn-region (beg end)
+  "Decode EUC-cWnn encoded text in the current region.
+Return the length of resulting text."
+  (interactive "r")
+  (prog1
+      (let (c cc s y ss (enable-multibyte-characters nil))
+       (save-restriction
+         (narrow-to-region beg end)
+         (goto-char (point-min))
+         (while (< (point) (point-max))
+           (setq c (following-char))
+           (cond
+            ((eq c 0)
+             (delete-char 1)
+             (if (>= (following-char) 128)
+                 (insert chinese-sisheng-leading-chars))
+             (forward-char))
+            ((>= c 128)
+             (insert (charset-id 'chinese-gb2312))
+             (forward-char 2)
+             (if (< (setq c (preceding-char)) 128)
+                 (progn
+                   (delete-char -1)
+                   (insert (+ c 128))
+                   (forward-char))))
+            (t
+             (delete-char 1)
+             (setq cc (logand (following-char) 127))
+             (delete-char 1)
+             (setq s (+ (lsh (- cc 32) -2) 1)
+                   y (lsh (- c 32) -1)
+                   ss (+ (logand c 1) (logand cc 3)))
+             (if cwnn-zhuyin
+                  (progn
+                   (setq c (aref yincoding-zhuyin-table (+ (* 41 s) y)))
+                    (if (eq (logand c ?\x8080) ?\x80)
+                        (setq s (lsh c -8)
+                              y (logand c 127)))
+                    (if (and (eq s 20)
+                             (eq (aref yincoding-pinyin-table (+ (* 39 s) y)) 0))
+                        (setq s 0))
+                    (insert (car (nth s yincoding-zhuyin-shengmu))
+                            (car (nth (+ (* 5 y) ss) yincoding-zhuyin-yunmu))))
+                (if (and (eq s 20)
+                         (eq (aref yincoding-pinyin-table (+ (* 39 s) y)) 0))
+                    (setq s 0))
+               (insert (car (nth s yincoding-pinyin-shengmu))
+                       (car (nth (+ (* 5 y) ss) yincoding-pinyin-yunmu)))))))
+         (- (point-max) (point-min))))
+    (if (looking-at "\0\0") (forward-char 2))))
+
+(defun post-read-decode-euc-cwnn (len)
+  (let ((pos (point))
+       (buffer-modified-p (buffer-modified-p)))
+    (prog1
+       (decode-euc-cwnn-region pos (+ pos len))
+      (set-buffer-modified-p buffer-modified-p))))
+
+(make-coding-system 'fixed-euc-cn 5 ?W "Coding System for fixed EUC Japanese")
+(put 'fixed-euc-cn 'post-read-conversion 'post-read-decode-euc-cwnn)
+(put 'fixed-euc-cn 'pre-write-conversion 'pre-write-encode-euc-cwnn)
+
+;;; euc-cn.el ends here.
index 9372491..d295424 100644 (file)
@@ -1,74 +1,62 @@
 (eval-when-compile
   (require 'cl))
 
+(defvar its-current-language "Japanese")
+
 (defvar its-zhuyin nil)
 (make-variable-buffer-local 'its-zhuyin)
-(put 'its-zhuyin 'permanent-local t)
 
-(eval-when (eval compile)
-  (defun its-make-select-func (key1 key2 func file map &optional zhuyin)
-    (setq func (intern (concat "its-select-" (symbol-name func)))
-         file (intern (concat "its/" (symbol-name file)))
-         map (intern (concat "its-" (symbol-name map) "-map")))
-    (cons
-     `(defun ,func (&optional temporally mode-line-unchange)
-       (interactive "P")
-       (if temporally
-           (its-select-mode-temporally ',func)
-         (let ((inhibit-read-only t))
-           (require ',file)
-           (cond
-            ((its-in-fence-p)
-             (its-input-end)
-             (its-put-cursor t))
-            ((egg-get-bunsetsu-info (point))
-             (egg-exit-conversion)))
-           (setq its-current-select-func ',func)
-           (setq its-current-map ,map)
-           (if (its-get-language its-current-map)
-               (setq its-current-language (its-get-language its-current-map)))
-           ,(if zhuyin `(setq its-zhuyin ,(eq zhuyin 'T)))
-           (if (null mode-line-unchange)
-               (its-set-mode-line-title)))))
-     `(define-key map
-       (if fence
-           ,(concat "\e" key2)
-         ,(concat "\C-x\C-m" key1))
-       ',func))))
+(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-select-func (list)
+(defmacro its-do-list-make-slect-func (list)
   (eval-when (eval compile)
-    (let (funcs keydefs pair)
+    (let (e l)
       (while list
-       (setq pair (apply 'its-make-select-func (car list)))
-       (setq funcs (cons (car pair) funcs)
-             keydefs (cons (cdr pair) keydefs))
+       (setq e (car list))
+       (setq l (cons `(its-make-slect-func ,@(car list)) l))
        (setq list (cdr list)))
-      `(progn
-        ,@funcs
-        (defun its-define-select-keys (map &optional fence)
-          ,@keydefs)))))
+      (cons 'progn l))))
 
-(its-do-list-make-select-func
- (("Q"    "Q"    upcase               ascii    up)
-  ("q"    "q"    downcase             ascii    down)
-  ("h"    "\C-h" hiragana             hira     hira)
-  ("k"    "\C-k" katakana             kata     kata)
-  ("x"    "\C-x" hankaku-katakana     hankata  han-kata)
-  ("Z"    "Z"    zenkaku-upcase       zenkaku  zenkaku-up)
-  ("z"    "z"    zenkaku-downcase     zenkaku  zenkaku-down)
-  ("\C-e" "\C-e" erpin-cn             erpin    erpin-cn          NIL)
-  ("\C-p" "\C-p" pinyin-cn            pinyin   pinyin-cn         NIL)
-  ("\C-z" "\C-z" zhuyin-cn            zhuyin   zhuyin-cn         T)
-  ("\C-u" "\C-u" quanjiao-upcase-cn   quanjiao quanjiao-up-cn)
-  ("\C-d" "\C-d" quanjiao-downcase-cn quanjiao quanjiao-down-cn)
-  ("E"    "E"    erpin-tw             erpin    erpin-tw          NIL)
-  ("P"    "P"    pinyin-tw            pinyin   pinyin-tw         NIL)
-  ("C"    "C"    zhuyin-tw            zhuyin   zhuyin-tw         T)
-  ("U"    "U"    quanjiao-upcase-tw   quanjiao quanjiao-up-tw)
-  ("D"    "D"    quanjiao-downcase-tw quanjiao quanjiao-down-tw)
-  ("H"    "H"    hangul               hangul   hangul)
-  ("J"    "J"    jeonkak-upcase       jeonkak  jeonkak-up)
-  ("j"    "j"    jeonkak-downcase     jeonkak  jeonkak-down)))
+(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)))
 
 (provide 'its-keydef)
diff --git a/its.el b/its.el
index d55f755..56bab98 100644 (file)
--- a/its.el
+++ b/its.el
 
 (require 'cl)
 
-(defvar its-current-map nil)
-(make-variable-buffer-local 'its-current-map)
-(put 'its-current-map 'permanent-local t)
-
-(defvar its-current-select-func nil)
-(make-variable-buffer-local 'its-current-select-func)
-(put 'its-current-select-func 'permanent-local t)
-
-(defvar its-previous-select-func nil)
-(make-variable-buffer-local 'its-previous-select-func)
-(put 'its-previous-select-func 'permanent-local t)
-
 (defvar its-current-language)
 (make-variable-buffer-local 'its-current-language)
-(put 'its-current-language 'permanent-local t)
 \f
 ;; Data structure in ITS
 ;; (1) SYL and CURSOR
           l)
          ((numberp l)                  ; VSYL
           (car syl))
-         ((numberp (cdr l))
-          (substring (car l) 0 (cdr l)))
          (t
-          (car l)))))
+          (car (cdr syl))))))
 
 (defsubst its-eob-keyexpr (eob)
   (car (cdr eob)))
   (cons class back))
 (defsubst its-make-otherwise (output class+back)
   (cons output class+back))
-
-(defsubst its-DSYL-with-back-p (syl)
-  (and (consp (cdr syl))
-       (numberp (its-get-kst/t syl))))
-
-(defsubst its-concrete-DSYL-p (syl)
-  (stringp (cdr syl)))
-
-(defsubst its-make-concrete-DSYL (syl)
-  (if (consp (cdr syl))
-      (cons (its-get-output syl) (its-get-keyseq-syl syl))
-    syl))
-    
 ;;
 ;;
 
-(eval-when (eval load compile)
-  (require 'its-keydef))
-
 (defvar its-mode-map
   (let ((map (make-sparse-keymap))
        (i 33))
     (define-key map "\C-a" 'its-beginning-of-input-buffer)
     (define-key map "\C-b" 'its-backward-SYL)
-    (define-key map "\C-c" 'its-cancel-input)
     (define-key map "\C-d" 'its-delete-SYL)
     (define-key map "\C-e" 'its-end-of-input-buffer)
     (define-key map "\C-f" 'its-forward-SYL)
-    (define-key map "\C-g" 'its-select-previous-mode)
     (define-key map "\C-]" 'its-cancel-input)
     (define-key map "\C-h" 'its-mode-help-command)
     (define-key map "\C-k" 'its-kill-line)
     (define-key map "\C-m" 'its-exit-mode)     ; RET
     (define-key map [return] 'its-exit-mode)
     (define-key map "\C-t" 'its-transpose-chars)
-    (define-key map "\C-w" 'its-kick-convert-region)
-    (define-key map "\C-y" 'its-yank)
-    (define-key map "\M-y" 'its-yank-pop)
-    (define-key map [backspace] 'its-delete-backward-SYL)
     (define-key map [delete] 'its-delete-backward-SYL)
-    (define-key map [M-backspace] 'its-delete-backward-SYL-by-keystroke)
-    (define-key map [M-delete] 'its-delete-backward-SYL-by-keystroke)
     (define-key map [right] 'its-forward-SYL)
     (define-key map [left] 'its-backward-SYL)
+    (define-key map "\C-\\" 'its-exit-mode-off-input-method)
     (while (< i 127)
       (define-key map (vector i) 'its-self-insert-char)
       (setq i (1+ i)))
-    (define-key map " "    'its-kick-convert-region-or-self-insert)
+    (define-key map " "    'its-kick-convert-region)
     (define-key map "\177" 'its-delete-backward-SYL)
     ;;
-    (define-key map "\M-p" 'its-previous-map)
-    (define-key map "\M-n" 'its-next-map)
-    (define-key map "\M-h" 'its-hiragana) ; hiragana-region for input-buffer
-    (define-key map "\M-k" 'its-katakana)
-    (define-key map "\M-<" 'its-hankaku)
-    (define-key map "\M->" 'its-zenkaku)
-    (its-define-select-keys map t)
+    (define-key map "\C-p" 'its-previous-map)
+    (define-key map "\C-n" 'its-next-map)
+;   (define-key map "\M-h"    'its-hiragana) ; hiragana-region for input-buffer
+;   (define-key map "\M-k"    'its-katakana)
+;   (define-key map "\M-<"    'its-hankaku)
+;   (define-key map "\M->"    'its-zenkaku)
+;   (define-key map "\M-\C-h" 'its-select-hiragana)
+;   (define-key map "\M-\C-k" 'its-select-katakana)
+;;;    (define-key map "\M-q"    'its-select-downcase) ; 
+;   (define-key map "\M-Q"    'its-select-upcase)
+;   (define-key map "\M-z"    'its-select-zenkaku-downcase)
+;   (define-key map "\M-Z"    'its-select-zenkaku-upcase)
     map)
   "Keymap for ITS mode.")
 
-(defvar its-fence-open  "|" "*\e$B%U%'%s%9$N;OE@$r<($9J8;zNs\e(B (1 \e$BJ8;z0J>e\e(B)")
-(defvar its-fence-close "|" "*\e$B%U%'%s%9$N=*E@$r<($9J8;zNs\e(B (1 \e$BJ8;z0J>e\e(B)")
-(defvar its-fence-face  nil "*\e$B%U%'%s%9I=<($KMQ$$$k\e(B face \e$B$^$?$O\e(B nil")
-
-(defconst its-setup-fence-before-insert-SYL nil)
-
-(defun its-get-fence-face ()
-  (let ((face (and (consp its-fence-face)
-                  (or (assoc its-current-language its-fence-face)
-                      (assoc t its-fence-face)))))
-    (if face (cdr face) its-fence-face)))
+(defvar its-fence-open   "|" "*\e$B%U%'%s%9$N;OE@$r<($9J8;zNs\e(B (1 \e$BJ8;z\e(B)")
+(defvar its-fence-close  "|" "*\e$B%U%'%s%9$N=*E@$r<($9J8;zNs\e(B (1 \e$BJ8;z\e(B)")
+(defvar its-fence-face nil  "*\e$B%U%'%s%9I=<($KMQ$$$k\e(B face \e$B$^$?$O\e(B nil")
 
 (defun its-put-cursor (cursor)
-  (let ((p (point))
-       (map (copy-keymap its-mode-map)))
-    (its-define-select-keys map)
+  (let ((p (point)))
     (insert "!")
-    (add-text-properties p (point) (list 'local-map map
-                                        'read-only t
+    (add-text-properties p (point) (list 'local-map its-mode-map
                                         'invisible t
                                         'intangible 'its-part-2
                                         'its-cursor cursor))
     (goto-char p)))
-
-(defsubst its-set-cursor-status (cursor)
-  (put-text-property (point) (1+ (point)) 'its-cursor cursor)
-  cursor)
-
 ;;
 ;;  +-- START property
 ;;  |          --- CURSOR Property
 ;; intangible intangible
 ;;     1       2
 ;;
-(defun its-setup-fence-mode ()
-  (let ((open-props '(its-start t intangible its-part-1))
-       (close-props '(rear-nonsticky t its-end t intangible its-part-2))
-       (p (point)) p1)
-    ;; Put open-fence before inhibit-read-only to detect read-nly
+(defun its-insert-fence-open ()
+  (let ((p (point)))
     (insert its-fence-open)
-    (let ((inhibit-read-only t))
-      (setq p1 (point))
-      (add-text-properties p p1 open-props)
-      (insert its-fence-close)
-      (add-text-properties p1 (point) close-props)
-      (if its-fence-face
-         (put-text-property p (point) 'invisible t))
-      (put-text-property p (point) 'read-only t)
-      (goto-char p1)
-      (its-put-cursor t))))
+    (add-text-properties p (point)
+                        (if its-fence-face
+                            '(invisible t its-start t intangible its-part-1)
+                          '(its-start t intangible its-part-1)))))
+
+(defun its-insert-fence-close ()
+  (let ((p (point)))
+    (insert its-fence-close)
+    (add-text-properties p (point) 
+                        (if its-fence-face
+                            '(invisible t its-end t intangible its-part-2)
+                          '(its-end t intangible its-part-2)))
+    (goto-char p)))
 
 (defun its-start (key)
-  (let ((its-setup-fence-before-insert-SYL t))
-    (its-input nil key)))
+  (its-insert-fence-open)
+  (its-insert-fence-close)
+  (its-put-cursor (its-input nil key))
+  (force-mode-line-update))
 
-(defun its-restart (str &optional set-prop)
+(defun its-restart (str)
   (let (p)
-    (its-setup-fence-mode)
+    (its-insert-fence-open)
+    (its-insert-fence-close)
     (setq p (point))
     (insert str)
-    (if set-prop
-       (its-setup-yanked-portion p (point)))
-    (its-beginning-of-input-buffer)))
+    (put-text-property p (point) 'intangible 'its-part-2)
+    (goto-char p)
+    (its-put-cursor t)))
 
 (defun its-self-insert-char ()
   (interactive)
-  (let ((inhibit-read-only t)
-       (key last-command-char)
+  (let ((key last-command-char)
        (cursor (get-text-property (point) 'its-cursor))
-       (syl (get-text-property (1- (point)) 'its-syl)))
-    (cond
-     ((or (eq cursor t)
-         (not (eq (get-text-property (1- (point)) 'its-map) its-current-map)))
-      (put-text-property (- (point) (length (its-get-output syl))) (point)
-                        'its-syl (its-make-concrete-DSYL syl))
-      (setq syl nil))
-    (cursor
-     (setq syl nil)))
-    (its-input syl key)))
+       (syl nil))
+    (if (null cursor)
+       (setq syl (get-text-property (1- (point)) 'its-syl)))
+    ;; delete cursor
+    (delete-region (point) (1+ (point)))
+    (setq cursor (its-input syl key))
+    (its-put-cursor cursor)))
+
+(defvar its-current-map nil)
+(make-variable-buffer-local 'its-current-map)
+(put 'its-current-map 'permanent-local t)
 
 (defun its-initial-ISYL ()
   (its-get-start-state its-current-map))
 (defun its-make-VSYL (keyseq)
   (cons keyseq (length keyseq)))
 
-(defvar its-barf-on-invalid-keyseq nil
-  "T means don't allow invalid key sequence in input buffer.")
-
-(defun its-input-error ()
-  (error "Invalid Romaji Sequence"))
-
 ;; Return CURSOR
 (defun its-input (syl key)
   (if (null syl)
       (setq syl (its-initial-ISYL)))
   (let ((output (car syl))
        (k/kk/s (cdr syl)))
-    (cond
-     ((numberp k/kk/s)
+    (if (numberp k/kk/s)
        ;; k/kk/s is "point in keyseq"
-       (its-input-to-vsyl syl key k/kk/s output))
-     ((and its-barf-on-invalid-keyseq
-          (null (its-keyseq-acceptable-p (vector key) syl)))
-      ;; signal before altering
-      (its-input-error))
-     (t
+       (its-input-to-vsyl syl key k/kk/s output)
       ;; It's ISYL
-      (its-state-machine syl key 'its-buffer-ins/del-SYL)))))
+      (its-state-machine syl key 'its-buffer-ins/del-SYL))))
 
 (defun its-input-to-vsyl (syl key point output)
   (if (< key 0)
-      (its-set-cursor-status t)
+      t
     (let ((len (length output)))
       (if (= len point)
          ;; point is at end of VSYL.  Don't need to call state machine.
-         (its-buffer-ins/del-SYL
-          (its-make-VSYL (concat output (vector key))) syl nil)
+         (progn
+           (its-buffer-ins/del-SYL
+            (its-make-VSYL (concat output (vector key))) syl)
+           nil)
        ;; point is at middle of VSYL.
        (let ((new-keyseq (concat (substring output 0 point)
                                  (vector key)
                                  (substring output point))))
          (its-state-machine-keyseq new-keyseq 'its-buffer-ins/del-SYL))))))
+
+(defvar its-barf-on-invalid-keyseq nil
+  "T means don't allow invalid key sequence in input buffer.")
 \f
 ;;;
 ;;; ITS State Machine
 ;;;
 
-(defvar its-disable-special-action nil)
-
 ;; Return CURSOR
 (defun its-state-machine (state key emit)
   (let ((next-state (its-get-next-state state key))
-       expr-output-back kst/t output keyseq back)
-    (cond
-     ;; proceed to next status
-     ((and next-state
-           (not (and its-disable-special-action
-                     (eq (its-get-kst/t next-state) t))))
-      (setq kst/t (its-get-kst/t next-state)
-           output (its-get-output next-state)
-           keyseq (its-get-keyseq next-state))
-      (cond
-       ;; Special actions.
-       ((eq kst/t t)
-       (funcall emit (cons "" keyseq) state 'its-cursor)
-       (apply (car output) (cdr output)))
-
-       ;; Still, it's a intermediate state.
-       ((its-kst-p kst/t)
-       (funcall emit next-state state nil))
-
-       ;; It's negative integer which specifies how many
-       ;; characters we go backwards
-       (kst/t
-       (funcall emit next-state state 'its-cursor)
-       (its-state-machine-keyseq (substring keyseq kst/t) emit (< key 0)))
-
-       ;; Here we arrive to a terminal state.
-       ;; Emit a DSYL, and go ahead.
-       (t
-       (funcall emit next-state state 'its-cursor))))
-
-     ;; push back by otherwise status
-     ((and (>= key 0)
-          (setq expr-output-back (its-get-otherwise state key)))
-      (setq keyseq (concat (its-get-keyseq state) (vector key)))
-      (funcall emit
-              (cons (its-get-output expr-output-back)
-                    (cons keyseq (its-eob-back expr-output-back)))
-              state t)
-      (its-state-machine-keyseq
-       (substring keyseq (its-eob-back expr-output-back)) emit))
-
-     ((eq its-barf-on-invalid-keyseq 'its-keyseq-test)
-      'its-keyseq-test-failed)
-
-     ;; No next state for KEY.  It's invalid sequence.
-     (its-barf-on-invalid-keyseq
-      (its-input-error))
-
-     (t
-      ;; XXX Should make DSYL (instead of VSYL)?
-      (setq keyseq (concat (its-get-keyseq state) (if (> key 0) (vector key))))
-      (funcall emit (its-make-VSYL keyseq) state nil)))))
+       expr-output-back)
+    (if next-state
+       (let ((kst/t (its-get-kst/t next-state)))
+         (funcall emit next-state state)
+         (if (not (its-kst-p kst/t))
+             ;; Here we arrive to a terminal state.
+             ;; Emit a DSYL, and go ahead.
+             (let ((output (its-get-output next-state))
+                   (keyseq (its-get-keyseq next-state))
+                   (back kst/t))
+               (if back
+                   ;; It's negative integer which specifies how many
+                   ;; characters we go backwards
+                   (its-state-machine-keyseq (substring keyseq back)
+                                             emit (< key 0))
+                 'its-cursor))
+           ;; Still, it's a intermediate state.
+           nil))
+      (if (and (>= key 0)
+              (setq expr-output-back (its-get-otherwise state key)))
+         (let ((keyseq (concat (its-get-keyseq state) (char-to-string key))))
+           (funcall emit expr-output-back state)
+           (its-state-machine-keyseq
+            (substring keyseq (its-eob-back expr-output-back)) emit))
+       ;; No next state for KEY.  It's invalid sequence.
+       (if (< key 0)           ; no next state for END of keystroke
+           ;; ISYL --> DSYL   XXX
+           (if its-barf-on-invalid-keyseq
+               (error its-barf-on-invalid-keyseq)
+             (funcall emit (cons (car state)
+                                 (list (its-get-keyseq state))) state)
+             t)
+         (if its-barf-on-invalid-keyseq
+             (error its-barf-on-invalid-keyseq)
+           ;; XXX Should make DSYL (instead of VSYL)?
+           (let ((keyseq (concat (its-get-keyseq state) (vector key))))
+             (funcall emit (its-make-VSYL keyseq) state)
+             nil)))))))
 
 (defvar its-latest-SYL nil
   "The latest SYL inserted.")
 (defun its-state-machine-keyseq (keyseq emit &optional eol)
   (let ((i 0)
        (len (length keyseq))
+       (its-barf-on-invalid-keyseq nil) ; temporally disable DING
        (syl (its-initial-ISYL))
        cursor)
     (while (< i len)
-      (cond
-       ((numberp (cdr syl))
-       ;; VSYL - no need looping
-       (funcall emit
-                (its-make-VSYL (concat (car syl) (substring keyseq i)))
-                syl nil)
-       (setq cursor nil
-             i len))
-       (t
-       (setq cursor (its-state-machine syl (aref keyseq i) emit))))
-      (if (eq cursor 'its-keyseq-test-failed)
-         (setq i len)
-       (setq syl (if cursor (its-initial-ISYL) its-latest-SYL)
-             i (1+ i))))
-    (if (and eol (not (eq cursor 'its-keyseq-test-failed)))
+      (let ((key (aref keyseq i)))
+       (setq cursor 
+             (if (numberp (cdr syl))           ; VSYL
+                 (progn
+                   (funcall emit
+                            (its-make-VSYL (concat (car syl) (vector key)))
+                            syl)
+                   nil)
+               (its-state-machine syl key emit)))
+       (setq i (1+ i))
+       (if cursor
+           (setq syl (its-initial-ISYL))
+         (setq syl its-latest-SYL))))
+    (if eol
        (its-state-machine syl -1 emit)
       cursor)))
 
-(defun its-buffer-ins/del-SYL (newsyl oldsyl cursor)
-  (if its-setup-fence-before-insert-SYL
-      (progn
-       (setq its-setup-fence-before-insert-SYL nil)
-       (its-setup-fence-mode)))
-  (let ((inhibit-read-only t))
-    (its-buffer-delete-SYL oldsyl)
-    (its-update-latest-SYL newsyl)
-    (let ((p (point)))
-      (insert (its-get-output newsyl))
-      (add-text-properties p (point)
-                          (list 'its-map its-current-map
-                                'its-syl newsyl
-                                'egg-lang its-current-language
-                                'read-only t
-                                'intangible 'its-part-1))
-      (if its-fence-face
-         (put-text-property p (point) 'face (its-get-fence-face)))
-      (its-set-cursor-status cursor))))
+(defun its-buffer-ins/del-SYL (newsyl oldsyl)
+  (its-buffer-delete-SYL oldsyl)
+  (its-update-latest-SYL newsyl)
+  (let ((p (point)))
+    (insert (its-get-output newsyl))
+    (add-text-properties p (point)
+                        (list 'its-syl newsyl
+                              'its-map its-current-map
+                              'its-lang its-current-language
+                              'intangible 'its-part-1))
+    (if its-fence-face
+       (put-text-property p (point) 'face its-fence-face))))
 
 (defun its-buffer-delete-SYL (syl)
   (let ((len (length (its-get-output syl))))
 
 (defun its-get-next-state (state key)
   (let ((kst/t (its-get-kst/t state)))
-    (and (listp kst/t)
-        (cdr (assq key (car kst/t))))))
+    (cdr (assq key (car kst/t)))))
 
 ;; XXX XXX XXX
 (defun its-otherwise-match (expr key)
              (setq ebl nil)
            (setq ebl (cdr ebl)))))
       expr-output-back))
-
-(defun its-keyseq-acceptable-p (keyseq &optional syl eol)
-  (let ((i 0)
-       (len (length keyseq))
-       (its-barf-on-invalid-keyseq 'its-keyseq-test)
-       (its-latest-SYL nil)
-       (emit (lambda (nsyl osyl cursor)
-               (its-update-latest-SYL nsyl)
-               cursor))
-       (its-current-map its-current-map)
-       (its-current-select-func its-current-select-func)
-       (its-current-language its-current-language)
-       (its-zhuyin its-zhuyin)
-       (its-previous-select-func its-previous-select-func)
-       cursor)
-    (if (null syl)
-       (setq syl (its-initial-ISYL)))
-    (while (and syl (< i len))
-      (setq cursor (its-state-machine syl (aref keyseq i) emit))
-      (cond
-       ((eq cursor 'its-keyseq-test-failed)
-       (setq syl nil))
-       (cursor
-       (setq syl (its-initial-ISYL)))
-       (t
-       its-latest-SYL))
-      (setq i (1+ i)))
-    (if (and syl eol)
-       (setq cursor (its-state-machine syl -1 emit)))
-    (not (eq cursor 'its-keyseq-test-failed))))
 \f
 ;;;
 ;;; Name --> map
@@ -622,90 +515,39 @@ Return last state."
 (defun its-make-next-state (state key keyseq output &optional back)
   (let ((next-state (its-new-state output keyseq back))
        (kst (its-get-kst/t state)))
-    (cond
-     ((null kst)
+    (if kst
+       (setcar kst (cons (cons key next-state) (car kst)))
       (its-set-kst state (list (list (cons key next-state)))))
-     ((consp kst)
-      (setcar kst (cons (cons key next-state) (car kst))))
-     (t
-      (error "Can't make new state after %S" (its-get-keyseq state))))
     next-state))
-
-(defmacro its-defrule-select-mode-temporally (input select-func)
-  `(its-defrule ,input '(its-select-mode-temporally
-                        ,(intern (concat "its-select-"
-                                         (symbol-name select-func))))
-               t))
 \f
 ;;;
 (defun its-beginning-of-input-buffer ()
   (interactive)
-  (let ((inhibit-read-only t))
-    (its-input-end)
-    (if (not (get-text-property (1- (point)) 'its-start))
-       (let ((begpos (previous-single-property-change (point) 'its-start)))
-         ;; Make SYLs have property of "part 2"
-         (put-text-property begpos (point) 'intangible 'its-part-2)
-         (goto-char begpos)))
-    (its-put-cursor t)))
+  (its-input-end)
+  (if (not (get-text-property (1- (point)) 'its-start))
+      (let ((begpos (previous-single-property-change (point) 'its-start)))
+       ;; Make SYLs have property of "part 2"
+       (put-text-property begpos (point) 'intangible 'its-part-2)
+       (goto-char begpos)))
+  (its-put-cursor t))
 
 (defun its-end-of-input-buffer ()
   (interactive)
-  (let ((inhibit-read-only t))
-    (its-input-end)
-    (if (not (get-text-property (point) 'its-end))
-       (let ((endpos (next-single-property-change (point) 'its-end)))
-         ;; Make SYLs have property of "part 1"
-         (put-text-property (point) endpos 'intangible 'its-part-1)
-         (goto-char endpos)))
-    (its-put-cursor t)))
-
-(defun its-kill-line (n)
-  (interactive "p")
-  (let ((inhibit-read-only t)
-       (p (point)))
-    (its-input-end)
-    (if (> n 0)
-       (cond
-        ((get-text-property (1- (point)) 'its-start)
-         (its-cancel-input))
-        ((get-text-property (point) 'its-end)
-         (its-put-cursor t))
-        (t
-         (delete-region (next-single-property-change (point) 'its-end)
-                        (point))
-         (its-put-cursor t)))
-      (cond
-       ((get-text-property (point) 'its-end)
-       (its-cancel-input))
-       ((get-text-property (1- (point)) 'its-start)
-       (its-put-cursor t))
-       (t
-       (delete-region (point)
-                      (previous-single-property-change (point) 'its-start))
-       (its-put-cursor t))))))
-
-(defun its-cancel-input ()
-  (interactive)
-  (let ((inhibit-read-only t))
-    (delete-region (if (get-text-property (1- (point)) 'its-start)
-                      (point)
-                    (previous-single-property-change (1- (point)) 'its-start))
-                  (if (get-text-property (point) 'its-end)
-                      (point)
-                    (next-single-property-change (point) 'its-end)))
-    (its-put-cursor t)
-    (its-exit-mode-internal)))
+  (its-input-end)
+  (if (not (get-text-property (point) 'its-end))
+      (let ((endpos (next-single-property-change (point) 'its-end)))
+       ;; Make SYLs have property of "part 1"
+       (put-text-property (point) endpos 'intangible 'its-part-1)
+       (goto-char endpos)))
+  (its-put-cursor t))
 
 ;; TODO: move in VSYL
 (defun its-backward-SYL (n)
   (interactive "p")
-  (let ((inhibit-read-only t)
-       syl p old-point)
-    (its-input-end)
-    (setq syl (get-text-property (1- (point)) 'its-syl)
-         p (point)
-         old-point (point))
+  (its-input-end)
+  (let ((syl (get-text-property (1- (point)) 'its-syl))
+       (p (point))
+       (old-point (point)))
     (while (and syl (> n 0))
       (setq p (- p (length (its-get-output syl))))
       (setq syl (get-text-property (1- p) 'its-syl))
@@ -720,18 +562,16 @@ Return last state."
 ;; TODO: move in VSYL
 (defun its-forward-SYL (n)
   (interactive "p")
-  (let ((inhibit-read-only t)
-       syl p old-point)
-    (its-input-end)
-    (setq syl (get-text-property (point) 'its-syl)
-         p (point)
-         old-point (point))
+  (its-input-end)
+  (let ((syl (get-text-property (point) 'its-syl))
+       (p (point))
+       (old-point (point)))
     (while (and syl (> n 0))
       (setq p (+ p (length (its-get-output syl))))
       (setq syl (get-text-property p 'its-syl))
       (setq n (1- n)))
     ;; Make SYLs have property of "part 1"
-    (put-text-property old-point p 'intangible 'its-part-1)
+    (put-text-property p old-point 'intangible 'its-part-1)
     (goto-char p)
     (its-put-cursor t)
     (if (> n 0)
@@ -740,11 +580,9 @@ Return last state."
 ;; TODO: handle VSYL.  KILLFLAG
 (defun its-delete-SYL (n killflag)
   (interactive "p\nP")
-  (let ((inhibit-read-only t)
-       syl p)
-    (its-input-end)
-    (setq syl (get-text-property (point) 'its-syl)
-         p (point))
+  (its-input-end)
+  (let ((syl (get-text-property (point) 'its-syl))
+       (p (point)))
     (while (and syl (> n 0))
       (setq p (+ p (length (its-get-output syl))))
       (setq syl (get-text-property p 'its-syl))
@@ -752,19 +590,19 @@ Return last state."
     (if (> n 0)
        (progn
          (its-put-cursor t)
-         (signal 'end-of-buffer nil))
+         (signal 'args-out-of-range (list p n)))
       (delete-region (point) p)
-      (its-put-cursor t)
       ;; Check if empty
-      (if (and (get-text-property (1- (point)) 'its-start)
-              (get-text-property (1+ (point)) 'its-end))
-         (its-exit-mode-internal)))))
+      (let ((s (get-text-property (1- (point)) 'its-start))
+           (e (get-text-property (point) 'its-end)))
+       (if (and s e)
+           (its-exit-mode-internal)
+         (its-put-cursor t))))))
 
 ;; TODO: killflag
 (defun its-delete-backward-SYL (n killflag)
   (interactive "p\nP")
-  (let ((inhibit-read-only t)
-       (syl (get-text-property (1- (point)) 'its-syl))
+  (let ((syl (get-text-property (1- (point)) 'its-syl))
        (cursor (get-text-property (point) 'its-cursor)))
     (if (null syl)
        (signal 'beginning-of-buffer nil)
@@ -781,168 +619,49 @@ Return last state."
       (setq syl (get-text-property (1- p) 'its-syl))
       (setq n (1- n)))
     (if (> n 0)
-       (signal 'beginning-of-buffer nil)
+       (signal 'args-out-of-range (list p n))
       (delete-region p (1+ (point)))   ; also delete cursor
-      (its-put-cursor t)
       ;; Check if empty
-      (if (and (get-text-property (1- (point)) 'its-start)
-              (get-text-property (1+ (point)) 'its-end))
-         (its-exit-mode-internal)))))
+      (let ((s (get-text-property (1- (point)) 'its-start))
+           (e (get-text-property (point) 'its-end)))
+       (if (and s e)
+           (its-exit-mode-internal)
+         (its-put-cursor t))))))
 
 (defvar its-delete-by-keystroke nil)
 
-(defun its-delete-backward-SYL-by-keystroke (n killflag)
-  (interactive "p\nP")
-  (let ((inhibit-read-only t)
-       (its-delete-by-keystroke t))
-    (its-delete-backward-SYL n killflag)))
-
 ;; TODO: killflag
 (defun its-delete-backward-within-SYL (syl n killflag)
   (let* ((keyseq (its-get-keyseq-syl syl))
         (len (length keyseq))
-        (p (- (point) (length (its-get-output syl))))
-        (its-current-map (get-text-property (1- (point)) 'its-map))
-        (its-current-language (get-text-property (1- (point)) 'egg-lang))
-        back pp)
-    (if (< n 0)
-       (signal 'args-out-of-range (list (- (point) n) (point))))
-    (if its-delete-by-keystroke
-      (while (null (or (eq p pp) (its-concrete-DSYL-p syl)))
-         (setq pp p)
-         (while (and (setq syl (get-text-property (1- p) 'its-syl))
-                     (its-DSYL-with-back-p syl)
-                     (<= (setq back (- (its-get-kst/t syl))) len)
-                     (> back (- len n))
-                     (equal (substring (its-get-keyseq syl) (- back))
-                            (substring keyseq 0 back)))
-           (setq keyseq (concat (its-get-keyseq-syl syl) keyseq)
-                 len (length keyseq)
-                 p (- p (length (its-get-output syl)))))
-         (if (and (eq p pp) syl (> n len))
-             (setq n (- n len)
-                   keyseq (its-get-keyseq-syl syl)
-                   len (length keyseq)
-                   p (- p (length (its-get-output syl))))))
-      (if (and (> n len) (its-concrete-DSYL-p syl))
-         (setq len 1)))
-    (if (> n len)
-       (setq n (- n len)
-             len 0))
-    (while (and (> n len) (setq syl (get-text-property (1- p) 'its-syl)))
-      (setq n (1- n)
-           p (- p (length (its-get-output syl)))))
+        (p (point))
+        (its-current-map (get-text-property (1- (point)) 'its-map)))
     (if (> n len)
-       (signal 'beginning-of-buffer nil))
-    (delete-region p (point))
-    (cond
-     ((> len n)
-      (its-state-machine-keyseq (substring keyseq 0 (- len n)) 
-                               'its-buffer-ins/del-SYL))
-     ;; Check if empty
-     ((and (get-text-property (1- (point)) 'its-start)
-          (get-text-property (1+ (point)) 'its-end))
-      (its-exit-mode-internal))
-     ((and its-delete-by-keystroke
-          (null (its-concrete-DSYL-p (get-text-property (1- p) 'its-syl))))
-      (its-set-cursor-status 'its-cursor))
-     (t
-      (its-set-cursor-status t)))))
-
+       (signal 'args-out-of-range (list p n)))
+    ;; Delete CURSOR
+    (delete-region p (1+ p))
+    (its-buffer-delete-SYL syl)
+    (if (= n len)
+       ;; Check if empty
+       (let ((s (get-text-property (1- (point)) 'its-start))
+             (e (get-text-property (point) 'its-end)))
+         (if (and s e)
+             (its-exit-mode-internal)
+           (its-put-cursor (not its-delete-by-keystroke))))
+      (setq keyseq (substring keyseq 0 (- len n)))
+      (let ((r (its-state-machine-keyseq keyseq 'its-buffer-ins/del-SYL)))
+       (its-put-cursor r)))))
+
+;; XXX: NIY
 (defun its-transpose-chars (n)
-  (interactive "p")
-  (let ((inhibit-read-only t)
-       (syl (get-text-property (1- (point)) 'its-syl))
-       (cursor (get-text-property (point) 'its-cursor))
-       keyseq len)
-    (cond
-     ((null syl)
-      (signal 'beginning-of-buffer nil))
-     ((eq cursor t)
-      (if (and (= n 1) (get-text-property (1+ (point)) 'its-end))
-         (progn
-           (its-backward-SYL 1)
-           (setq syl (get-text-property (1- (point)) 'its-syl))
-           (if (null syl)
-               (signal 'beginning-of-buffer nil))))
-      (its-buffer-delete-SYL syl)
-      (while (> n 0)
-       (if (get-text-property (1+ (point)) 'its-end)
-           (progn
-             (its-buffer-ins/del-SYL syl nil t)
-             (signal 'end-of-buffer nil)))
-       (its-forward-SYL 1)
-       (setq n (1- n)))
-      (while (< n 0)
-       (if (get-text-property (1- (point)) 'its-start)
-           (progn
-             (its-buffer-ins/del-SYL syl nil t)
-             (signal 'beginning-of-buffer nil)))
-       (its-backward-SYL 1)
-       (setq n (1+ n)))
-      (its-buffer-ins/del-SYL syl nil t))
-     (t
-      (setq keyseq (its-get-keyseq-syl syl)
-           len (length keyseq))
-      (cond
-       ((or (> n 1) (<= len 1))
-       (signal 'end-of-buffer nil))
-       ((>= (- n) len)
-       (signal 'beginning-of-buffer nil))
-       (t
-       (setq n (if (> n 0) (- -1 n) (1- n)))
-       (setq keyseq (concat (substring keyseq 0 n)
-                            (substring keyseq -1)
-                            (substring keyseq n -1)))
-       (if (and its-barf-on-invalid-keyseq
-                (null (its-keyseq-acceptable-p keyseq)))
-           (its-input-error))
-       (delete-region (- (point) (length (its-get-output syl))) (point))
-       (its-state-machine-keyseq keyseq 'its-buffer-ins/del-SYL)))))))
-
-(defun its-yank (&optional arg)
-  (interactive "*P")
-  (let ((inhibit-read-only t))
-    (its-input-end)
-    (its-put-cursor t)
-    (yank arg)
-    (its-setup-yanked-portion (region-beginning) (region-end))))
-
-(defun its-yank-pop (arg)
-  (interactive "*p")
-  (let ((inhibit-read-only t))
-    (its-input-end)
-    (its-put-cursor t)
-    (yank-pop arg)
-    (its-setup-yanked-portion (region-beginning) (region-end))))
-
-(defun its-setup-yanked-portion (start end)
-  (let ((yank-before (eq (point) end))
-       (max-sisheng (make-char 'chinese-sisheng 127))
-       p syl lang)
-    (remove-text-properties start end '(intangible nil))
-    (egg-separate-languages start end t)
-    (goto-char start)
-    (while (< (point) end)
-      (setq p (point)
-           lang (get-text-property p 'egg-lang))
-      (if (and
-          (or (equal lang "Chinese-GB") (equal lang "Chinese-CNS"))
-          (<= (following-char) max-sisheng)
-          (setq len (egg-chinese-syllable (buffer-substring (point) end))))
-         (goto-char (+ (point) len))
-       (forward-char))
-      (setq syl (buffer-substring-no-properties p (point)))
-      (put-text-property p (point) 'its-syl (cons syl syl))
-      (if its-fence-face
-         (let ((its-current-language (get-text-property p 'egg-lang)))
-           (put-text-property p (point) 'face (its-get-fence-face)))))
-    (if yank-before
-       (add-text-properties start end '(read-only t intangible its-part-1))
-      (add-text-properties start end '(read-only t intangible its-part-2))
-      (delete-region (point) (1+ (point)))
-      (goto-char start)
-      (its-put-cursor t))))
+  (interactive)
+  (let ((syl (get-text-property (1- (point)) 'its-syl))
+       (cursor (get-text-property (point) 'its-cursor)))
+    (if (null syl)
+       (signal 'beginning-of-buffer nil)
+      (if (eq cursor t)
+         (its-delete-backward-SYL-internal n nil)
+       (its-delete-backward-within-SYL syl 2 nil)))))
 
 ;; Return VOID
 (defun its-input-end ()
@@ -955,85 +674,67 @@ Return last state."
 (defun its-exit-mode ()
   "Exit ITS mode."
   (interactive)
-  (let ((inhibit-read-only t))
-    (its-exit-mode-internal)))
+  (its-input-end)
+  (its-exit-mode-internal))
 
 (defun its-exit-mode-off-input-method ()
   "Exit ITS mode."
   (interactive)
-  (let ((inhibit-read-only t))
-    (its-exit-mode-internal)
-    (inactivate-input-method)))
+  (its-input-end)
+  (its-exit-mode-internal)
+  (inactivate-input-method))
 
 ;; TODO: handle overwrite-mode, insertion-hook, fill...
 (defun its-exit-mode-internal (&optional proceed-to-conversion)
-  (let (start end s e)
-    (its-select-previous-mode t)
-    ;; Delete CURSOR
-    (delete-region (point) (1+ (point)))
+  (let (start end)
     ;; Delete open fence
-    (setq s (if (get-text-property (1- (point)) 'its-start)
-               (point)
-             (previous-single-property-change (point) 'its-start))
-        start (- s (length its-fence-open)))
-    (delete-region start s)
+    (if (get-text-property (1- (point)) 'its-start)
+       (setq start (1- (point)))
+      (setq start (1- (previous-single-property-change (point) 'its-start))))
+    (delete-region start (1+ start))
     ;; Delete close fence
-    (setq end (if (get-text-property (point) 'its-end)
-                 (point)
-               (next-single-property-change (point) 'its-end))
-         e (+ end (length its-fence-close)))
-    (delete-region end e)
+    (if (get-text-property (point) 'its-end)
+       (setq end (point))
+      (setq end (next-single-property-change (point) 'its-end)))
+    (delete-region end (1+ end))
+    ;; Remove all properties added by ITS
+    (remove-text-properties start end '(its-map nil
+                                       face nil
+                                       intangible nil))
     (if proceed-to-conversion
        (egg-convert-region start end)
-      ;; Remove all properties
-      (set-text-properties start end nil)
+      (remove-text-properties start end '(its-lang nil its-syl nil))
       (egg-do-auto-fill)
       (run-hooks 'input-method-after-insert-chunk-hook))))
 
 (defun its-kick-convert-region ()
   (interactive)
-  (let ((inhibit-read-only t))
-    (its-exit-mode-internal t)))
-
-(defun its-kick-convert-region-or-self-insert ()
-  (interactive)
-  (let ((syl (and (null (get-text-property (point) 'its-cursor))
-                 (get-text-property (1- (point)) 'its-syl))))
-    (if (its-keyseq-acceptable-p (vector last-command-char) syl)
-       (its-self-insert-char)
-      (its-kick-convert-region))))
+  (its-input-end)
+  (its-exit-mode-internal t))
 
 (defun its-in-fence-p ()
-  (eq (get-text-property (point) 'intangible) 'its-part-2))
+  (let ((prop (get-text-property (point) 'intangible)))
+    (or (eq prop 'its-part-1) (eq prop 'its-part-2))))
 \f
-(defvar its-translation-result "" "")
+(defvar its-translation-result nil "")
 
-(defun its-ins/del-SYL-batch (newsyl oldsyl cursor)
+(defun its-ins/del-SYL-batch (newsyl oldsyl)
   (its-update-latest-SYL newsyl)
   (if (and newsyl
           (consp (cdr newsyl))
           (not (its-kst-p (its-get-kst/t newsyl))))
       ;; DSYL
-      (let ((output (its-get-output newsyl))
-           (oldlen (length its-translation-result)))
-       (setq its-translation-result (concat its-translation-result output))
-       (put-text-property oldlen (length its-translation-result)
-                          'egg-lang its-current-language
-                          its-translation-result)))
-  cursor)
-
-(defun its-translate-region (start end)
-  (interactive "r")
-  (its-translate-region-internal start end)
-  (set-text-properties start (point) nil))
+      (setq its-translation-result
+           (cons (its-get-output newsyl) its-translation-result))))
 
-(defun its-translate-region-internal (start end)
-  (setq its-translation-result "")
+(defun its-translate-region (start end &optional map)
+  (interactive "r")
+  (setq its-translation-result nil)
   (goto-char start)
   (let ((i 0)
        (syl (its-initial-ISYL))
        ;; temporally enable DING
-       (its-barf-on-invalid-keyseq t)
+       (its-barf-on-invalid-keyseq "Invalid Romaji Sequence")
        cursor)
     (while (< (point) end)
       (let ((key (following-char)))
@@ -1045,30 +746,9 @@ Return last state."
     (if (eq syl its-latest-SYL)
        (its-state-machine syl -1 'its-ins/del-SYL-batch))
     (delete-region start end)
-    (insert its-translation-result)))
+    (apply 'insert (reverse its-translation-result))))
 \f
-(defun its-set-mode-line-title ()
-  (let ((title (its-get-indicator its-current-map)))
-    (setq current-input-method-title (if its-previous-select-func
-                                        (concat "<" title ">")
-                                      title))
-    (force-mode-line-update)))
-
-(defun its-select-mode-temporally (func)
-  (let ((select-func its-current-select-func))
-    (funcall func)
-    (if (null its-previous-select-func)
-       (setq its-previous-select-func select-func))
-    (its-set-mode-line-title)))
-
-(defun its-select-previous-mode (&optional quiet)
-  (interactive)
-  (if (null its-previous-select-func)
-      (if (null quiet)
-         (beep))
-    (funcall its-previous-select-func)
-    (setq its-previous-select-func nil)
-    (its-set-mode-line-title)))
+(require 'its-keydef)
 
 (provide 'its)
 ;;; its.el ends here.
index 888c434..a37f32e 100644 (file)
@@ -1,45 +1,15 @@
-;;; its/hangul.el --- Hangul Input in Egg Input Method Architecture
-
-;; Copyright (C) 1997, 1998 Mule Project,
-;; Powered by Electrotechnical Laboratory, JAPAN.
-;; Project Leader: Satoru Tomura <tomura@etl.go.jp>
-
-;; Author: NIIBE Yutaka <gniibe@mri.co.jp>
-;;         KATAYAMA Yoshio <kate@pfu.co.jp>
-
-;; This file will be part of GNU Emacs (in future).
-
-;; GNU Emacs is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
-
-;; GNU Emacs 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 General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
-
-;;; Commentary:
-
-
-;;; Code:
-
 (eval-when-compile
   (require 'its)
   (require 'cl))
 
-(defvar its-hangul-enable-jeonkak-alphabet t "*Enable Jeonkak alphabet")
-(defvar        its-hangul-period ". " "*\e$(C#.\e(B")    ; ". " "\e$(C#.\e(B"
-(defvar        its-hangul-comma  ", " "*\e$(C#,\e(B")    ; ", " "\e$(C#,\e(B"
 (defvar its-hangul-open-bracket  "\e$(C!8\e(B" "*[")  ; "\e$(C#[\e(B"
-(defvar its-hangul-close-bracket "\e$(C!9\e(B" "*]")  ; "\e$(C#]\e(B"
+(defvar its-hangul-close-bracket  "\e$(C!9\e(B" "*]") ; "\e$(C#]\e(B"
 
 (eval-when-compile
+
+ (defvar its-jeonkak-escape "J")
+ (defvar its-pankak-escape  "B")
+
  (defconst its-hangul-kijuhynbmlopOP
    (its-make-class+back "[kijuhynbmlopOP]" -2))
  (defconst its-hangul-kijuhynbmlopP
      (its-defrule-otherwise state output))))
 
 (define-its-state-machine its-hangul-map
-  "hangul" "\e$(CGQ\e(B" "Korean"
+  "hangul" "\e$(CGQ\e(B" "korean"
   "Map for Hangul input. (Korean)"
-
-  (defconst its-jeonkak-escape "Z")
-  (defconst its-pankak-escape  "X")
-
-  (its-defrule-select-mode-temporally "B" downcase)
-  (its-defrule-select-mode-temporally "J" jeonkak-downcase)
-
   (its-defrule-hangul  "r"     "\e$(C$!\e(B")
   (its-defrule-hangul  "s"     "\e$(C$$\e(B")
   (its-defrule-hangul  "e"     "\e$(C$'\e(B")
     (its-define-hangul "glt"   "\e$(CH}\e(B"     kijuhynbmlopOP)
     (its-define-hangul "gld"   "\e$(CH~\e(B"     kijuhynbmlopOP))
 
-  (dolist (ascii '(("1" . "\e$(C#1\e(B")  ("2" . "\e$(C#2\e(B")  ("3" . "\e$(C#3\e(B")  ("4" . "\e$(C#4\e(B")
-                  ("5" . "\e$(C#5\e(B")  ("6" . "\e$(C#6\e(B")  ("7" . "\e$(C#7\e(B")  ("8" . "\e$(C#8\e(B")
-                  ("9" . "\e$(C#9\e(B")  ("0" . "\e$(C#0\e(B")
-                  (" " . "\e$(C!!\e(B")  ("!" . "\e$(C#!\e(B")  ("@" . "\e$(C#@\e(B")  ("#" . "\e$(C##\e(B")
-                  ("$" . "\e$(C#$\e(B")  ("%" . "\e$(C#%\e(B")  ("^" . "\e$(C#^\e(B")  ("&" . "\e$(C#&\e(B")
-                  ("*" . "\e$(C#*\e(B")  ("(" . "\e$(C#(\e(B")  (")" . "\e$(C#)\e(B")
-                  ("-" . "\e$(C#-\e(B")  ("=" . "\e$(C#=\e(B")  ("`" . "\e$(C#`\e(B")  ("\\" . "\e$(C#\\e(B")
-                  ("|" . "\e$(C#|\e(B")  ("_" . "\e$(C#_\e(B")  ("+" . "\e$(C#+\e(B")  ("~" . "\e$(C#~\e(B")
-                  ("[" . "\e$(C!8\e(B")  ("]" . "\e$(C!9\e(B")  ("{" . "\e$(C#{\e(B")  ("}" . "\e$(C#}\e(B")
-                  (":" . "\e$(C#:\e(B")  (";" . "\e$(C#;\e(B")  ("\"" . "\e$(C#"\e(B") ("'" . "\e$(C#'\e(B")
-                  ("<" . "\e$(C#<\e(B")  (">" . "\e$(C#>\e(B")  ("?" . "\e$(C#?\e(B")  ("/" . "\e$(C#/\e(B")
-                  ("," . "\e$(C#,\e(B")  ("." . "\e$(C#.\e(B")
-                  ("a" . "\e$(C#a\e(B")  ("b" . "\e$(C#b\e(B")  ("c" . "\e$(C#c\e(B")  ("d" . "\e$(C#d\e(B")
-                  ("e" . "\e$(C#e\e(B")  ("f" . "\e$(C#f\e(B")  ("g" . "\e$(C#g\e(B")  ("h" . "\e$(C#h\e(B")
-                  ("i" . "\e$(C#i\e(B")  ("j" . "\e$(C#j\e(B")  ("k" . "\e$(C#k\e(B")  ("l" . "\e$(C#l\e(B")
-                  ("m" . "\e$(C#m\e(B")  ("n" . "\e$(C#n\e(B")  ("o" . "\e$(C#o\e(B")  ("p" . "\e$(C#p\e(B")
-                  ("q" . "\e$(C#q\e(B")  ("r" . "\e$(C#r\e(B")  ("s" . "\e$(C#s\e(B")  ("t" . "\e$(C#t\e(B")
-                  ("u" . "\e$(C#u\e(B")  ("v" . "\e$(C#v\e(B")  ("w" . "\e$(C#w\e(B")  ("x" . "\e$(C#x\e(B")
-                  ("y" . "\e$(C#y\e(B")  ("z" . "\e$(C#z\e(B")
-                  ("A" . "\e$(C#A\e(B")  ("B" . "\e$(C#B\e(B")  ("C" . "\e$(C#C\e(B")  ("D" . "\e$(C#D\e(B")
-                  ("E" . "\e$(C#E\e(B")  ("F" . "\e$(C#F\e(B")  ("G" . "\e$(C#G\e(B")  ("H" . "\e$(C#H\e(B")
-                  ("I" . "\e$(C#I\e(B")  ("J" . "\e$(C#J\e(B")  ("K" . "\e$(C#K\e(B")  ("L" . "\e$(C#L\e(B")
-                  ("M" . "\e$(C#M\e(B")  ("N" . "\e$(C#N\e(B")  ("O" . "\e$(C#O\e(B")  ("P" . "\e$(C#P\e(B")
-                  ("Q" . "\e$(C#Q\e(B")  ("R" . "\e$(C#R\e(B")  ("S" . "\e$(C#S\e(B")  ("T" . "\e$(C#T\e(B")
-                  ("U" . "\e$(C#U\e(B")  ("V" . "\e$(C#V\e(B")  ("W" . "\e$(C#W\e(B")  ("X" . "\e$(C#X\e(B")
-                  ("Y" . "\e$(C#Y\e(B")  ("Z" . "\e$(C#Z\e(B")))
-    (let ((in (car ascii)) (out (cdr ascii)))
-      (its-defrule (concat its-pankak-escape in) in)
-      (its-defrule (concat its-jeonkak-escape in) out))))
+  ;;; Jeonkak Symbols
+
+  (its-defrule   "1"   "\e$(C#1\e(B")
+  (its-defrule   "2"   "\e$(C#2\e(B")
+  (its-defrule   "3"   "\e$(C#3\e(B")
+  (its-defrule   "4"   "\e$(C#4\e(B")
+  (its-defrule   "5"   "\e$(C#5\e(B")
+  (its-defrule   "6"   "\e$(C#6\e(B")
+  (its-defrule   "7"   "\e$(C#7\e(B")
+  (its-defrule   "8"   "\e$(C#8\e(B")
+  (its-defrule   "9"   "\e$(C#9\e(B")
+  (its-defrule   "0"   "\e$(C#0\e(B")
+
+  ;;(its-defrule   " "   "\e$(C!!\e(B")
+  (its-defrule   "!"   "\e$(C#!\e(B")
+  (its-defrule   "@"   "\e$(C#@\e(B")
+  (its-defrule   "#"   "\e$(C##\e(B")
+  (its-defrule   "$"   "\e$(C#$\e(B")
+  (its-defrule   "%"   "\e$(C#%\e(B")
+  (its-defrule   "^"   "\e$(C#^\e(B")
+  (its-defrule   "&"   "\e$(C#&\e(B")
+  (its-defrule   "*"   "\e$(C#*\e(B")
+  (its-defrule   "("   "\e$(C#(\e(B")
+  (its-defrule   ")"   "\e$(C#)\e(B")
+  (its-defrule   "-"   "\e$(C#-\e(B")
+  (its-defrule   "="   "\e$(C#=\e(B")
+  (its-defrule   "`"   "\e$(C#`\e(B")
+  (its-defrule   "\\"  "\e$(C#\\e(B")
+  (its-defrule   "|"   "\e$(C#|\e(B")
+  (its-defrule   "_"   "\e$(C#_\e(B")
+  (its-defrule   "+"   "\e$(C#+\e(B")
+  (its-defrule   "~"   "\e$(C#~\e(B")
+  (its-defrule   "["   "\e$(C!8\e(B");;(its-defrule   "["   "\e$(C#[\e(B")
+  (its-defrule   "]"   "\e$(C!9\e(B");;(its-defrule   "]"   "\e$(C#]\e(B")
+  (its-defrule   "{"   "\e$(C#{\e(B")
+  (its-defrule   "}"   "\e$(C#}\e(B")
+  (its-defrule   ":"   "\e$(C#:\e(B")
+  (its-defrule   ";"   "\e$(C#;\e(B")
+  (its-defrule   "\""  "\e$(C#"\e(B")
+  (its-defrule   "'"   "\e$(C#'\e(B")
+  (its-defrule   "<"   "\e$(C#<\e(B")
+  (its-defrule   ">"   "\e$(C#>\e(B")
+  (its-defrule   "?"   "\e$(C#?\e(B")
+  (its-defrule   "/"   "\e$(C#/\e(B")
+  (its-defrule   ","   "\e$(C#,\e(B")
+  (its-defrule   "."   "\e$(C#.\e(B")
+
+  (its-defrule (concat its-jeonkak-escape " ") "\e$(C!!\e(B")
+  (let ((i ?!))
+    (while (<= i ?~)
+      (its-defrule (concat its-jeonkak-escape (char-to-string i))
+                  (char-to-string (+ (- ?\e$(C#!\e(B ?!) i)))
+      (setq i (1+ i))))
+
+  ;;; pankak 
+  (let ((i ?!))
+    (while (<= i ?~)
+      (its-defrule (concat its-pankak-escape (char-to-string i))
+                  (char-to-string i))
+       (setq i (1+ i)))))
 
 (define-its-state-machine-append its-hangul-map
-  (its-defrule "[" its-hangul-open-bracket)
-  (its-defrule "]" its-hangul-close-bracket)
-  (its-defrule "." its-hangul-period)
-  (its-defrule "," its-hangul-comma)
-
-  (if its-hangul-enable-jeonkak-alphabet
-      (progn
-       (its-defrule   "1"   "\e$(C#1\e(B")  (its-defrule   "2"   "\e$(C#2\e(B")
-       (its-defrule   "3"   "\e$(C#3\e(B")  (its-defrule   "4"   "\e$(C#4\e(B")
-       (its-defrule   "5"   "\e$(C#5\e(B")  (its-defrule   "6"   "\e$(C#6\e(B")
-       (its-defrule   "7"   "\e$(C#7\e(B")  (its-defrule   "8"   "\e$(C#8\e(B")
-       (its-defrule   "9"   "\e$(C#9\e(B")  (its-defrule   "0"   "\e$(C#0\e(B")
-       (its-defrule   "!"   "\e$(C#!\e(B")  (its-defrule   "@"   "\e$(C#@\e(B")
-       (its-defrule   "#"   "\e$(C##\e(B")  (its-defrule   "$"   "\e$(C#$\e(B")
-       (its-defrule   "%"   "\e$(C#%\e(B")  (its-defrule   "^"   "\e$(C#^\e(B")
-       (its-defrule   "&"   "\e$(C#&\e(B")  (its-defrule   "*"   "\e$(C#*\e(B")
-       (its-defrule   "("   "\e$(C#(\e(B")  (its-defrule   ")"   "\e$(C#)\e(B")
-       (its-defrule   "-"   "\e$(C#-\e(B")  (its-defrule   "~"   "\e$(C#~\e(B")
-       (its-defrule   "="   "\e$(C#=\e(B")  (its-defrule   "`"   "\e$(C#`\e(B")
-       (its-defrule   "\\"  "\e$(C#\\e(B")  (its-defrule   "|"   "\e$(C#|\e(B")
-       (its-defrule   "_"   "\e$(C#_\e(B")  (its-defrule   "+"   "\e$(C#+\e(B")
-       (its-defrule   "{"   "\e$(C#{\e(B")  (its-defrule   "}"   "\e$(C#}\e(B")
-       (its-defrule   ":"   "\e$(C#:\e(B")  (its-defrule   ";"   "\e$(C#;\e(B")
-       (its-defrule   "\""  "\e$(C#"\e(B")  (its-defrule   "'"   "\e$(C#'\e(B")
-       (its-defrule   "<"   "\e$(C#<\e(B")  (its-defrule   ">"   "\e$(C#>\e(B")
-       (its-defrule   "?"   "\e$(C#?\e(B")  (its-defrule   "/"   "\e$(C#/\e(B"))
-    (progn
-      (its-defrule   "1"   "1")  (its-defrule   "2"   "2")
-      (its-defrule   "3"   "3")  (its-defrule   "4"   "4")
-      (its-defrule   "5"   "5")  (its-defrule   "6"   "6")
-      (its-defrule   "7"   "7")  (its-defrule   "8"   "8")
-      (its-defrule   "9"   "9")  (its-defrule   "0"   "0")
-      (its-defrule   "!"   "!")  (its-defrule   "@"   "@")
-      (its-defrule   "#"   "#")  (its-defrule   "$"   "$")
-      (its-defrule   "%"   "%")  (its-defrule   "^"   "^")
-      (its-defrule   "&"   "&")  (its-defrule   "*"   "*")
-      (its-defrule   "("   "(")  (its-defrule   ")"   ")")
-      (its-defrule   "-"   "-")  (its-defrule   "~"   "~")
-      (its-defrule   "="   "=")  (its-defrule   "`"   "`")
-      (its-defrule   "\\"  "\\") (its-defrule   "|"   "|")
-      (its-defrule   "_"   "_")  (its-defrule   "+"   "+")
-      (its-defrule   "{"   "{")  (its-defrule   "}"   "}")
-      (its-defrule   ":"   ":")  (its-defrule   ";"   ";")
-      (its-defrule   "\""  "\"") (its-defrule   "'"   "'")
-      (its-defrule   "<"   "<")  (its-defrule   ">"   ">")
-      (its-defrule   "?"   "?")  (its-defrule   "/"   "/"))))
+  (its-defrule "[" its-hangul-open-bracket  nil t)
+  (its-defrule "]" its-hangul-close-bracket nil t)
+  )
 
 (provide 'its/hangul)
index 051dcc6..a08cec9 100644 (file)
 (define-its-state-machine its-hira-map
   "roma-kana" "\e$B$"\e(B" "Japanese" nil
   "Map for Romaji-Hiragana translation. (Japanese)"
-
   (defconst its-zenkaku-escape "Z")  ;; Escape character to Zenkaku inputs
   (defconst its-hankaku-escape "~")  ;; Escape character to Hankaku inputs
 
-  (its-defrule-select-mode-temporally "q" downcase)
-  (its-defrule-select-mode-temporally "Q" zenkaku-downcase)
-
 ;;; k      k
 ;;; kk     \e$B$C\e(Bk
 ;;; kka    \e$B$C$+\e(B
       (its-defrule "nn" "\e$B$s\e(B")
     (its-defrule "nn" "\e$B$s\e(B" -1))
 
-  (its-defrule "-" its-hira-horizontal)
-  (its-defrule "[" its-hira-open-bracket)
-  (its-defrule "]" its-hira-close-bracket)
+  (its-defrule "-"   its-hira-horizontal)
+  (its-defrule "["    its-hira-open-bracket)
+  (its-defrule "]"    its-hira-close-bracket)
   (its-defrule "." its-hira-period)
   (its-defrule "," its-hira-comma)
 
        (its-defrule   "="   "\e$B!a\e(B")  (its-defrule   "`"   "\e$B!.\e(B")
        (its-defrule   "\\"  "\e$B!o\e(B")  (its-defrule   "|"   "\e$B!C\e(B")
        (its-defrule   "_"   "\e$B!2\e(B")  (its-defrule   "+"   "\e$B!\\e(B")
-       (its-defrule   "{"   "\e$B!P\e(B")  (its-defrule   "}"   "\e$B!Q\e(B")
-       (its-defrule   ":"   "\e$B!'\e(B")  (its-defrule   ";"   "\e$B!(\e(B")
-       (its-defrule   "\""  "\e$B!I\e(B")  (its-defrule   "'"   "\e$B!G\e(B")
-       (its-defrule   "<"   "\e$B!c\e(B")  (its-defrule   ">"   "\e$B!d\e(B")
-       (its-defrule   "?"   "\e$B!)\e(B")  (its-defrule   "/"   "\e$B!?\e(B"))
+       (its-defrule   "~"   "\e$B!1\e(B" nil t)
+       (its-defrule   "{"   "\e$B!P\e(B")
+       (its-defrule   "}"   "\e$B!Q\e(B")  (its-defrule   ":"   "\e$B!'\e(B")
+       (its-defrule   ";"   "\e$B!(\e(B")  (its-defrule   "\""  "\e$B!I\e(B")
+       (its-defrule   "'"   "\e$B!G\e(B")  (its-defrule   "<"   "\e$B!c\e(B")
+       (its-defrule   ">"   "\e$B!d\e(B")  (its-defrule   "?"   "\e$B!)\e(B")
+       (its-defrule   "/"   "\e$B!?\e(B"))
     (progn
       (its-defrule   "1"   "1")  (its-defrule   "2"   "2")
       (its-defrule   "3"   "3")  (its-defrule   "4"   "4")
       (its-defrule   "&"   "&")  (its-defrule   "*"   "*")
       (its-defrule   "("   "(")  (its-defrule   ")"   ")")
       (its-defrule   "="   "=")  (its-defrule   "`"   "`")
-      (its-defrule   "\\"  "\\") (its-defrule   "|"   "|")
+      (its-defrule   "\\"  "\\")  (its-defrule   "|"   "|")
       (its-defrule   "_"   "_")  (its-defrule   "+"   "+")
-      (its-defrule   "{"   "{")  (its-defrule   "}"   "}")
-      (its-defrule   ":"   ":")  (its-defrule   ";"   ";")
-      (its-defrule   "\""  "\"") (its-defrule   "'"   "'")
-      (its-defrule   "<"   "<")  (its-defrule   ">"   ">")
-      (its-defrule   "?"   "?")  (its-defrule   "/"   "/")))
+      (its-defrule   "~"   "~" nil t)
+      (its-defrule   "{"   "{")
+      (its-defrule   "}"   "}")  (its-defrule   ":"   ":")
+      (its-defrule   ";"   ";")  (its-defrule   "\""  "\"")
+      (its-defrule   "'"   "'")  (its-defrule   "<"   "<")
+      (its-defrule   ">"   ">")  (its-defrule   "?"   "?")
+      (its-defrule   "/"   "/")))
   )
 
 (provide 'its/hira)
index 6a32775..9d3505d 100644 (file)
@@ -1,46 +1,17 @@
-;;; its/pinyin.el --- Pinyin Input in Egg Input Method Architecture
-
-;; Copyright (C) 1997, 1998 Mule Project,
-;; Powered by Electrotechnical Laboratory, JAPAN.
-;; Project Leader: Satoru Tomura <tomura@etl.go.jp>
-
-;; Author: KATAYAMA Yoshio <kate@pfu.co.jp>
-
-;; This file will be part of GNU Emacs (in future).
-
-;; GNU Emacs is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
-
-;; GNU Emacs 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 General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
-
-;;; Commentary:
-
-
-;;; Code:
-
 (eval-when-compile
   (require 'its)
   (require 'cl))
 
-(defvar its-pinyin-cn-enable-quanjioao-alphabet t "*Enable Quanjiao alphabet")
 (defvar its-pinyin-cn-open-braket  "\e$A!8\e(B" "*[") ; "\e$A#[\e(B"
 (defvar its-pinyin-cn-close-braket "\e$A!9\e(B" "*]") ; "\e$A#]\e(B"
 
-(defvar its-pinyin-tw-enable-quanjioao-alphabet t "*Enable Quanjiao alphabet")
 (defvar its-pinyin-tw-open-braket  "\e$(G!V\e(B" "*[") ; "\e$(G!b\e(B "
 (defvar its-pinyin-tw-close-braket "\e$(G!W\e(B" "*]") ; "\e$(G!c\e(B"
 
 (eval-when-compile
+  (defvar its-quanjiao-escape "Z")
+  (defvar its-banjiao-escape  "X")
+
   (defconst its-pinyin-term
     (char-to-string (make-char 'chinese-sisheng ?@)))
 
       state))
 
   (defmacro its-do-sisheng-table (list)
-    `(progn
-       ,@(mapcar (lambda (syl)
-                  `(its-define-sisheng ,@syl))
-                list)))
+    `(progn ,@(mapcar (lambda (syl)
+                       `(its-define-sisheng ,(car syl) ,(cdr syl)))
+                     list)))
 
   (defmacro its-define-sisheng (shengmu yunmu)
     `(let ((qing (nth 5 ,yunmu)) (y (car ,yunmu))
           (UO   '("uo"   "u\e(0-\e(B"   "u\e(0.\e(B"   "u\e(0/\e(B"   "u\e(00\e(B"   "uo"  )))
 
        (its-do-sisheng-table
-       (((- B C D F G H   K L M N P     S T W   Y Z CH SH ZH ) A)
-        ((- B C D   G H   K L M N P     S T W     Z CH SH ZH ) AI)
-        ((- B C D F G H   K L M N P   R S T W   Y Z CH SH ZH ) AN)
-        ((- B C D F G H   K L M N P   R S T W   Y Z CH SH ZH ) ANG)
-        ((- B C D   G H   K L M N P   R S T     Y Z CH SH ZH ) AO)
-        ((-   C D   G H   K L M N     R S T     Y Z CH SH ZH ) E)
-        ((- B C D F G H   K L M N P       T W     Z    SH ZH ) EI)
-        ((- B C D F G H   K   M N P   R S   W     Z CH SH ZH ) EN)
-        ((- B C D F G H   K L M N P   R S T W     Z CH SH ZH ) ENG)
-        ((-                                                  ) ER)
-        ((  B C D       J   L M N P Q R S T   X Y Z CH SH ZH ) I)
-        ((      D       J   L       Q         X              ) IA)
-        ((  B   D       J   L M N P Q     T   X              ) IAN)
-        ((              J   L   N   Q         X              ) IANG)
-        ((  B   D       J   L M N P Q     T   X              ) IAO)
-        ((  B   D       J   L M N P Q     T   X              ) IE)
-        ((  B           J   L M N P Q         X Y            ) IN)
-        ((  B   D       J   L M N P Q     T   X Y            ) ING)
-        ((              J           Q         X              ) IONG)
-        ((      D       J   L M N   Q         X              ) IU)
-        ((- B     F         L M   P         W   Y            ) O)
-        ((    C D   G H   K L   N     R S T     Y Z CH    ZH ) ONG)
-        ((-   C D F G H   K L M N P   R S T     Y Z CH SH ZH ) OU)
-        ((  B C D F G H J K L M N P Q R S T W X Y Z CH SH ZH ) U)
-        ((                  L   N                            ) V)
-        ((          G H   K           R             CH SH ZH ) UA)
-        ((          G H   K                         CH SH ZH ) UAI)
-        ((    C D   G H J K L   N   Q R S T   X Y Z CH SH ZH ) UAN)
-        ((          G H   K                         CH SH ZH ) UANG)
-        ((              J           Q         X Y            ) UE)
-        ((                  L   N                            ) VE)
-        ((    C D   G H   K           R S T       Z CH SH ZH ) UI)
-        ((    C D   G H J K L       Q R S T   X Y Z CH SH ZH ) UN)
-        ((    C D   G H   K L   N     R S T       Z CH SH ZH ) UO)
-
-        ((J Q X) (cons "a"   (cdr IA  )))
-        ((J Q X) (cons "ai"  (cdr IA  )))
-        ((J Q X) (cons "an"  (cdr IAN )))
-        ((J Q X) (cons "ang" (cdr IANG)))
-        ((J Q X) (cons "ao"  (cdr IAO )))
-        ((J Q X) (cons "e"   (cdr IE  )))
-        ((J Q X) (cons "ei"  (cdr IE  )))
-        ((J Q X) (cons "en"  (cdr IN  )))
-        ((J Q X) (cons "eng" (cdr ING )))
-        ((J Q X) (cons "ou"  (cdr IU  )))))
+       (((- B C D F G H   K L M N P     S T W   Y Z CH SH ZH ) . A)
+        ((- B C D   G H   K L M N P     S T W     Z CH SH ZH ) . AI)
+        ((- B C D F G H   K L M N P   R S T W   Y Z CH SH ZH ) . AN)
+        ((- B C D F G H   K L M N P   R S T W   Y Z CH SH ZH ) . ANG)
+        ((- B C D   G H   K L M N P   R S T     Y Z CH SH ZH ) . AO)
+        ((-   C D   G H   K L M N     R S T     Y Z CH SH ZH ) . E)
+        ((- B C D F G H   K L M N P       T W     Z    SH ZH ) . EI)
+        ((- B C D F G H   K   M N P   R S   W     Z CH SH ZH ) . EN)
+        ((- B C D F G H   K L M N P   R S T W     Z CH SH ZH ) . ENG)
+        ((-                                                  ) . ER)
+        ((  B C D       J   L M N P Q R S T   X Y Z CH SH ZH ) . I)
+        ((      D       J   L       Q         X              ) . IA)
+        ((  B   D       J   L M N P Q     T   X              ) . IAN)
+        ((              J   L   N   Q         X              ) . IANG)
+        ((  B   D       J   L M N P Q     T   X              ) . IAO)
+        ((  B   D       J   L M N P Q     T   X              ) . IE)
+        ((  B           J   L M N P Q         X Y            ) . IN)
+        ((  B   D       J   L M N P Q     T   X Y            ) . ING)
+        ((              J           Q         X              ) . IONG)
+        ((      D       J   L M N   Q         X              ) . IU)
+        ((- B     F         L M   P         W   Y            ) . O)
+        ((    C D   G H   K L   N     R S T     Y Z CH    ZH ) . ONG)
+        ((-   C D F G H   K L M N P   R S T     Y Z CH SH ZH ) . OU)
+        ((  B C D F G H J K L M N P Q R S T W X Y Z CH SH ZH ) . U)
+        ((                  L   N                            ) . V)
+        ((          G H   K           R             CH SH ZH ) . UA)
+        ((          G H   K                         CH SH ZH ) . UAI)
+        ((    C D   G H J K L   N   Q R S T   X Y Z CH SH ZH ) . UAN)
+        ((          G H   K                         CH SH ZH ) . UANG)
+        ((              J           Q         X Y            ) . UE)
+        ((                  L   N                            ) . VE)
+        ((    C D   G H   K           R S T       Z CH SH ZH ) . UI)
+        ((    C D   G H J K L       Q R S T   X Y Z CH SH ZH ) . UN)
+        ((    C D   G H   K L   N     R S T       Z CH SH ZH ) . UO)
+
+        ((J Q X) . (cons "a"   (cdr IA  )))
+        ((J Q X) . (cons "ai"  (cdr IA  )))
+        ((J Q X) . (cons "an"  (cdr IAN )))
+        ((J Q X) . (cons "ang" (cdr IANG)))
+        ((J Q X) . (cons "ao"  (cdr IAO )))
+        ((J Q X) . (cons "e"   (cdr IE  )))
+        ((J Q X) . (cons "ei"  (cdr IE  )))
+        ((J Q X) . (cons "en"  (cdr IN  )))
+        ((J Q X) . (cons "eng" (cdr ING )))
+        ((J Q X) . (cons "ou"  (cdr IU  )))))
 
        (its-define-qingsheng   "hm"    "")
        (its-define-qingsheng   "hng"   "")
 (define-its-state-machine its-pinyin-cn-map
   "pinyin-cn" "\e$AF4\e(BG" "Chinese-GB"
   "Map for Pinyin input. (Chinese-GB)"
-
-  (defconst its-quanjiao-escape "Z")
-  (defconst its-banjiao-escape  "X")
-
-  (its-defrule-select-mode-temporally "B" downcase)
-  (its-defrule-select-mode-temporally "Q" quanjiao-downcase-cn)
-
   (its-define-pinyin-table)
   (its-defoutput*      "b "    "\e$A2;\e(B")
   (its-defoutput*      "c "    "\e$A2E\e(B")
                   ("U" . "\e$A#U\e(B")  ("V" . "\e$A#V\e(B")  ("W" . "\e$A#W\e(B")  ("X" . "\e$A#X\e(B")
                   ("Y" . "\e$A#Y\e(B")  ("Z" . "\e$A#Z\e(B")))
     (let ((in (car ascii)) (out (cdr ascii)))
+      (if (and (or (string< in "a") (string< "z" in))
+              (null (equal in " "))
+              (null (equal in its-banjiao-escape))
+              (null (equal in its-quanjiao-escape)))
+         (progn
+           (its-defrule in in)
+           (its-defrule (concat (downcase its-banjiao-escape) in) in)
+           (its-defrule (concat (downcase its-quanjiao-escape) in) out)))
       (its-defrule (concat its-banjiao-escape in) in)
       (its-defrule (concat its-quanjiao-escape in) out)))
 
-  (its-defrule ","     "\e$A#,\e(B")
-  (its-defrule "."     "\e$A!#\e(B")
-  (its-defrule "/"     "\e$A!"\e(B")
-  (its-defrule ":"     "\e$A#:\e(B")
-  (its-defrule ";"     "\e$A#;\e(B")
-  (its-defrule "?"     "\e$A#?\e(B")
-  (its-defrule "!"     "\e$A#!\e(B"))
+  (its-defrule ","     "\e$A#,\e(B"      nil t)
+  (its-defrule "."     "\e$A!#\e(B"      nil t)
+  (its-defrule "/"     "\e$A!"\e(B"      nil t)
+  (its-defrule ":"     "\e$A#:\e(B"      nil t)
+  (its-defrule ";"     "\e$A#;\e(B"      nil t)
+  (its-defrule "?"     "\e$A#?\e(B"      nil t)
+  (its-defrule "!"     "\e$A#!\e(B"      nil t)
+  (its-defrule "-"     "\e$A!*\e(B"      nil t))
 
 (define-its-state-machine its-pinyin-tw-map
   "pinyin-tw" "\e$(GQ;\e(BC" "Chinese-CNS"
   "Map for Pinyin input."
-
-  (defconst its-quanjiao-escape "Z")
-  (defconst its-banjiao-escape  "X")
-
-  (its-defrule-select-mode-temporally "B" downcase)
-  (its-defrule-select-mode-temporally "Q" quanjiao-downcase-tw)
-
   (its-define-pinyin-table)
   (its-defoutput*      "b "    "\e$(GDb\e(B")
   (its-defoutput*      "c "    "\e$(GD_\e(B")
                   ("U" . "\e$(G$U\e(B")  ("V" . "\e$(G$V\e(B")  ("W" . "\e$(G$W\e(B")  ("X" . "\e$(G$X\e(B")
                   ("Y" . "\e$(G$Y\e(B")  ("Z" . "\e$(G$Z\e(B")))
     (let ((in (car ascii)) (out (cdr ascii)))
+      (if (and (or (string< in "a") (string< "z" in))
+              (null (equal in " "))
+              (null (equal in its-banjiao-escape))
+              (null (equal in its-quanjiao-escape)))
+         (progn
+           (its-defrule in in)
+           (its-defrule (concat (downcase its-banjiao-escape) in) in)
+           (its-defrule (concat (downcase its-quanjiao-escape) in) out)))
       (its-defrule (concat its-banjiao-escape in) in)
       (its-defrule (concat its-quanjiao-escape in) out)))
 
-  (its-defrule ","     "\e$(G!"\e(B")
-  (its-defrule "."     "\e$(G!$\e(B")
-  (its-defrule "/"     "\e$(G!#\e(B")
-  (its-defrule ":"     "\e$(G!(\e(B")
-  (its-defrule ";"     "\e$(G!'\e(B")
-  (its-defrule "?"     "\e$(G!)\e(B")
-  (its-defrule "!"     "\e$(G!*\e(B"))
+  (its-defrule ","     "\e$(G!"\e(B"     nil t)
+  (its-defrule "."     "\e$(G!$\e(B"     nil t)
+  (its-defrule "/"     "\e$(G!#\e(B"     nil t)
+  (its-defrule ":"     "\e$(G!(\e(B"     nil t)
+  (its-defrule ";"     "\e$(G!'\e(B"     nil t)
+  (its-defrule "?"     "\e$(G!)\e(B"     nil t)
+  (its-defrule "!"     "\e$(G!*\e(B"     nil t)
+  (its-defrule "-"     "\e$(G"1\e(B"     nil t)
+  (its-defrule "["     "\e$(G!V\e(B"     nil t)
+  (its-defrule "]"     "\e$(G!W\e(B"     nil t))
 
 (define-its-state-machine-append its-pinyin-cn-map
-  (its-defrule "[" its-pinyin-cn-open-braket)
-  (its-defrule "]" its-pinyin-cn-close-braket)
-
-  (if its-pinyin-cn-enable-quanjioao-alphabet
-      (progn
-       (its-defrule "1"  "\e$A#1\e(B")  (its-defrule "2"  "\e$A#2\e(B")
-       (its-defrule "3"  "\e$A#3\e(B")  (its-defrule "4"  "\e$A#4\e(B")
-       (its-defrule "5"  "\e$A#5\e(B")  (its-defrule "6"  "\e$A#6\e(B")
-       (its-defrule "7"  "\e$A#7\e(B")  (its-defrule "8"  "\e$A#8\e(B")
-       (its-defrule "9"  "\e$A#9\e(B")  (its-defrule "0"  "\e$A#0\e(B")
-       (its-defrule "@"  "\e$A#@\e(B")
-       (its-defrule "#"  "\e$A##\e(B")  (its-defrule "$"  "\e$A!g\e(B")
-       (its-defrule "%"  "\e$A#%\e(B")  (its-defrule "^"  "\e$A#^\e(B")
-       (its-defrule "&"  "\e$A#&\e(B")  (its-defrule "*"  "\e$A#*\e(B")
-       (its-defrule "("  "\e$A#(\e(B")  (its-defrule ")"  "\e$A#)\e(B")
-       (its-defrule "-"  "\e$A#-\e(B")  (its-defrule "~"  "\e$A!+\e(B")
-       (its-defrule "="  "\e$A#=\e(B")  (its-defrule "`"  "\e$A#`\e(B")
-       (its-defrule "\\" "\e$A#\\e(B")  (its-defrule "|"  "\e$A#|\e(B")
-       (its-defrule "_"  "\e$A#_\e(B")  (its-defrule "+"  "\e$A#+\e(B")
-       (its-defrule "{"  "\e$A#{\e(B")  (its-defrule "}"  "\e$A#}\e(B")
-       (its-defrule "\"" "\e$A#"\e(B")  (its-defrule "'"  "\e$A#'\e(B")
-       (its-defrule "<"  "\e$A#<\e(B")  (its-defrule ">"  "\e$A#>\e(B"))
-    (progn
-      (its-defrule "1"  "1")  (its-defrule "2"  "2")
-      (its-defrule "3"  "3")  (its-defrule "4"  "4")
-      (its-defrule "5"  "5")  (its-defrule "6"  "6")
-      (its-defrule "7"  "7")  (its-defrule "8"  "8")
-      (its-defrule "9"  "9")  (its-defrule "0"  "0")
-      (its-defrule "@"  "@")
-      (its-defrule "#"  "#")  (its-defrule "$"  "$")
-      (its-defrule "%"  "%")  (its-defrule "^"  "^")
-      (its-defrule "&"  "&")  (its-defrule "*"  "*")
-      (its-defrule "("  "(")  (its-defrule ")"  ")")
-      (its-defrule "-"  "-")  (its-defrule "~"  "~")
-      (its-defrule "="  "=")  (its-defrule "`"  "`")
-      (its-defrule "\\" "\\") (its-defrule "|"  "|")
-      (its-defrule "_"  "_")  (its-defrule "+"  "+")
-      (its-defrule "{"  "{")  (its-defrule "}"  "}")
-      (its-defrule "\"" "\"") (its-defrule "'"  "'")
-      (its-defrule "<"  "<")  (its-defrule ">"  ">"))))
+  (its-defrule "[" its-pinyin-cn-open-braket  nil t)
+  (its-defrule "]" its-pinyin-cn-close-braket nil t))
 
 (define-its-state-machine-append its-pinyin-tw-map
-  (its-defrule "[" its-pinyin-tw-open-braket)
-  (its-defrule "]" its-pinyin-tw-close-braket)
-
-  (if its-pinyin-tw-enable-quanjioao-alphabet
-      (progn
-       (its-defrule "1"  "\e$(G$"\e(B")  (its-defrule "2"  "\e$(G$#\e(B")
-       (its-defrule "3"  "\e$(G$$\e(B")  (its-defrule "4"  "\e$(G$%\e(B")
-       (its-defrule "5"  "\e$(G$&\e(B")  (its-defrule "6"  "\e$(G$'\e(B")
-       (its-defrule "7"  "\e$(G$(\e(B")  (its-defrule "8"  "\e$(G$)\e(B")
-       (its-defrule "9"  "\e$(G$*\e(B")  (its-defrule "0"  "\e$(G$!\e(B")
-       (its-defrule "@"  "\e$(G"i\e(B")
-       (its-defrule "#"  "\e$(G!l\e(B")  (its-defrule "$"  "\e$(G"c\e(B")
-       (its-defrule "%"  "\e$(G"h\e(B")  (its-defrule "^"  "\e$(G!T\e(B")
-       (its-defrule "&"  "\e$(G!m\e(B")  (its-defrule "*"  "\e$(G!n\e(B")
-       (its-defrule "("  "\e$(G!>\e(B")  (its-defrule ")"  "\e$(G!?\e(B")
-       (its-defrule "-"  "\e$(G"1\e(B")  (its-defrule "~"  "\e$(G"D\e(B")
-       (its-defrule "="  "\e$(G"8\e(B")  (its-defrule "`"  "\e$(G!j\e(B")
-       (its-defrule "\\" "\e$(G"b\e(B")  (its-defrule "|"  "\e$(G"^\e(B")
-       (its-defrule "_"  "\e$(G"%\e(B")  (its-defrule "+"  "\e$(G"0\e(B")
-       (its-defrule "{"  "\e$A#{\e(B")  (its-defrule "}"  "\e$(G!a\e(B")
-       (its-defrule "\"" "\e$(G!i\e(B")  (its-defrule "'"  "\e$(G!k\e(B")
-       (its-defrule "<"  "\e$(G"6\e(B")  (its-defrule ">"  "\e$(G"7\e(B"))
-    (progn
-      (its-defrule "1"  "1")  (its-defrule "2"  "2")
-      (its-defrule "3"  "3")  (its-defrule "4"  "4")
-      (its-defrule "5"  "5")  (its-defrule "6"  "6")
-      (its-defrule "7"  "7")  (its-defrule "8"  "8")
-      (its-defrule "9"  "9")  (its-defrule "0"  "0")
-      (its-defrule "@"  "@")
-      (its-defrule "#"  "#")  (its-defrule "$"  "$")
-      (its-defrule "%"  "%")  (its-defrule "^"  "^")
-      (its-defrule "&"  "&")  (its-defrule "*"  "*")
-      (its-defrule "("  "(")  (its-defrule ")"  ")")
-      (its-defrule "-"  "-")  (its-defrule "~"  "~")
-      (its-defrule "="  "=")  (its-defrule "`"  "`")
-      (its-defrule "\\" "\\") (its-defrule "|"  "|")
-      (its-defrule "_"  "_")  (its-defrule "+"  "+")
-      (its-defrule "{"  "{")  (its-defrule "}"  "}")
-      (its-defrule "\"" "\"") (its-defrule "'"  "'")
-      (its-defrule "<"  "<")  (its-defrule ">"  ">"))))
+  (its-defrule "[" its-pinyin-tw-open-braket  nil t)
+  (its-defrule "]" its-pinyin-tw-close-braket nil t))
 
 (provide 'its/pinyin)
index 215b9a0..8eae19b 100644 (file)
@@ -5,37 +5,37 @@
 
 (register-input-method
  "japanese-egg-wnn" "Japanese" 'egg-activate-wnn
- ""  "Romaji -> Hiragana -> Kanji&Kana"
- 'its-select-hiragana)
+ 'egg-mode-line-title  "Romaji -> Hiragana -> Kanji&Kana"
+ 'its-select-hiragana "Japanese")
 
 (register-input-method
  "japanese-egg-sj3" "Japanese" 'egg-activate-sj3
- ""  "Romaji -> Hiragana -> Kanji&Kana"
- 'its-select-hiragana)
+ 'egg-mode-line-title  "Romaji -> Hiragana -> Kanji&Kana"
+ 'its-select-hiragana "Japanese")
 
 (register-input-method
  "chinese-gb-egg-wnn-py" "Chinese-GB" 'egg-activate-wnn
- ""  "Pinyin -> Simplified Hanzi"
- 'its-select-pinyin-cn)
+ 'egg-mode-line-title  "Pinyin -> Simplified Hanzi"
+ 'its-select-pinyin-cn "Chinese-GB")
 
 (register-input-method
  "chinese-gb-egg-wnn-zy" "Chinese-GB" 'egg-activate-wnn
- ""  "Zhunyin -> Simplified Hanzi"
- 'its-select-zhuyin-cn)
+ 'egg-mode-line-title  "Zhunyin -> Simplified Hanzi"
+ 'its-select-zhuyin-cn "Chinese-GB")
 
 (register-input-method
  "chinese-cns-egg-wnn-py" "Chinese-CNS" 'egg-activate-wnn
- ""  "Pinyin -> Traditional Hanzi"
- 'its-select-pinyin-tw)
+ 'egg-mode-line-title  "Pinyin -> Traditional Hanzi"
+ 'its-select-pinyin-tw "Chinese-CNS")
 
 (register-input-method
  "chinese-cns-egg-wnn-zy" "Chinese-CNS" 'egg-activate-wnn
- ""  "Zhunyin -> Traditional Hanzi"
- 'its-select-zhuyin-tw)
+ 'egg-mode-line-title  "Zhunyin -> Traditional Hanzi"
+ 'its-select-zhuyin-tw "Chinese-CNS")
 
 (register-input-method
  "korean-egg-wnn" "Korean" 'egg-activate-wnn
- ""  "Hangul -> Hanja"
- 'its-select-hangul)
+ 'egg-mode-line-title  "Hangul -> Hanja"
+ 'its-select-hangul "Korean")
 
 (autoload 'egg-mode "egg" "Toggle EGG  mode." t)