Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does emacs create temporary symbolic links for modified files?

Tags:

emacs

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) 
like image 950
Daniel Schuler Avatar asked Apr 21 '11 00:04

Daniel Schuler


People also ask

Why are symbolic links created?

Symbolic links are used all the time to link libraries and make sure files are in consistent places without moving or copying the original. Links are often used to “store” multiple copies of the same file in different places but still reference to one file.

Why do you need the symbolic link in file management?

A symlink is a symbolic Linux/ UNIX link that points to another file or folder on your computer, or a connected file system. This is similar to a Windows shortcut. Symlinks can take two forms: Soft links are similar to shortcuts, and can point to another file or directory in any file system.

What is a symbolic file link?

A symbolic link is a file-system object that points to another file system object. The object being pointed to is called the target. Symbolic links are transparent to users; the links appear as normal files or directories, and can be acted upon by the user or application in exactly the same manner.

Can symbolic links point to files that don't exist?

You can create a symlink to practically anything, including things that don't exist.


1 Answers

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

like image 97
Arne Babenhauserheide Avatar answered Oct 14 '22 00:10

Arne Babenhauserheide