I'm using Emacs on Windows. Everything was fine just a few minutes ago, but for some odd reason, when I open a certain file, I get ^M
characters after every line. As far as I know/remember, I didn't do anything to the file except refile a a couple org-mode items (and they didn't contain any strange characters like smart quotes or anything either)... and yet when I closed then reopened the file a few seconds later, these characters appeared. It only happens for that file; other buffers seem to be okay.
Based on my research, ^M
seems to be the end of line character for Windows.
Following this, executing M-x revert-buffer-with-coding-system utf-8-dos
seems to fix the problem until I open the file again, at which point the ^M
s return.
The only encoding-related thing I have in my init.el file is
(set-language-environment "UTF-8")
(set-default-coding-systems 'utf-8)
which hasn't changed since I set them a couple months ago.
Does anyone have any idea what happened?
Update: One thing I noticed (after disabling my modeline theme) is that the file in question seems to always want to revert to (Unix)
Unix-style LF line endings, when all my other (working) files are set to \
DOS-style CRLF line endings. I have some characters like é and あ in my file, but they hadn't caused problems before...
Here's a comparison of the modeline indicators:
- (Working) File with no
^M
, no foreign characters:-\
undecided-dos, DOS-style CRLF - (Not working) File with
^M
, with foreign characters:=(Unix)
no-conversion, Unix-style LF - (Working) File with no
^M
, with foreign characters:U\
utf-8-dos, CRLF
The "not working" file always seems to want to open with (Unix) and no-conversion...
Update 2: I seem to have temporarily been able to solve this by forcing the buffer to read the file as utf-8-dos by including # -*- coding: utf-8-dos -*-
at the top.
I will leave this question open, however, as I still would like to know what caused this, and why emacs suddenly decided it wanted to encode the file as no-conversion
even though it had been handling foreign characters just fine earlier in the day...