(define-coding-system-alias 'dos 'undecided-dos)
(define-coding-system-alias 'mac 'undecided-mac)
+(define-coding-system 'prefer-utf-8
+ "Like `undecided' but prefer UTF-8 when appropriate.
+On decoding, if the source contains 8-bit codes and they all
+are valid UTF-8 sequences, detect the source as UTF-8 encoding
+regardless of the coding priority.
+On encoding, if the source contains non-ASCII characters, encode them
+by UTF-8."
+ :coding-type 'undecided
+ :mnemonic ?-
+ :charset-list '(emacs)
+ :prefer-utf-8 t)
+
(define-coding-system 'raw-text
"Raw text, which means text contains random 8-bit codes.
Encoding text with this coding system produces the actual byte
(setq file-coding-system-alist
(mapcar (lambda (arg) (cons (purecopy (car arg)) (cdr arg)))
'(("\\.elc\\'" . utf-8-emacs)
- ("\\.el\\'" . utf-8)
+ ("\\.el\\'" . prefer-utf-8)
("\\.utf\\(-8\\)?\\'" . utf-8)
("\\.xml\\'" . xml-find-file-coding-system)
;; We use raw-text for reading loaddefs.el so that if it