From: tomo Date: Fri, 4 Sep 2009 18:55:14 +0000 (+0000) Subject: (chinese-simplify-string): Use `char-feature' instead of X-Git-Tag: chise-base-0_25~5 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0bd078a73eec3dc3ba5035664a769101ee6528d3;p=chise%2Ftomoyo-tools.git (chinese-simplify-string): Use `char-feature' instead of `get-char-attribute' to retrieve `=>ucs*'; fix typo. (japanese-simplify-string): Support non-JIS variants. (chinese-traditionalize-string): Add new optional argument `selector'; (japanese-traditionalize-string): Likewise. --- diff --git a/ideo-trans.el b/ideo-trans.el index 882319d..3e9689a 100644 --- a/ideo-trans.el +++ b/ideo-trans.el @@ -97,8 +97,8 @@ (setq chr (decode-char '=ucs@gb ret))) ((setq ret (char-ucs chr)) (setq chr (decode-char '=ucs@gb ret)) - (if (setq ret (get-char-attribute chr '=>ucs*)) - (decode-char '=ucs@gb ret) + (if (setq ret (char-feature chr '=>ucs*)) + (setq chr (decode-char '=ucs@gb ret)) chr)) (t chr))) (char-to-string @@ -122,6 +122,15 @@ (let (ret) (mapconcat (lambda (chr) + (setq uchr + (cond ((setq ret (char-feature chr '=>ucs@jis)) + (setq chr (decode-char '=ucs@jis ret))) + ((setq ret (char-ucs chr)) + (setq chr (decode-char '=ucs@jis ret)) + (if (setq ret (char-feature chr '=>ucs*)) + (setq chr (decode-char '=ucs@jis ret)) + chr)) + (t chr))) (setq ret (or (char-feature chr '->simplified@JP/Jouyou) (char-feature chr '->simplified@JP) (char-feature chr '->simplified))) @@ -157,15 +166,19 @@ (nth (1- ret) chars))) ;;;###autoload -(defun chinese-traditionalize-string (string) +(defun chinese-traditionalize-string (string &optional selector) "Convert simplified Chinese characters in STRING to traditional characters." + (unless selector + (setq selector + (lambda (chars) + (ideo-trans-select-char chars (format "%c => " chr))))) (let (ret) (mapconcat (lambda (chr) (char-to-string (cond ((car (char-feature chr '<-simplified)) (if (cdr ret) - (ideo-trans-select-char ret (format "%c => " chr)) + (funcall selector ret) (car ret))) ((progn (setq ret @@ -186,8 +199,12 @@ 'chinese-traditionalize-string) ;;;###autoload -(defun japanese-traditionalize-string (string) +(defun japanese-traditionalize-string (string &optional selector) "Convert simplified Kanji in STRING into traditional characters." + (unless selector + (setq selector + (lambda (chars) + (ideo-trans-select-char chars (format "%c => " chr))))) (let (ret) (mapconcat (lambda (chr) @@ -196,7 +213,7 @@ (char-feature chr '<-simplified@JP) (char-feature chr '<-simplified))) (if (cdr ret) - (ideo-trans-select-char ret (format "%c => " chr)) + (funcall selector ret) (car ret))) ((progn (setq ret