I am trying to configure Emacs to save UTF-8 files with a Byte Order Mark. (Yes, I know that the BOM is evil and unnecessary for UTF-8 files. However, Microsoft has decided they know better, so I want to make sure I'm able to save files with BOM.)
However, for some reason my choice of utf-8-with-signature
for buffer-file-coding-system
won't stick when I save the file.
I'm using Emacs 24.5.1 on Windows 10. To reproduce:
emacs -Q
- Open a file (optionally one that already has a BOM).
(setq buffer-file-coding-system 'utf-8-with-signature)
(OrM-x set-buffer-file-coding-system RET utf-8-with-signature RET
.)C-x C-s
C-h v buffer-file-coding-system
. It is now set toutf-8-dos
. I also verified that the existing BOM was removed from the file.
Why is this happening, and how can I fix it?