From: Kenichi Handa Date: Wed, 29 Dec 2004 01:25:15 +0000 (+0000) Subject: (recode-region): New function. X-Git-Tag: ttn-vms-21-2-B4~3081 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=27a91cf7c3e70cb169d6a442064a632b8cea55ec;p=emacs.git (recode-region): New function. --- diff --git a/lisp/international/mule.el b/lisp/international/mule.el index 144bd0360ca..ea227ea7e9f 100644 --- a/lisp/international/mule.el +++ b/lisp/international/mule.el @@ -1924,6 +1924,25 @@ Part of the job of this function is setting `buffer-undo-list' appropriately." (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