summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenichi Handa <handa@gnu.org>2013-06-28 23:42:55 +0900
committerKenichi Handa <handa@gnu.org>2013-06-28 23:42:55 +0900
commit4d4ff4c6dd9356ff3a24c273a785e08c7609ad92 (patch)
treeb1abbc9fd8f583db56987eb414fae69c7b20ffc7
parentaa453e89dc7a26c048ecaa2f7b4a45917e574c0d (diff)
downloademacs-4d4ff4c6dd9356ff3a24c273a785e08c7609ad92.tar.gz
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).
-rw-r--r--lisp/international/mule-cmds.el7
1 files changed, 6 insertions, 1 deletions
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el
index 0806006a6c3..6ef7709e930 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)