默认情况下,如何配置GNU Emacs来编写UNIX或DOS格式的文件? [英] How to configure GNU Emacs to write UNIX or DOS formatted files by default?

查看:135
本文介绍了默认情况下,如何配置GNU Emacs来编写UNIX或DOS格式的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的 .emacs.el 文件中使用了这些功能:

I've had these functions in my .emacs.el file for years:

(defun dos2unix ()
  "Convert a DOS formatted text buffer to UNIX format"
  (interactive)
  (set-buffer-file-coding-system 'undecided-unix nil))

(defun unix2dos ()
  "Convert a UNIX formatted text buffer to DOS format"
  (interactive)
  (set-buffer-file-coding-system 'undecided-dos nil))

这些功能允许我轻松地在格式之间切换,但是我不知道如何配置Emacs默认写入一种特定的格式,无论我使用哪个平台。现在,当我在Windows上运行时,Emacs以Windows格式保存;当我在UNIX / Linux中运行时,Emacs以UNIX格式保存。

These functions allow me to easily switch between formats, but I'm not sure how to configure Emacs to write in one particular format by default regardless of which platform I'm using. As it is now, when I run on Windows, Emacs saves in Windows format; when I run in UNIX/Linux, Emacs saves in UNIX format.

我想指示Emacs以UNIX格式编写,无论其上的平台我正在运行我该怎么做?

我应该添加一些调用其中一个函数的文本模式钩子吗?例如,如果我在Windows上,然后在找到文本文件时调用 dos2unix

Should I perhaps add some text mode hook that calls one of these functions? For example, if I'm on Windows, then call dos2unix when I find a text file?

推荐答案

我的.emacs中有一堆这样的内容:

I've got a bunch of these in my .emacs:

(setq-default buffer-file-coding-system 'utf-8-unix)
(setq-default default-buffer-file-coding-system 'utf-8-unix)
(set-default-coding-systems 'utf-8-unix)
(prefer-coding-system 'utf-8-unix)

我不知道哪个是对的,我只是迷信。

I don't know which is right, I am just superstitious.

这篇关于默认情况下,如何配置GNU Emacs来编写UNIX或DOS格式的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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