diff options
| author | Kenichi Handa | 1998-04-15 07:15:01 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1998-04-15 07:15:01 +0000 |
| commit | b5a647bfb59b5e35684252cf5a17775510452223 (patch) | |
| tree | d9d159d21f7d875b76976c93609d21d8ff6633ab | |
| parent | 727fb7903df0bfca302ac64abf7a7d714c515cab (diff) | |
| download | emacs-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.el | 40 |
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. | ||
| 293 | The returned coding system converts end-of-line by EOL-TYPE | ||
| 294 | but text as the same way as CODING-SYSTEM. | ||
| 295 | EOL-TYPE should be `unix', `dos', `mac', or nil. | ||
| 296 | If EOL-TYPE is nil, the returned coding system detects | ||
| 297 | how 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. | ||
| 319 | The returned coding system converts text by CODING | ||
| 320 | but end-of-line as the same way as CODING-SYSTEM. | ||
| 321 | If CODING is nil, the returned coding system detects | ||
| 322 | how 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. |
| 293 | PRIORITY-LIST is an alist of coding categories vs the corresponding | 333 | PRIORITY-LIST is an alist of coding categories vs the corresponding |