From: Kenichi Handa Date: Fri, 28 Jun 2013 14:42:55 +0000 (+0900) Subject: mule-cmds.el (select-safe-coding-system): If X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~1996 X-Git-Url: https://code.delx.au/gnu-emacs/commitdiff_plain/4d4ff4c6dd9356ff3a24c273a785e08c7609ad92 mule-cmds.el (select-safe-coding-system): If DEFAULT-CODING-SYSTEM is prefer-utf-8 and the buffer contains multibyte characters, return utf-8 (or one of it's siblings). --- diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el index 0806006a6c..6ef7709e93 100644 --- a/lisp/international/mule-cmds.el +++ b/lisp/international/mule-cmds.el @@ -972,7 +972,7 @@ It is highly recommended to fix it before writing to a file." ;; Classify the defaults into safe, rejected, and unsafe. (dolist (elt default-coding-system) - (if (or (eq (car codings) 'undecided) + (if (or (eq (coding-system-type (car elt)) 'undecided) (memq (cdr elt) codings)) (if (and (functionp accept-default-p) (not (funcall accept-default-p (cdr elt)))) @@ -1029,6 +1029,11 @@ and try again)? " coding-system auto-cs)) (error "Save aborted")))) (when (and tick (/= tick (buffer-chars-modified-tick))) (error "Canceled because the buffer was modified")) + (if (and (eq (coding-system-type coding-system) 'undecided) + (coding-system-get coding-system :prefer-utf-8) + (< (- to from) (- (position-bytes to) (position-bytes from)))) + (setq coding-system + (coding-system-change-text-conversion coding-system 'utf-8))) coding-system))) (setq select-safe-coding-system-function 'select-safe-coding-system)