更改Emacs默认编码系统 [英] Change Emacs Default Coding System

查看:120
本文介绍了更改Emacs默认编码系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题源于Emacs将编码系统头插入到包含非ASCII字符的源文件中:

 # -  *  - 编码:utf-8  -  *  -  

我的同事不喜欢这些标题被检入我们的存储库。我不希望它们插入到我的文件中,因为Emacs会自动检测到该文件应该是UTF-8,无论如何,似乎没有任何好处。



我想简单地将Emacs设置为对所有文件自动使用UTF-8,但它似乎不同意这个想法。为了解决这个问题,我将以下内容添加到我的.emacs中:

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

这似乎无法解决我的问题。 Emacs仍然将编码系统头插入到我的文件中。任何人都有任何想法?



编辑:



我认为这个问题与ruby-mode有关。我仍然无法关闭它。

解决方案

默认情况下,Emacs不会将文件变量写入文件。你必须要求它在你的.emacs的某个地方这样做。尝试运行emacs -q并查看是否插入文件变量。


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.

解决方案

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.

这篇关于更改Emacs默认编码系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆