aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorKenichi Handa <[email protected]>1998-04-15 07:15:01 +0000
committerKenichi Handa <[email protected]>1998-04-15 07:15:01 +0000
commitb5a647bfb59b5e35684252cf5a17775510452223 (patch)
treed9d159d21f7d875b76976c93609d21d8ff6633ab /lisp
parent727fb7903df0bfca302ac64abf7a7d714c515cab (diff)
(coding-system-change-eol-coding): New function.
(coding-system-change-text-coding): New function.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/international/mule-util.el40
1 files changed, 40 insertions, 0 deletions
diff --git a/lisp/international/mule-util.el b/lisp/international/mule-util.el
index a2b534ada2..38178be30b 100644
--- a/lisp/international/mule-util.el
+++ b/lisp/international/mule-util.el
@@ -288,6 +288,46 @@ or one is an alias of the other."
(and (vectorp eol-type-1) (vectorp eol-type-2)))))))
;;;###autoload
+(defun coding-system-change-eol-conversion (coding-system eol-type)
+ "Return a coding system which differs from CODING-SYSTEM in eol conversion.
+The returned coding system converts end-of-line by EOL-TYPE
+but text as the same way as CODING-SYSTEM.
+EOL-TYPE should be `unix', `dos', `mac', or nil.
+If EOL-TYPE is nil, the returned coding system detects
+how end-of-line is formatted automatically while decoding."
+ (let ((eol-type (cond ((eq eol-type 'unix) 0)
+ ((eq eol-type 'dos) 1)
+ ((eq eol-type 'mac) 2)
+ (t eol-type)))
+ (orig-eol-type (coding-system-eol-type coding-system)))
+ (if (vectorp orig-eol-type)
+ (if (not eol-type)
+ coding-system
+ (aref orig-eol-type eol-type))
+ (let ((base (coding-system-base coding-system)))
+ (if (not eol-type)
+ base
+ (if (= eol-type orig-eol-type)
+ coding-system
+ (setq orig-eol-type (coding-system-eol-type base))
+ (if (vectorp orig-eol-type)
+ (aref orig-eol-type eol-type))))))))
+
+;;;###autoload
+(defun coding-system-change-text-conversion (coding-system coding)
+ "Return a coding system which differs from CODING-SYSTEM in text conversion.
+The returned coding system converts text by CODING
+but end-of-line as the same way as CODING-SYSTEM.
+If CODING is nil, the returned coding system detects
+how text is formatted automatically while decoding."
+ (if (not coding)
+ (coding-system-base coding-system)
+ (let ((eol-type (coding-system-eol-type coding-system)))
+ (coding-system-change-eol-conversion
+ coding
+ (if (numberp eol-type) (aref [unix dos mac] eol-type))))))
+
+;;;###autoload
(defmacro detect-coding-with-priority (from to priority-list)
"Detect a coding system of the text between FROM and TO with PRIORITY-LIST.
PRIORITY-LIST is an alist of coding categories vs the corresponding