aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorKenichi Handa <[email protected]>2003-01-22 02:33:07 +0000
committerKenichi Handa <[email protected]>2003-01-22 02:33:07 +0000
commitf29387e80b31f675b8e54516ab94b1eca157b730 (patch)
treeb0af5fca7ed8dcf1b3b62e6725bbf739376eeb86 /lisp
parent7b997a977e6271d9fd3e4d15bb755889727d3e0a (diff)
(decode-coding-region-as-inserted-from-file): New function.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/international/mule.el27
1 files changed, 27 insertions, 0 deletions
diff --git a/lisp/international/mule.el b/lisp/international/mule.el
index 909ba315b7..aa14f442bd 100644
--- a/lisp/international/mule.el
+++ b/lisp/international/mule.el
@@ -1899,6 +1899,33 @@ or a function symbol which, when called, returns such a cons cell."
(cons (cons regexp coding-system)
network-coding-system-alist)))))))
+(defun decode-coding-region-as-inserted-from-file (from to filename
+ &optional
+ visit beg end replace)
+ "Decode the region between FROM and TO as if it is read from file FILENAME.
+Optional arguments VISIT, BEG, END, and REPLACE are the same as those
+of the function `insert-file-contents'."
+ (save-excursion
+ (save-restriction
+ (narrow-to-region from to)
+ (goto-char (point-min))
+ (let ((coding coding-system-for-read))
+ (or coding
+ (setq coding (funcall set-auto-coding-function
+ filename (- (point-max) (point-min)))))
+ (or coding
+ (setq coding (find-operation-coding-system
+ 'insert-file-contents
+ filename visit beg end replace)))
+ (if (coding-system-p coding)
+ (or enable-multibyte-characters
+ (setq coding
+ (coding-system-change-text-conversion coding 'raw-text)))
+ (setq coding nil))
+ (if coding
+ (decode-coding-region (point-min) (point-max) coding))
+ (setq last-coding-system-used coding)))))
+
(defun make-translation-table (&rest args)
"Make a translation table from arguments.
A translation table is a char table intended for character