如何隐藏emacs创建的备份文件? [英] How can I hide the backup files that emacs creates?
问题描述
我刚开始使用emacs,使用vi很长一段时间。 :)
令人烦恼的一件事是,每当我修改一个文件,保存并退出emacs,我看到一个名为 filename〜
(如果我编辑的文件是 filename
)。
您可以使用以下代码将它们移动到自己的文件夹:
;;不要用文件来混淆目录〜
(setq backup-directory-alist`((。。,(expand-file-name
(concat dotfiles-dirbackups)))) )
;;不要混淆#files
(setq auto-save-file-name-transforms
`((。*,(expand-file-name(concat dotfiles-dirbackups) ))))
或者您可以完全删除它们,如下所示:
(setq make-backup-files nil)
(setq auto-save-default nil)
我个人谨慎删除它们,因为他们可以进来有用。进一步讨论如下:
我建议您退房 emacs-starter-kit ,它排除了人们在使用emacs时遇到的一些问题,并且被大量使用。
< a href =http://github.com/technomancy/emacs-starter-kit/blob/master/starter-kit-misc.el =noreferrer> http://github.com/technomancy/emacs-入门套件/ blob / master / starter-kit-misc.el
更新:
似乎对如何使用这些功能有很多的困惑。我稍后会有一点玩,但这里有一些更多的信息。请注意, auto-save-file-name-transforms
:
可让您指定一系列正则表达式和替换,以转换自动保存文件名称
[emacs-manual]
所以它不仅仅是添加到一个文件夹名称。那就是说,从一个快速的谷歌搜索来看,以下可能只是做你想要的:
;;;备份/自动保存
(defvar backup-dir(expand-file-name〜/ .emacs.d / backup /))
(defvar autosave-dir(expand-file-name〜/ emacs.d / autosave /))
(setq backup-directory-alist(list(cons。*backup-dir)))
(setq auto-save-list-file-prefix autosave -dir)
(setq auto-save-file-name-transforms`((。*,autosave-dir t)))
http://www.google.com/codesearch?hl=zh-CN&lr=&q=auto-save-file-name-transforms&sbtn=Search
I just started using emacs after having used vi for a long time. :)
One thing which is annoying me is that whenever I modify a file, save it and exit emacs, I see a backup file created in the same directory named filename~
(if the file I edited was filename
).
Is there any way I can get rid of this? Or hide these files? It is very annoying to see tons of backup files when I do ls of the directory.
You can either move them to their own folder with the following code:
;; Don't clutter up directories with files~
(setq backup-directory-alist `(("." . ,(expand-file-name
(concat dotfiles-dir "backups")))))
;; Don't clutter with #files either
(setq auto-save-file-name-transforms
`((".*" ,(expand-file-name (concat dotfiles-dir "backups")))))
Or you can remove them completely, like so:
(setq make-backup-files nil)
(setq auto-save-default nil)
Personally I would be wary of removing them as they can come in useful. Further discussion is here:
I would recommend checking out the emacs-starter-kit it sorts out a load of issues that people have when coming to emacs, and is pretty heavily used.
http://github.com/technomancy/emacs-starter-kit/blob/master/starter-kit-misc.el
Update:
There seems to be much confusion over how to use the functions. I'm going to have a little play around later but here is some more information. Note that auto-save-file-name-transforms
:
lets you specify a series of regular expressions and replacements to transform the auto save file name [emacs-manual]
so it's not just as simple as adding in a folder name. That said it seems from a quick google search the following might just do what you all want:
;;; backup/autosave
(defvar backup-dir (expand-file-name "~/.emacs.d/backup/"))
(defvar autosave-dir (expand-file-name "~/.emacs.d/autosave/"))
(setq backup-directory-alist (list (cons ".*" backup-dir)))
(setq auto-save-list-file-prefix autosave-dir)
(setq auto-save-file-name-transforms `((".*" ,autosave-dir t)))
http://www.google.com/codesearch?hl=en&lr=&q=auto-save-file-name-transforms&sbtn=Search
这篇关于如何隐藏emacs创建的备份文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!