In my .emacs file, I use the line
'(setq coding-system-for-write 'iso-8859-1-unix)
to have Emacs save files in the iso-8859-1-unix encoding. When I enter characters that cannot be encoded that way ("Łódź" for example), I get prompted to select a different encoding, but upon entering `iso-8859-1-unix' into the minibuffer, the file is saved and the offending characters are lost.
If I just hit enter at the prompt, the file is saved in Unicode, and when I close and reopen Emacs it is interpreted as a Unicode file again. If I then remove the offending characters, save the file and close and reopen Emacs another time, it is still interpreted as a Unicode file -- from which I deduce that it has still been saved in Unicode, even though saving in iso-8859-1-unix would have been possible.
So is there a way to force Emacs to write a file in iso-8859-1 whenever possible, and never save it in that encoding if doing so would gobble characters?
Many thanks in advance,
Thure Dührsen
As per the doc string for coding-system-for-write
, you should not be setting it globally.
Perhaps what you are looking for is (prefer-coding-system 'iso-8859-1-unix)
?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With