There are files like session.10110ac205e127d7e2143131143297155100000021880037 in my .emacs.d folder. I would like to do something about it but could not figure out what to do.

  • What are these files for ?
  • Why emacs generate multiple files ?

These are saved session files which emacs dumps when the window manager notifies it that it is shutting down. See the function emacs-session-save. There are multiple files because they are suffixed by the X session ID. Are you by chance in the habit of quitting your window manager before you exit emacs?

  • That sounds right. However, I cannot find emacs-session-save function. Is there anything I should load into emacs ? – Rangi Lin May 28 '15 at 15:25
  • @RangiLin: C-h f emacs-session-save should take you there. It's in lisp/term/x-win.el if you have the Emacs source code. According to git the function has been there since 2002 so it's quite old ;-) – stsquad May 28 '15 at 15:34
  • It took me awhile to realize that emacs need to load term (or M-x term to load) in order to find this function, emacs-session-filename is the function that decide where the file should be saved. I will take some time to see how I can change it. Thanks. – Rangi Lin Jun 1 '15 at 4:00
  • 1
    How do we stop them from being made (or move them to another directory)? – Startec May 3 '18 at 5:21

There is a movement to clean up this kind of litter of files in .emacs.d:

emacscollective/no-littering: Help keeping ~/.emacs.d clean

This issue has been addressed to some degree by emacs-session: theme emacs-session-filename (#38) by DamienCassou · Pull Request #39 · emacscollective/no-littering but I think it simply puts the files in a subdirectory of .emacs.d

This still doesn't address the underlying question of why empty files are being left around. (Yes - for me, all 84 session.* files are empty. And yes, I don't bother exiting emacs before shutting down - I just run (desktop-save-in-desktop-dir))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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