Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
244 views
in Technique[技术] by (71.8m points)

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 (e.g. foo.c):

.#foo.c -> [email protected]: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 (M-x auto-save-mode) and disabled backup files (M-x 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)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...