我正在尝试 .gitignore emacs 临时/自动保存文件。我正在使用...
\.\#.*
在我的 .gitignore 中。
但是 git add -A
在子文件夹中运行仍然给我:
# new file: .#make_collections.py
# new file: .#norm_collections.py
# new file: make_collections.py
# new file: norm_collections.py
虽然
\.\#.*
当我 test it with a regex tester 时,显然得到了正确的文件名而不是错误的文件名。 .
最佳答案
您还可以通过设置变量 auto-save-file-name-transforms
指示 emacs 将自动保存文件完全保存在不同的目录中,我在我的初始化文件中有这个
(setq auto-save-file-name-transforms
`((".*" ,(concat user-emacs-directory "auto-save/") t)))
这指示 emacs 将自动保存存储在用户 emacs 目录(通常是 ~/.emacs.d
)的 auto-save
文件夹中。
要将备份文件保存在不同的目录中,请设置变量 backup-directory-alist
,以下会将备份文件保存在用户 emacs 目录中的 backups
文件夹中
(setq backup-directory-alist
`(("." . ,(expand-file-name
(concat user-emacs-directory "backups")))))
关于regex - .gitignore 用于 emacs 临时文件的正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22175365/