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

查看:12
本文介绍了我如何控制 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这些变量的文档(使用 C-h 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天全站免登陆