Why does emacs create temporary symbolic links for modified files?

When I change the buffer, Emacs automatically creates a temporary symlink in the same directory as the edited file (for example, foo.c):

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

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

Why is Emacs creating these links and how can I prevent this?

Please note that I turned off the automatic save mode ( Mx auto-save-mode ) and disabled the backup files ( Mx set-variable -> make-backup-files -> nil ). When I save the modified buffer or cancel the changes, the symbolic link disappears.

In particular, I am trying to prevent Emacs from creating these links because they cause a change in the directoryโ€™s timestamp, which forces our build system to rebuild the entire module instead of compiling and linking for one changed file: /

Thanks for any input!




Update. In order for Emacs to constantly create blocking files, you can modify src/filelock.c and create your own binary file:

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



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

 (setq create-lockfiles nil) 
+59
emacs
Apr 21 2018-11-11T00: 00Z
source share
3 answers

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

In the current emacs line, you can simply configure the create-lockfiles variable:

 Ch v create-lockfiles 

Documentation: Non-nil means using lockfiles to avoid editing conflicts.

In your initialization file you can set

 (setq create-lockfiles nil) 

Get it through

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

(I found out about it because I decided to take an active part and just add this option myself ... :))

+52
Oct 19 '12 at 12:11
source share

A symlink is an emacs file locking system: a symlink indicates that the emacs instance is editing the 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 change or disable file locking from emacs.

+32
Apr 21 2018-11-21T00:
source share

As I understand it, most editors:

  • open temp file
  • save temp file
  • rename file temp -> file

This is much safer than truncating and rewriting the file in place, which will lead to file loss if the system crashes at that moment (or at any time while the file is physically unloaded to disk).

You may be able to disable this, but I think the best option is to change your build system.

-2
Apr 21 2018-11-11T00:
source share



All Articles