Windows 10 (64 bit), Emacs 25.1

I want when I save any file to save them (by default) with coding system = UTF-8.

So In my init.el I has :

(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-language-environment 'utf-8)
(set-selection-coding-system 'utf-8)

But it not help. When I try to save file (C-x C-s) Emacs prompt me: "Select coding system"

  • 1
    What is the type/mode of the file you are saving? Having you tried this with just emacs -Q? I just have (prefer-coding-system 'utf-8-unix) in my config (Windows 10, Emacs 25.2) and it works fine. Your code also seems fine, so it is likely something else. – Reign of Error Jul 21 '17 at 10:39
  • Type mode is Text because file is myfile.txt. I try this (prefer-coding-system 'utf-8-unix) - but it not help. I try emacs -Q but it also ask me "Select coding system". – Alex Jul 21 '17 at 11:49
  • That is strange. What language is Windows 10 configured to use - for input etc - and what kind of characters (e.g. Latin, Cyrillic, Chinese) does your text file contain? PS. I didn't mean to suggest you should use 'utf-8-unix, utf-8 should be fine. – Reign of Error Jul 21 '17 at 13:14
  • Also - what does "myfile.txt" contain? Text you typed in? Nothing? Text pasted in? – Reign of Error Jul 21 '17 at 13:23

This does it for me:

(set-language-environment "UTF-8")

See here.


You could try M-x customize then Environment > Keyboard > Keyboard Coding System The docs say "This is set at startup based on locale." which may also point you in the direction of what variable to set.

New contributor
Georg3.14159265 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.