Mercurial > emacs
changeset 54507:96c240b674ee
(select-safe-coding-system): Merge
coding-system and auto-cs before comparing them.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Tue, 23 Mar 2004 02:33:41 +0000 |
parents | 4c1b8195ebf5 |
children | 192ac22b4182 |
files | lisp/international/mule-cmds.el |
diffstat | 1 files changed, 23 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/international/mule-cmds.el Mon Mar 22 17:12:16 2004 +0000 +++ b/lisp/international/mule-cmds.el Tue Mar 23 02:33:41 2004 +0000 @@ -926,13 +926,33 @@ (goto-char (point-min)) (set-auto-coding (or file buffer-file-name "") (buffer-size)))))) - (if (and auto-cs coding-system + ;; Merge coding-system and auto-cs as far as possible. + (if (not coding-system) + (setq coding-system auto-cs) + (if (not auto-cs) + (setq auto-cs coding-system) + (let ((eol-type-1 (coding-system-eol-type coding-system)) + (eol-type-2 (coding-system-eol-type auto-cs))) + (if (eq (coding-system-base coding-system) 'undecided) + (setq coding-system (coding-system-change-text-conversion + coding-system auto-cs)) + (if (eq (coding-system-base auto-cs) 'undecided) + (setq auto-cs (coding-system-change-text-conversion + auto-cs coding-system)))) + (if (vectorp eol-type-1) + (or (vectorp eol-type-2) + (setq coding-system (coding-system-change-eol-conversion + coding-system eol-type-2))) + (if (vectorp eol-type-2) + (setq auto-cs (coding-system-change-eol-conversion + auto-cs eol-type-1))))))) + + (if (and auto-cs ;; Don't barf if writing a compressed file, say. ;; This check perhaps isn't ideal, but is probably ;; the best thing to do. (not (auto-coding-alist-lookup (or file buffer-file-name ""))) - (not (coding-system-equal (coding-system-base coding-system) - (coding-system-base auto-cs)))) + (not (coding-system-equal coding-system auto-cs))) (unless (yes-or-no-p (format "Selected encoding %s disagrees with \ %s specified by file contents. Really save (else edit coding cookies \