为什么 emacs 为修改后的文件创建临时符号链接?

当我修改缓冲区时,Emacs 会自动在正在编辑的文件所在的目录中创建一个临时符号链接(例如 foo.c) :

.#foo.c -> user@host.12345:1296583136

其中“12345”是 Emacs 的 PID (我不知道最后一个数字是什么意思)。

为什么 Emacs 创建这些链接,我如何防止它这样做?

注意,我已经关闭了自动保存模式(M-x auto-save-mode)并禁用了备份文件(M-x set-variable -> make-backup-files -> nil)。当我保存修改后的缓冲区或撤消对它的更改时,符号链接就会消失。

特别是,我试图阻止 Emacs 创建这些链接,因为它们会导致修改目录时间戳,这会导致我们的构建系统重新构建整个模块,而不是为一个已更改的文件编译和链接:/

谢谢你的建议!


更新: 为了防止 Emacs 永久地创建联锁文件,您可以更改 src/filelock.c并构建一个自定义二进制文件:

void
lock_file (fn)
Lisp_Object fn;
{
return;
// Unused code below...
}

更新2: Arne 的答案是正确的。现在可以在最新的 Emacs (24.3.1)中禁用锁文件,方法是将其添加到。Emacs 档案:

(setq create-lockfiles nil)
7619 次浏览

The symbolic link is emacs' file interlocking system: the symbolic link indicates that an instance of emacs is editing this file. If another instance tries to edit the same file, emacs will issue a warning. See http://www.gnu.org/software/emacs/manual/html_node/emacs/Interlocking.html

This has nothing to do with auto-save.

I cannot find how to modify or disable file locking from within emacs.

Update: Emacs 24.3 has been released with full support for this new setting!

In the current trunk of emacs, you can simply customize the variable create-lockfiles:

C-h v create-lockfiles

Documentation: Non-nil means use lockfiles to avoid editing collisions.

In your init file, you can set

(setq create-lockfiles nil)

Get it via

bzr branch bzr://bzr.savannah.gnu.org/emacs/trunk emacs-trunk
make
src/emacs

(I found out about this, because I decided to get active and just add an option like that myself… :) )