From 6aa69bd7c54552311267fb30ce71c87309583b04 Mon Sep 17 00:00:00 2001 From: Kenichi Handa Date: Tue, 23 Mar 2004 02:35:36 +0000 Subject: [PATCH] (select-safe-coding-system): Merge coding-system and auto-cs before comparing them. --- lisp/ChangeLog | 5 +++++ lisp/international/mule-cmds.el | 26 +++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index d97a84f6e80..3e20ba34510 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2004-03-23 Kenichi Handa + + * international/mule-cmds.el (select-safe-coding-system): Merge + coding-system and auto-cs before comparing them. + 2004-03-22 Stefan Monnier * emacs-lisp/pp.el (pp-eval-expression): Simplify. diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el index dca8b80744e..65e9fcab362 100644 --- a/lisp/international/mule-cmds.el +++ b/lisp/international/mule-cmds.el @@ -926,13 +926,33 @@ at the risk of losing the problematic characters.\n"))) (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 \ -- 2.39.2