I want my autosave files and backup files, e.g. #filename.org# and filename.org~ files, not to clutter the directory in my code repo that is in TypeScript.

I have popped into a way to place inside another directory and it worked. However, after that I have seen another file popping up with .#filename.org.

What is this file for? How can I make Emacs put them into another directory too?

  • 1
    It's a lockfile to prevent another emacs from overwriting your changes. There's no provision for putting them somewhere else (but you can turn them off by setting create-lockfiles to nil)
    – rpluim
    Jan 14, 2021 at 14:53
  • If teh file is saved the lock file is destroyed, that means in my specific case I actually do not need to have a way to make emacs create them in another dirctory. I did not want the emacs specific files to clutter my other editors direcotry view. Also one can add a gitignore file to ignore tracking those files, there are comprehensie ready made gitignore files for emacs and many things.
    – sçuçu
    Jan 14, 2021 at 20:59

1 Answer 1


emacs-28, which has just been released, comes with lock-file-name-transforms, which lets you place those lockfiles somewhere other than in the same directory.

  • If you are not accessing shared files, then turning off lock-files altogether is probably fine. If you /are/ accessing files shared with other emacs users, then the locks are only useful if everyone agrees on lock-file-name-transforms....
    – glucas
    May 5, 2022 at 15:24
  • 1
    There's also the case where the other Emacs user is yourself with another instance of Emacs. I run into that surprisingly often.
    – rpluim
    May 9, 2022 at 13:49
  • Could you show how to use this?
    – Mike H-R
    Sep 5, 2023 at 12:31
  • C-h v lock-file-name-transforms explains how to use it.
    – rpluim
    Sep 6, 2023 at 7:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.