aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa1998-04-15 07:15:01 +0000
committerKenichi Handa1998-04-15 07:15:01 +0000
commitb5a647bfb59b5e35684252cf5a17775510452223 (patch)
treed9d159d21f7d875b76976c93609d21d8ff6633ab
parent727fb7903df0bfca302ac64abf7a7d714c515cab (diff)
downloademacs-b5a647bfb59b5e35684252cf5a17775510452223.tar.gz
emacs-b5a647bfb59b5e35684252cf5a17775510452223.zip
(coding-system-change-eol-coding): New function.
(coding-system-change-text-coding): New function.
-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 a2b534ada28..38178be30b0 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."
288 (and (vectorp eol-type-1) (vectorp eol-type-2))))))) 288 (and (vectorp eol-type-1) (vectorp eol-type-2)))))))
289 289
290;;;###autoload 290;;;###autoload
291(defun coding-system-change-eol-conversion (coding-system eol-type)
292 "Return a coding system which differs from CODING-SYSTEM in eol conversion.
293The returned coding system converts end-of-line by EOL-TYPE
294but text as the same way as CODING-SYSTEM.
295EOL-TYPE should be `unix', `dos', `mac', or nil.
296If EOL-TYPE is nil, the returned coding system detects
297how end-of-line is formatted automatically while decoding."
298 (let ((eol-type (cond ((eq eol-type 'unix) 0)
299 ((eq eol-type 'dos) 1)
300 ((eq eol-type 'mac) 2)
301 (t eol-type)))
302 (orig-eol-type (coding-system-eol-type coding-system)))
303 (if (vectorp orig-eol-type)
304 (if (not eol-type)
305 coding-system
306 (aref orig-eol-type eol-type))
307 (let ((base (coding-system-base coding-system)))
308 (if (not eol-type)
309 base
310 (if (= eol-type orig-eol-type)
311 coding-system
312 (setq orig-eol-type (coding-system-eol-type base))
313 (if (vectorp orig-eol-type)
314 (aref orig-eol-type eol-type))))))))
315
316;;;###autoload
317(defun coding-system-change-text-conversion (coding-system coding)
318 "Return a coding system which differs from CODING-SYSTEM in text conversion.
319The returned coding system converts text by CODING
320but end-of-line as the same way as CODING-SYSTEM.
321If CODING is nil, the returned coding system detects
322how text is formatted automatically while decoding."
323 (if (not coding)
324 (coding-system-base coding-system)
325 (let ((eol-type (coding-system-eol-type coding-system)))
326 (coding-system-change-eol-conversion
327 coding
328 (if (numberp eol-type) (aref [unix dos mac] eol-type))))))
329
330;;;###autoload
291(defmacro detect-coding-with-priority (from to priority-list) 331(defmacro detect-coding-with-priority (from to priority-list)
292 "Detect a coding system of the text between FROM and TO with PRIORITY-LIST. 332 "Detect a coding system of the text between FROM and TO with PRIORITY-LIST.
293PRIORITY-LIST is an alist of coding categories vs the corresponding 333PRIORITY-LIST is an alist of coding categories vs the corresponding