如何控制Emacs如何备份文件? [英] How do I control how Emacs makes backup files?

查看:144
本文介绍了如何控制Emacs如何备份文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Emacs将备份文件命名为 foo〜无处不在,我不想记得删除它们。另外,如果我在文件系统中编辑硬链接的其他位置的文件,硬编辑链接指向备份,当我完成编辑,这是令人困惑和可怕的。如何消除这些备份文件,或者将它们移动到同一个目录以外的地方?

Emacs puts backup files named foo~ everywhere and I don't like having to remember to delete them. Also, if I edit a file that has a hard link somewhere else in the file system, the hard link points to the backup when I'm done editing, and that's confusing and awful. How can I either eliminate these backup files, or have them go somewhere other than the same directory?

推荐答案

被Emacs备份文件保存,你
可能需要更多的它们,而不是更少。这是令人讨厌的
,它们与您正在编辑的文件相同的目录
,但这很容易改变。您可以将所有备份文件通过在
.emacs 中将以下内容放入目录中

If you've ever been saved by an Emacs backup file, you probably want more of them, not less of them. It is annoying that they go in the same directory as the file you're editing, but that is easy to change. You can make all backup files go into a directory by putting something like the following in your .emacs.

(setq backup-directory-alist `(("." . "~/.saves")))

有几个神秘细节与Emacs
可能如何创建备份文件相关联。应该重命名原来的
并写出编辑的缓冲区吗?如果原文链接起来怎么办?
一般来说,最安全但最慢的赌注是总是通过复制来备份

There are a number of arcane details associated with how Emacs might create your backup files. Should it rename the original and write out the edited buffer? What if the original is linked? In general, the safest but slowest bet is to always make backups by copying.

(setq backup-by-copying t)

如果这太慢了,您可能还可以看看
备份时的链接

If that's too slow for some reason you might also have a look at backup-by-copying-when-linked.

自您的备份现在都在自己的位置,您可能需要更多的
,而不是更少的备份。看看这些变量的Emacs
文档(使用 Ch v )。

Since your backups are all in their own place now, you might want more of them, rather than less of them. Have a look at the Emacs documentation for these variables (with C-h v).

(setq delete-old-versions t
  kept-new-versions 6
  kept-old-versions 2
  version-control t)

最后,如果绝对不需要备份文件:

Finally, if you absolutely must have no backup files:

(setq make-backup-files nil)

它让我生病,想想它。

这篇关于如何控制Emacs如何备份文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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