From: morioka Date: Fri, 20 Feb 1998 10:22:37 +0000 (+0000) Subject: egg-980220. X-Git-Tag: egg-980220~2 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=03c39fadd173acf1f5527acbf17d3938a7a40e94;p=elisp%2Fegg.git egg-980220. --- diff --git a/ChangeLog b/ChangeLog index e27efae..9989248 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,29 @@ +1998-02-20 KATAYAMA Yoshio + + * its.el (its-restart): New function. + (its-insert-fence-open, its-insert-fence-close): New function. + (its-start): Rewritten. Use its-insert-fence-open and + its-insert-fence-close. + (its-exit-mode-internal): Leave its-syl property. + (its-exit-mode-internal): Delete the property in this case. + (its-keydef): Require it. + + * its-keydef.el: Provide the feature. + + * egg-cnv.el (egg-convert-region): Add egg-source property to save + the source string. + (egg-conversion-map, \C-c): New keybind. + (egg-get-previous-bunsetsu): Bug fix. + (egg-decide-before-point): New implementation. + (egg-exit-conversion): Use gg-decide-before-point. + (egg-abort-conversion): New command. + +1998-02-20 NIIBE Yutaka + + * Makefile (SRCS), Egg.prj: Remove euc-china.el. + * egg-com.el: Include egg-china.el. + * egg-china.el: Removed. + 1998-02-18 NIIBE Yutaka * Egg.prj: Use PRCS. diff --git a/Makefile b/Makefile index 6afbd93..3215a4b 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,6 @@ SRCS = menudiag.el its.el egg.el \ its/hangul.el \ its-keydef.el \ egg-mlh.el egg-cnv.el egg-com.el \ - euc-china.el \ egg/sj3.el egg/sj3rpc.el \ egg/wnn.el egg/wnnrpc.el diff --git a/egg-cnv.el b/egg-cnv.el index 76a748b..8c499b3 100644 --- a/egg-cnv.el +++ b/egg-cnv.el @@ -117,7 +117,11 @@ (narrow-to-region start end) (goto-char start) (insert egg-conversion-open) - (put-text-property start (point) 'egg-start t) + (add-text-properties start (point) + (list + 'egg-start t + 'egg-source (buffer-substring (point) + (point-max)))) (if egg-conversion-face (put-text-property start (point) 'invisible t)) (setq start (point)) @@ -229,6 +233,7 @@ (define-key map [?\C-\ ] 'egg-decide-first-char) (define-key map "\C-a" 'egg-beginning-of-conversion-buffer) (define-key map "\C-b" 'egg-backward-bunsetsu) + (define-key map "\C-c" 'egg-abort-conversion) (define-key map "\C-e" 'egg-end-of-conversion-buffer) (define-key map "\C-f" 'egg-forward-bunsetsu) (define-key map "\C-h" 'egg-help-command) @@ -299,9 +304,9 @@ (signal 'end-of-buffer nil)))) (defun egg-get-previous-bunsetsu (p) - (if (get-text-property (1- p) 'egg-start) - nil - (egg-get-bunsetsu-info (- p 2)))) + (and (null (get-text-property (1- p) 'egg-start)) + (null (get-text-property (1- p) 'egg-bunsetsu-last)) + (egg-get-bunsetsu-info (- p 2)))) (defun egg-separate-characters (str) (let* ((v (string-to-vector str)) @@ -391,6 +396,7 @@ (interactive "p") (egg-next-candidate (- n))) +;; Bogus function 980220 (defun egg-decide-bunsetsu (&optional end-marker) (let ((in-loop t) p bunsetsu-info-list bl) @@ -415,41 +421,59 @@ (defun egg-decide-before-point () (interactive) - (let ((m (make-marker)) - all start bunsetsu-list) - (if (get-text-property (1- (point)) 'egg-start) - (signal 'beginning-of-buffer nil) - (setq start (1- (previous-single-property-change (point) 'egg-start)))) - (set-marker m (point)) - (goto-char start) - ;; Delete open marker - (delete-region start (1+ start)) - (setq bunsetsu-list (egg-decide-bunsetsu m)) - ;; delete separator - (delete-region (1- (point)) (point)) - ;; insert open marker - (insert egg-conversion-open) - (put-text-property m (point) 'egg-start t) - (if egg-conversion-face - (put-text-property p (point) 'invisible t)) - (egg-end-conversion bunsetsu-list) - (set-marker m nil))) + (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 (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 (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) + (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) (1+ (point))) + (egg-do-auto-fill) + (run-hooks 'input-method-after-insert-chunk-hook)) + ;; 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) - (let (start bunsetsu-list) - (if (get-text-property (1- (point)) 'egg-start) - (setq start (1- (point))) - (setq start (1- (previous-single-property-change (point) 'egg-start)))) - (goto-char start) - ;; Delete open marker - (delete-region start (1+ start)) - (setq bunsetsu-list (egg-decide-bunsetsu)) - ;; Delete close marker - (delete-region (point) (1+ (point))) - (egg-do-auto-fill) - (egg-end-conversion bunsetsu-list) - (run-hooks 'input-method-after-insert-chunk-hook))) + (goto-char (next-single-property-change (point) 'egg-end)) + (egg-decide-before-point)) + +(defun egg-abort-conversion () + (interactive) + (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) diff --git a/egg-com.el b/egg-com.el index cf5b401..a15ba79 100644 --- a/egg-com.el +++ b/egg-com.el @@ -100,6 +100,8 @@ (make-coding-system 'fixed-euc-jp 4 ?W "Coding System for fixed EUC Japanese" (cons ccl-decode-fixed-euc-jp ccl-encode-fixed-euc)) +;; Korean + (eval-and-compile (define-ccl-program ccl-decode-fixed-euc-kr `(2 @@ -135,6 +137,458 @@ (make-coding-system 'fixed-euc-kr 4 ?W "Coding System for fixed EUC Korean" (cons ccl-decode-fixed-euc-kr ccl-encode-fixed-euc-kr)) + +;; Chinese +(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 + '(("š À" 0 0) ("š À" 0 1) ("š À" 0 3) ("š À" 0 5) ("š À" 0 7) + ("aš À" 1 0) ("š ¡š À" 1 1) ("š ¢š À" 1 3) ("š £š À" 1 5) ("š ¤š À" 1 7) + ("aiš À" 2 0) ("š ¡iš À" 2 1) ("š ¢iš À" 2 3) ("š £iš À" 2 5) ("š ¤iš À" 2 7) + ("anš À" 3 0) ("š ¡nš À" 3 1) ("š ¢nš À" 3 3) ("š £nš À" 3 5) ("š ¤nš À" 3 7) + ("angš À" 4 0) ("š ¡ngš À" 4 1) ("š ¢ngš À" 4 3) ("š £ngš À" 4 5) ("š ¤ngš À" 4 7) + ("aoš À" 5 0) ("š ¡oš À" 5 1) ("š ¢oš À" 5 3) ("š £oš À" 5 5) ("š ¤oš À" 5 7) + ("eš À" 6 0) ("š ¥š À" 6 1) ("š ¦š À" 6 3) ("š §š À" 6 5) ("š ¨š À" 6 7) + ("eiš À" 7 0) ("š ¥iš À" 7 1) ("š ¦iš À" 7 3) ("š §iš À" 7 5) ("š ¨iš À" 7 7) + ("enš À" 8 0) ("š ¥nš À" 8 1) ("š ¦nš À" 8 3) ("š §nš À" 8 5) ("š ¨nš À" 8 7) + ("engš À" 9 0) ("š ¥ngš À" 9 1) ("š ¦ngš À" 9 3) ("š §ngš À" 9 5) ("š ¨ngš À" 9 7) + ("erš À" 10 0) ("š ¥rš À" 10 1) ("š ¦rš À" 10 3) ("š §rš À" 10 5) ("š ¨rš À" 10 7) + ("iš À" 11 0) ("š ©š À" 11 1) ("š ªš À" 11 3) ("š «š À" 11 5) ("š ¬š À" 11 7) + ("iaš À" 12 0) ("iš ¡š À" 12 1) ("iš ¢š À" 12 3) ("iš £š À" 12 5) ("iš ¤š À" 12 7) + ("ianš À" 13 0) ("iš ¡nš À" 13 1) ("iš ¢nš À" 13 3) ("iš £nš À" 13 5) ("iš ¤nš À" 13 7) + ("iangš À" 14 0) ("iš ¡ngš À" 14 1) ("iš ¢ngš À" 14 3) ("iš £ngš À" 14 5) ("iš ¤ngš À" 14 7) + ("iaoš À" 15 0) ("iš ¡oš À" 15 1) ("iš ¢oš À" 15 3) ("iš £oš À" 15 5) ("iš ¤oš À" 15 7) + ("ieš À" 16 0) ("iš ¥š À" 16 1) ("iš ¦š À" 16 3) ("iš §š À" 16 5) ("iš ¨š À" 16 7) + ("inš À" 17 0) ("š ©nš À" 17 1) ("š ªnš À" 17 3) ("š «nš À" 17 5) ("š ¬nš À" 17 7) + ("ingš À" 18 0) ("š ©ngš À" 18 1) ("š ªngš À" 18 3) ("š «ngš À" 18 5) ("š ¬ngš À" 18 7) + ("iongš À" 19 0) ("iš ­ngš À" 19 1) ("iš ®ngš À" 19 3) ("iš ¯ngš À" 19 5) ("iš °ngš À" 19 7) + ("iuš À" 20 0) ("iš ±š À" 20 1) ("iš ²š À" 20 3) ("iš ³š À" 20 5) ("iš ´š À" 20 7) + ("mš À" 21 0) ("mš À" 21 1) ("mš À" 21 3) ("mš À" 21 5) ("mš À" 21 7) + ("nš À" 22 0) ("nš À" 22 1) ("š ½š À" 22 3) ("š ¾š À" 22 5) ("š ¿š À" 22 7) + ("ngš À" 23 0) ("ngš À" 23 1) ("ngš À" 23 3) ("ngš À" 23 5) ("ngš À" 23 7) + ("oš À" 24 0) ("š ­š À" 24 1) ("š ®š À" 24 3) ("š ¯š À" 24 5) ("š °š À" 24 7) + ("ongš À" 25 0) ("š ­ngš À" 25 1) ("š ®ngš À" 25 3) ("š ¯ngš À" 25 5) ("š °ngš À" 25 7) + ("ouš À" 26 0) ("š ­uš À" 26 1) ("š ®uš À" 26 3) ("š ¯uš À" 26 5) ("š °uš À" 26 7) + ("uš À" 27 0) ("š ±š À" 27 1) ("š ²š À" 27 3) ("š ³š À" 27 5) ("š ´š À" 27 7) + ("uaš À" 28 0) ("uš ¡š À" 28 1) ("uš ¢š À" 28 3) ("uš £š À" 28 5) ("uš ¤š À" 28 7) + ("uaiš À" 29 0) ("uš ¡iš À" 29 1) ("uš ¢iš À" 29 3) ("uš £iš À" 29 5) ("uš ¤iš À" 29 7) + ("uanš À" 30 0) ("uš ¡nš À" 30 1) ("uš ¢nš À" 30 3) ("uš £nš À" 30 5) ("uš ¤nš À" 30 7) + ("uangš À" 31 0) ("uš ¡ngš À" 31 1) ("uš ¢ngš À" 31 3) ("uš £ngš À" 31 5) ("uš ¤ngš À" 31 7) + ("ueš À" 32 0) ("uš ¥š À" 32 1) ("uš ¦š À" 32 3) ("uš §š À" 32 5) ("uš ¨š À" 32 7) + ("uiš À" 33 0) ("uš ©š À" 33 1) ("uš ªš À" 33 3) ("uš «š À" 33 5) ("uš ¬š À" 33 7) + ("unš À" 34 0) ("š ±nš À" 34 1) ("š ²nš À" 34 3) ("š ³nš À" 34 5) ("š ´nš À" 34 7) + ("uoš À" 35 0) ("uš ­š À" 35 1) ("uš ®š À" 35 3) ("uš ¯š À" 35 5) ("uš °š À" 35 7) + ("š ¹š À" 36 0) ("š µš À" 36 1) ("š ¶š À" 36 3) ("š ·š À" 36 5) ("š ¸š À" 36 7) + ("š ¹eš À" 37 0) ("š ¹š ¥š À" 37 1) ("š ¹š ¦š À" 37 3) ("š ¹š §š À" 37 5) ("š ¹š ¨š À" 37 7) + ("0š À" 38 0) ("1š À" 38 1) ("2š À" 38 3) ("3š À" 38 5) ("4š À" 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) ("š Å" . 1) ("š Ø" . 2) ("š Ô" . 3) ("š É" . 4) + ("š È" . 5) ("š Í" . 6) ("š Ï" . 7) ("š Ð" . 8) ("š Î" . 9) + ("š Ì" . 10) ("š Ç" . 11) ("š Ë" . 12) ("š Æ" . 13) ("š Ñ" . 14) + ("š Ö" . 15) ("š Ù" . 16) ("š Õ" . 17) ("š Ê" . 18) ("š è" . 19) + ("š Ò" . 20) ("š ç" . 21) ("š ×" . 22) ("š Ó" . 23))) + +(defconst yincode-zhuyin-yunmu + '(("š À" 0 0) ("š Á" 0 1) ("š Â" 0 3) ("š Ã" 0 5) ("š Ä" 0 7) ; i + ("š Úš À" 1 0) ("š Úš Á" 1 1) ("š Úš Â" 1 3) ("š Úš Ã" 1 5) ("š Úš Ä" 1 7) ; a + ("š Þš À" 2 0) ("š Þš Á" 2 1) ("š Þš Â" 2 3) ("š Þš Ã" 2 5) ("š Þš Ä" 2 7) ; ai + ("š âš À" 3 0) ("š âš Á" 3 1) ("š âš Â" 3 3) ("š âš Ã" 3 5) ("š âš Ä" 3 7) ; an + ("š äš À" 4 0) ("š äš Á" 4 1) ("š äš Â" 4 3) ("š äš Ã" 4 5) ("š äš Ä" 4 7) ; ang + ("š àš À" 5 0) ("š àš Á" 5 1) ("š àš Â" 5 3) ("š àš Ã" 5 5) ("š àš Ä" 5 7) ; ao + ("š Üš À" 6 0) ("š Üš Á" 6 1) ("š Üš Â" 6 3) ("š Üš Ã" 6 5) ("š Üš Ä" 6 7) ; e + ("š ßš À" 7 0) ("š ßš Á" 7 1) ("š ßš Â" 7 3) ("š ßš Ã" 7 5) ("š ßš Ä" 7 7) ; ei + ("š ãš À" 8 0) ("š ãš Á" 8 1) ("š ãš Â" 8 3) ("š ãš Ã" 8 5) ("š ãš Ä" 8 7) ; en + ("š åš À" 9 0) ("š åš Á" 9 1) ("š åš Â" 9 3) ("š åš Ã" 9 5) ("š åš Ä" 9 7) ; eng + ("š æš À" 10 0) ("š æš Á" 10 1) ("š æš Â" 10 3) ("š æš Ã" 10 5) ("š æš Ä" 10 7) ; er + ("š çš À" 11 0) ("š çš Á" 11 1) ("š çš Â" 11 3) ("š çš Ã" 11 5) ("š çš Ä" 11 7) ; i + ("š çš Úš À" 12 0) ("š çš Úš Á" 12 1) ("š çš Úš Â" 12 3) ("š çš Úš Ã" 12 5) ("š çš Úš Ä" 12 7) ; ia + ("š çš âš À" 13 0) ("š çš âš Á" 13 1) ("š çš âš Â" 13 3) ("š çš âš Ã" 13 5) ("š çš âš Ä" 13 7) ; ian + ("š çš äš À" 14 0) ("š çš äš Á" 14 1) ("š çš äš Â" 14 3) ("š çš äš Ã" 14 5) ("š çš äš Ä" 14 7) ; iang + ("š çš àš À" 15 0) ("š çš àš Á" 15 1) ("š çš àš Â" 15 3) ("š çš àš Ã" 15 5) ("š çš àš Ä" 15 7) ; iao + ("š çš Ýš À" 16 0) ("š çš Ýš Á" 16 1) ("š çš Ýš Â" 16 3) ("š çš Ýš Ã" 16 5) ("š çš Ýš Ä" 16 7) ; ie + ("š çš ãš À" 17 0) ("š çš ãš Á" 17 1) ("š çš ãš Â" 17 3) ("š çš ãš Ã" 17 5) ("š çš ãš Ä" 17 7) ; in + ("š çš åš À" 18 0) ("š çš åš Á" 18 1) ("š çš åš Â" 18 3) ("š çš åš Ã" 18 5) ("š çš åš Ä" 18 7) ; ing + ("š éš åš À" 19 0) ("š éš åš Á" 19 1) ("š éš åš Â" 19 3) ("š éš åš Ã" 19 5) ("š éš åš Ä" 19 7) ; iong + ("š çš áš À" 20 0) ("š çš áš Á" 20 1) ("š çš áš Â" 20 3) ("š çš áš Ã" 20 5) ("š çš áš Ä" 20 7) ; iu + ("š Çš À" 21 0) ("š Çš Á" 21 1) ("š Çš Â" 21 3) ("š Çš Ã" 21 5) ("š Çš Ä" 21 7) ; m + ("š Ëš À" 22 0) ("š Ëš Á" 22 1) ("š Ëš Â" 22 3) ("š Ëš Ã" 22 5) ("š Ëš Ä" 22 7) ; n + ("@š À" 23 0) ("@š Á" 23 1) ("@š Â" 23 3) ("@š Ã" 23 5) ("@š Ä" 23 7) ; ng + ("š Ûš À" 24 0) ("š Ûš Á" 24 1) ("š Ûš Â" 24 3) ("š Ûš Ã" 24 5) ("š Ûš Ä" 24 7) ; o + ("š èš åš À" 25 0) ("š èš åš Á" 25 1) ("š èš åš Â" 25 3) ("š èš åš Ã" 25 5) ("š èš åš Ä" 25 7) ; ong + ("š áš À" 26 0) ("š áš Á" 26 1) ("š áš Â" 26 3) ("š áš Ã" 26 5) ("š áš Ä" 26 7) ; ou + ("š èš À" 27 0) ("š èš Á" 27 1) ("š èš Â" 27 3) ("š èš Ã" 27 5) ("š èš Ä" 27 7) ; u + ("š èš Úš À" 28 0) ("š èš Úš Á" 28 1) ("š èš Úš Â" 28 3) ("š èš Úš Ã" 28 5) ("š èš Úš Ä" 28 7) ; ua + ("š èš Þš À" 29 0) ("š èš Þš Á" 29 1) ("š èš Þš Â" 29 3) ("š èš Þš Ã" 29 5) ("š èš Þš Ä" 29 7) ; uai + ("š èš âš À" 30 0) ("š èš âš Á" 30 1) ("š èš âš Â" 30 3) ("š èš âš Ã" 30 5) ("š èš âš Ä" 30 7) ; uan + ("š èš äš À" 31 0) ("š èš äš Á" 31 1) ("š èš äš Â" 31 3) ("š èš äš Ã" 31 5) ("š èš äš Ä" 31 7) ; uang + ("š éš Ýš À" 37 0) ("š éš Ýš Á" 37 1) ("š éš Ýš Â" 37 3) ("š éš Ýš Ã" 37 5) ("š éš Ýš Ä" 37 7) ; ue + ("š èš ßš À" 33 0) ("š èš ßš Á" 33 1) ("š èš ßš Â" 33 3) ("š èš ßš Ã" 33 5) ("š èš ßš Ä" 33 7) ; ui + ("š èš ãš À" 34 0) ("š èš ãš Á" 34 1) ("š èš ãš Â" 34 3) ("š èš ãš Ã" 34 5) ("š èš ãš Ä" 34 7) ; un + ("š èš Ûš À" 35 0) ("š èš Ûš Á" 35 1) ("š èš Ûš Â" 35 3) ("š èš Ûš Ã" 35 5) ("š èš Ûš Ä" 35 7) ; uo + ("š éš À" 36 0) ("š éš Á" 36 1) ("š éš Â" 36 3) ("š éš Ã" 36 5) ("š éš Ä" 36 7) ; š ¹ + ("š éš Ýš À" 37 0) ("š éš Ýš Á" 37 1) ("š éš Ýš Â" 37 3) ("š éš Ýš Ã" 37 5) ("š éš Ýš Ä" 37 7) ; š ¹e + ("0š À" 38 0) ("1š Á" 38 1) ("2š Â" 38 3) ("3š Ã" 38 5) ("4š Ä" 38 7) ; undefined + ("š éš âš À" 39 0) ("š éš âš Á" 39 1) ("š éš âš Â" 39 3) ("š éš âš Ã" 39 5) ("š éš âš Ä" 39 7) ; š ¹an + ("š éš ãš À" 40 0) ("š éš ãš Á" 40 1) ("š éš ãš Â" 40 3) ("š éš ãš Ã" 40 5) ("š éš ãš Ä" 40 7) ; š ¹n + )) + +(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š ¡-š ¿]+š À" 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 "^[š Å-š é@0-4]+[š Àš Áš Âš Ãš Ä]" 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š ¡ngš À") (length "š Óš èš äš Á")))) + (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) (defsubst comm-format-u32c (uint32c) (let ((h0 (car uint32c)) diff --git a/its-keydef.el b/its-keydef.el index 90b77f1..d295424 100644 --- a/its-keydef.el +++ b/its-keydef.el @@ -58,3 +58,5 @@ ("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 26aeb04..56bab98 100644 --- a/its.el +++ b/its.el @@ -222,28 +222,38 @@ ;; intangible intangible ;; 1 2 ;; -(defun its-start (key) - (let (p cursor) - (setq p (point)) +(defun its-insert-fence-open () + (let ((p (point))) (insert its-fence-open) - (add-text-properties p (point) - (let ((props '(its-start t intangible its-part-1))) - (if its-fence-face - (append '(invisible t) props) - props))) - (setq p (point)) - (setq cursor (its-input nil key)) - (its-put-cursor cursor) - (forward-char 1) - (setq p (point)) + (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) - (let ((props '(its-end t intangible its-part-2))) - (if its-fence-face - (append '(invisible t) props) - props))) - (forward-char -2) - (force-mode-line-update))) + (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) + (its-insert-fence-open) + (its-insert-fence-close) + (its-put-cursor (its-input nil key)) + (force-mode-line-update)) + +(defun its-restart (str) + (let (p) + (its-insert-fence-open) + (its-insert-fence-close) + (setq p (point)) + (insert str) + (put-text-property p (point) 'intangible 'its-part-2) + (goto-char p) + (its-put-cursor t))) (defun its-self-insert-char () (interactive) @@ -688,13 +698,12 @@ Return last state." (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-syl nil - its-map nil + (remove-text-properties start end '(its-map nil face nil intangible nil)) (if proceed-to-conversion (egg-convert-region start end) - (remove-text-properties start end '(its-lang nil)) + (remove-text-properties start end '(its-lang nil its-syl nil)) (egg-do-auto-fill) (run-hooks 'input-method-after-insert-chunk-hook)))) @@ -739,7 +748,7 @@ Return last state." (delete-region start end) (apply 'insert (reverse its-translation-result)))) -(load "its-keydef.el") +(require 'its-keydef) (provide 'its) ;;; its.el ends here.