Change Emacs Default Coding System

2019-03-09 19:01发布

My problem stems from Emacs inserting the coding system headers into source files containing non-ascii characters:

# -*- coding: utf-8 -*-

My coworkers do not like these headers being checked into our repositories. I don't want them inserted into my files because Emacs automatically detects that the file should be UTF-8 regardless so there doesn't seem to be any benefit to anyone.

I would like to simply set Emacs to use UTF-8 automatically for all files, yet it seems to disagree with this idea. In an effort to fix this, I've added the following to my .emacs:

(prefer-coding-system 'utf-8)
(setq coding-system-for-read 'utf-8)
(setq coding-system-for-write 'utf-8)

This does not seem to solve my problem. Emacs still inserts the coding-system headers into my files. Anyone have any ideas?

EDIT:

I think this problem is specifically related to ruby-mode. I still can't turn it off though.

7条回答
叼着烟拽天下
2楼-- · 2019-03-09 19:32

By default, Emacs will not write file variables into your files. You must have asked it to do so somewhere in your .emacs. Try running emacs -q and see if the file variables get inserted.

查看更多
登录 后发表回答