From: tomo Date: Wed, 5 Nov 2003 15:19:34 +0000 (+0000) Subject: (ideo-translate-region-into-traditional): New command. X-Git-Tag: chise-base-0_23~42 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d0c81d521e6c5efa6bc852816c56b4820f7bd1c9;p=chise%2Ftomoyo-tools.git (ideo-translate-region-into-traditional): New command. --- 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. ;;;