I use this piece of code to set the default line ending to linux-style \n
;; https://www.emacswiki.org/emacs/EndOfLineTips
(add-hook 'find-file-hook 'find-file-check-line-endings)
(defun dos-file-endings-p ()
(string-match "dos" (symbol-name buffer-file-coding-system)))
(defun find-file-check-line-endings ()
(when (dos-file-endings-p)
(set-buffer-file-coding-system 'undecided-unix)
(set-buffer-modified-p nil)))
And this - to set the default encoding to utf-8
;; emacs set default codepage
;; https://stackoverflow.com/questions/1785200/change-emacs-default-coding-system
(prefer-coding-system 'utf-8)
(setq coding-system-for-read 'utf-8)
(setq coding-system-for-write 'utf-8)
But it looks like because of the second one, first isn't working. Now line ending is \r\n
on saving, even if I manually change it.