From d0c81d521e6c5efa6bc852816c56b4820f7bd1c9 Mon Sep 17 00:00:00 2001 From: tomo Date: Wed, 5 Nov 2003 15:19:34 +0000 Subject: [PATCH] (ideo-translate-region-into-traditional): New command. --- ideo-trans.el | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/ideo-trans.el b/ideo-trans.el index 4f50ce8..5055791 100644 --- a/ideo-trans.el +++ b/ideo-trans.el @@ -45,6 +45,43 @@ (define-obsolete-function-alias 'ideo-trans-simplify-chinese-string 'ideo-translate-string-into-simplified-chinese) +;;;###autoload +(defun ideo-translate-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) + (while (and (skip-chars-forward "\x00-\xFF") + (not (eobp))) + (setq chr (char-after)) + (if (setq ret (or (get-char-attribute chr '<-simplified@jp-jouyou) + (get-char-attribute chr '<-simplified@jp) + (get-char-attribute chr '<-jp-simplified))) + (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)))))) + (delete-char) + (insert (nth (1- rret) ret))) + (delete-char) + (insert (car ret)))) + (or (eobp) + (forward-char)))))))) + ;;; @ End. ;;; -- 1.7.10.4