Why does emacs create temporary symbolic links for modified files?

When I modify a buffer, Emacs automatically creates a temporary symlink in the same directory as the file being edited (eg foo.c):

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

where '12345' is Emacs' PID (I don't know what the last number means).

Why does Emacs create these links, and how do I prevent it from doing that?

Note that I have turned off auto save mode ( Mx auto-save-mode ) and disabled backup files ( Mx set-variable -> make-backup-files -> nil ). When I save a modified buffer, or undo the changes to it, the symlink disappears.

In particular, I'm trying to prevent Emacs from creating these links because they cause the directory timestamp to be modified, which causes our build system to rebuild an entire module instead of compiling and linking for one changed file :/

Thanks for any input!


Update: In order to prevent Emacs from creating interlocking files permanently, you can change src/filelock.c and build a custom binary:

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

Update 2: Arne's answer is correct. It's now possible to disable lock files in the latest Emacs (24.3.1), by adding this to your .emacs file:

(setq create-lockfiles nil)

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… :) )


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.

链接地址: http://www.djcxy.com/p/38554.html

上一篇: 如何让emacs将其备份文件与符号链接一起保存?

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