summaryrefslogtreecommitdiff
path: root/lisp/international
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2018-08-14 09:06:43 -0700
committerGlenn Morris <rgm@gnu.org>2018-08-14 09:06:43 -0700
commitd113142a8b8c815ecd6ff1418694cb878db5f45c (patch)
tree633f01eefae0388b9cae7b7b2169abe8b2ebb660 /lisp/international
parent396a33a3656a0e2bbe2f24a81df64914491c44e5 (diff)
parent614cc65f2dae346b2e30326cd5de01f891933eed (diff)
downloademacs-d113142a8b8c815ecd6ff1418694cb878db5f45c.tar.gz
Merge from origin/emacs-26
614cc65 ; * lisp/simple.el (line-move-visual): Fix typo. d2ad4ba Do not consider external packages to be removable (Bug#27822) ec0995c * src/alloc.c: Remove obsolete comments. ec6f588 Better support utf-8-with-signature and utf-8-hfs in HTML eb026a8 Don't use -Wabi compiler option
Diffstat (limited to 'lisp/international')
-rw-r--r--lisp/international/mule.el12
1 files changed, 11 insertions, 1 deletions
diff --git a/lisp/international/mule.el b/lisp/international/mule.el
index a5e7477e758..0267b154409 100644
--- a/lisp/international/mule.el
+++ b/lisp/international/mule.el
@@ -2545,7 +2545,17 @@ This function is intended to be added to `auto-coding-functions'."
(let* ((match (match-string 2))
(sym (intern (downcase match))))
(if (coding-system-p sym)
- sym
+ ;; If the encoding tag is UTF-8 and the buffer's
+ ;; encoding is one of the variants of UTF-8, use the
+ ;; buffer's encoding. This allows, e.g., saving an
+ ;; HTML file as UTF-8 with BOM when the tag says UTF-8.
+ (let ((sym-type (coding-system-type sym))
+ (bfcs-type
+ (coding-system-type buffer-file-coding-system)))
+ (if (and (coding-system-equal 'utf-8 sym-type)
+ (coding-system-equal 'utf-8 bfcs-type))
+ buffer-file-coding-system
+ sym))
(message "Warning: unknown coding system \"%s\"" match)
nil)))))