(ideo-trans-select-char): New function.
authortomo <tomo>
Tue, 24 Aug 2004 13:35:43 +0000 (13:35 +0000)
committertomo <tomo>
Tue, 24 Aug 2004 13:35:43 +0000 (13:35 +0000)
(ideo-translate-chinese-string-into-traditional): New function.
(ideo-translate-japanese-string-into-traditional): New function.
(ideo-translate-string-into-traditional): Deleted.
(ideo-translate-japanese-region-into-traditional): Renamed from
`ideo-translate-region-into-traditional'; use
`ideo-trans-select-char'.
(ideo-translate-region-into-traditional): New obsolete alias for
`ideo-translate-japanese-region-into-traditional'.

ideo-trans.el

index d0b84d0..ec8de15 100644 (file)
 ;;;###autoload
 (defun char-representative-of-ucs (char)
   "Convert CHAR into representative character of UCS."
-  (if (setq ret (char-ucs char))
-      (decode-char '=ucs ret)
-    char))
+  (let (ret)
+    (if (setq ret (char-ucs char))
+       (decode-char '=ucs ret)
+      char)))
 
 ;;;###autoload
 (defun char-representative-of-domain (char domain)
 ;;;###autoload
 (defun ideo-translate-string-into-simplified-japanese (string)
   "Simplify traditional Kanji characters in STRING."
-  (let (uchr ret)
+  (let (ret)
     (mapconcat
      (lambda (chr)
        (setq ret (or (char-feature chr '->simplified@JP/Jouyou)
              (t chr))))
      string "")))
 
+(defun ideo-trans-select-char (chars &optional prefix)
+  (let ((i 0)
+       prompt ret)
+    (setq prompt
+         (concat
+          prefix
+          (mapconcat (lambda (cell)
+                       (setq i (1+ i))
+                       (format "%d. %c" i cell))
+                     chars " ")
+          " : "))
+    (while (and (setq ret (string-to-int (read-string prompt)))
+               (not (and (< 0 ret)
+                         (<=  ret (length chars))))))
+    (nth (1- ret) chars)))
+
 ;;;###autoload
-(defun ideo-translate-string-into-traditional (string)
-  "Convert simplified Kanji in STRING into traditional characters."
-  (let (uchr ret)
+(defun ideo-translate-chinese-string-into-traditional (string)
+  "Convert simplified Chinese characters in STRING to traditional characters."
+  (let (ret)
     (mapconcat
      (lambda (chr)
        (char-to-string
-       (cond ((car (char-feature chr '<-simplified)))
-             ((progn
-                (setq ret
-                      (cond ((setq ret (char-feature chr '=>ucs@jis))
-                             (decode-char '=ucs@jis ret))
-                            ((setq ret (char-ucs chr))
-                             (decode-char '=ucs@jp ret))
-                            (t chr)))
-                (setq ret (or (char-feature ret '<-simplified@JP/Jouyou)
-                              (char-feature ret '<-simplified@JP))))
-              (car ret))
+       (cond ((car (char-feature chr '<-simplified))
+              (if (cdr ret)
+                  (ideo-trans-select-char ret (format "%c => " chr))
+                (car ret)))
              ((progn
                 (setq ret
                       (cond ((setq ret (char-feature chr '=>ucs@gb))
                 (if (setq ret (encode-char ret 'chinese-gb2312))
                     (setq ret (decode-char 'chinese-gb12345 ret))))
               ret)
+             (t chr))))
+     string "")))
+
+;;;###autoload
+(defun ideo-translate-japanese-string-into-traditional (string)
+  "Convert simplified Kanji in STRING into traditional characters."
+  (let (ret)
+    (mapconcat
+     (lambda (chr)
+       (char-to-string
+       (cond ((setq ret (char-feature chr '<-simplified))
+              (if (cdr ret)
+                  (ideo-trans-select-char ret (format "%c => " chr))
+                (car ret)))
+             ((progn
+                (setq ret
+                      (cond ((setq ret (char-feature chr '=>ucs@jis))
+                             (decode-char '=ucs@jis ret))
+                            ((setq ret (char-ucs chr))
+                             (decode-char '=ucs@jp ret))
+                            (t chr)))
+                (setq ret (or (char-feature ret '<-simplified@JP/Jouyou)
+                              (char-feature ret '<-simplified@JP))))
+              (if (cdr ret)
+                  (ideo-trans-select-char ret (format "%c => " chr))
+                (car ret)))
              ((setq ret (char-feature chr '=>ucs@jis))
               (decode-char '=ucs@jis ret))
              ((setq ret (char-ucs chr))
               (decode-char '=ucs@jp ret))
              (t chr))))
      string "")))
-
+                     
 ;;;###autoload
-(defun ideo-translate-region-into-traditional (start end)
+(defun ideo-translate-japanese-region-into-traditional (start end)
   (interactive "r")
   (save-excursion
     (save-restriction
       (narrow-to-region start end)
       (goto-char start)
-      (let (chr ret rret i prompt)
+      (let (chr ret rret)
        (while (and (skip-chars-forward "\x00-\xFF")
                    (not (eobp)))
          (setq chr (char-after))
              (progn
                (if (cdr ret)
                    (progn
-                     (setq i 0)
-                     (setq prompt
-                           (concat
-                            (mapconcat (lambda (cell)
-                                         (setq i (1+ i))
-                                         (format "%d. %c" i cell))
-                                       ret " ")
-                            " : "))
-                     (while (and (setq rret
-                                       (string-to-int
-                                        (read-string prompt)))
-                                 (not (and (< 0 rret)
-                                           (<=  rret (length ret))))))
+                     (setq rret (ideo-trans-select-char ret))
                      (delete-char)
-                     (insert (nth (1- rret) ret)))
+                     (insert rret))
                  (delete-char)
                  (insert (car ret))))
            (or (eobp)
                (forward-char))))))))
 
+;;;###autoload
+(define-obsolete-function-alias
+  'ideo-translate-region-into-traditional
+  'ideo-translate-japanese-region-into-traditional)
+
 
 ;;; @ End.
 ;;;