Search code examples
emacselisp

How to create temporary files `.#filename` in `/tmp`, not working directory


When files are being modified in Emacs, a temporary file is created in the working directory that looks like this: .#filename. The file is deleted when the buffer is saved.

I found a few of these types of temporary files in my Git remote repositories, and I thought it might be better to nip the bud at the source instead of configuring Git to ignore them for every project.

How can we configure Emacs to create those files in the /tmp directory instead of the working directory?


Solution

  • The file at issue is called a lock file -- commencing with Emacs version 24.3, it can be controlled with the following setting:

    (setq create-lockfiles nil)
    

    https://stackoverflow.com/a/12974060/2112489