# HG changeset patch # User Kenichi Handa # Date 1104283515 0 # Node ID a9efc32867d2e8f5ba7a885eaf2077429acaecee # Parent 517f681ba7a8a5290493c05e5cd28aa54103e9c9 (recode-region): New function. diff -r 517f681ba7a8 -r a9efc32867d2 lisp/international/mule.el --- a/lisp/international/mule.el Wed Dec 29 00:10:31 2004 +0000 +++ b/lisp/international/mule.el Wed Dec 29 01:25:15 2004 +0000 @@ -1924,6 +1924,25 @@ (setq buffer-undo-list (cons (cons from (point-max)) undo-list-saved)))))))) +(defun recode-region (start end new-coding coding) + "Re-decode the region (previously decoded by CODING) by NEW-CODING." + (interactive + (list (region-beginning) (region-end) + (read-coding-system "Text was really in: ") + (let ((coding (or buffer-file-coding-system last-coding-system-used))) + (read-coding-system + (concat "But was interpreted as" + (if coding (format " (default %S): " coding) ": ")) + coding)))) + (or (and new-coding coding) + (error "Coding system not specified")) + ;; Check it before we encode the region. + (check-coding-system new-coding) + (save-restriction + (narrow-to-region start end) + (encode-coding-region (point-min) (point-max) coding) + (decode-coding-region (point-min) (point-max) new-coding))) + (defun make-translation-table (&rest args) "Make a translation table from arguments. A translation table is a char table intended for character