I almost never manually save files; I rely on auto-save.

In the past few months I have noticed some of my edits mysteriously disappearing. The disappearances seem to be related to Linux crashes (about 2/month) or Emacs crashes (about 10/month). Today I found that my Emacs auto-save sometimes fails, but I don't know how to reproduce the auto-save failure.

Here is the time line of the last edit disappearance:

4/29/18  7:20:33  My login screen suddenly appeared.
         When I logged back in, all applications that where open on desktop are now closed.
         Messages say that Xorg and Emacs crashed.
4/29/18  About 20:00, edited tasks.org file: archived tasks and added new tasks.
5/01/18  6:13:14  My login screen suddenly appeared.
         When I logged back in, all applications that where open on desktop are now closed.
         Messages say that Xorg and Emacs crashed.
5/01/18  6:16:47  I rebooted.
         I opened tasks.org and saw edits from 4/29/18 20:00 are missing (tasks.org is old version modified on 29 Apr 2018 09∶33).
         From terminal:
             $ ls -l -A ~/Documents/tasks
             -rw-r--r--. 1 wolfv wolfv 35148 Apr 29 09:33 tasks.org
             -rw-rw-r--. 1 wolfv wolfv 39936 Apr 29 09:40 tasks.org_archive
         In my hourly backup folder, the last backup of tasks.org is tasks.org_2018-04-29_10:00:01.

So apparently the tasks.org buffer was not auto-saved for at least 10 hours.

This time I know the edit disappearance is not my imagination because both tasks.org and tasks.org_archive contain the archived tasks.

All other emacs files during this time span where auto-saved and in my hourly backup folder. The tasks.org file size is only 35 kB. The computer is always on. I am the only one with access to this computer.

System Info:

- OS: gnu/linux
- Emacs: 25.3.1
- Spacemacs: 0.200.10
- Spacemacs branch: master (rev. 4bb4cb46)
- Graphic display: t
- Distribution: spacemacs
- Editing style: vim
- Completion: ivy
- Layers:
(c-c++ emacs-lisp evil-snipe git ivy org shell spell-checking)

On my Spacemacs, auto-save saves to 'original, not the default 'cache. And create-lockfiles is turned off.

From my .spacemacs file:

(defun dotspacemacs/init ()
  "Initialization function.
This function is called at the very startup of Spacemacs initialization
before layers configuration.
You should not put any user code in there besides modifying the variable
  ;; This setq-default sexp is an exhaustive list of all the supported
  ;; spacemacs settings.
   ;; Location where to auto-save files. Possible values are `original' to
   ;; auto-save the file in-place, `cache' to auto-save the file to another
   ;; file stored in the cache directory and `nil' to disable auto-saving.
   ;; (default 'cache)
   dotspacemacs-auto-save-file-location 'original
(defun dotspacemacs/user-config ()
  "Configuration function for user code.
This function is called at the very end of Spacemacs initialization after
layers configuration.
This is the place where most of your configurations should be done. Unless it is
explicitly specified that a variable should be set before a package is loaded,
you should place your code here."
(setq create-lockfiles nil)

There is no #tasks.org# auto-save file as expected.

There is no .#tasks.org lock file as expected.

~/.emacs.d/.cache/auto-save/site/ is empty as expected.

Can disabling lock mess up auto-save after a crash?

Any ideas on how to troubleshoot or reproduce the auto-save failure?

  • Not sure about Spacemacs, GNU Emacs has auto-save-hook which you could customize to log something every time it's called. But this is about as much as I know about auto-saving.
    – wvxvw
    May 1 '18 at 19:48
  • It may behoove you to consider setting up visual indications of whether the buffer has been modified, the date/time of the last manual save, and the date/time of the last auto-save. Then as you go about your daily work over the foreseeable future, you can glance down (e.g., mode-line) and see if the auto-save is occurring. You may also wish to setup some messages that appear in the minibuffer which can even be in color if so desired. Once you see a noticeable gap in the auto-save, you can begin to troubleshoot what you were doing and so forth .... [Manually save after you do lots of work.]
    – lawlist
    May 1 '18 at 19:49
  • @lawlist, good idea. Spacemacs comes with an indicator in the mode-line by default ('*' means modified, '-' means saved). I will get in the habit of checking it every hour.
    – wolfv
    May 1 '18 at 20:35
  • It's not Spacemacs that provides that indicator. It's plain old Emacs, and it has always done so.
    – Drew
    May 1 '18 at 21:29
  • T̶h̶i̶s̶ ̶f̶e̶e̶l̶s̶ ̶l̶i̶k̶e̶ ̶a̶ ̶q̶u̶e̶s̶t̶i̶o̶n̶ ̶b̶e̶t̶t̶e̶r̶ ̶d̶i̶s̶c̶u̶s̶s̶e̶d̶ ̶i̶n̶ ̶S̶p̶a̶c̶e̶m̶a̶c̶s̶ ̶G̶i̶t̶h̶u̶b̶ ̶I̶s̶s̶u̶e̶ ̶i̶f̶ ̶t̶h̶e̶y̶ ̶a̶l̶l̶o̶w̶ ̶d̶i̶s̶c̶u̶s̶s̶i̶o̶n̶,̶ ̶o̶r̶ ̶t̶h̶e̶i̶r̶ ̶r̶e̶c̶o̶m̶m̶e̶n̶d̶e̶d̶ ̶c̶h̶a̶n̶n̶e̶l̶ ̶a̶s̶ ̶y̶o̶u̶'̶d̶ ̶f̶i̶n̶d̶ ̶m̶o̶r̶e̶ ̶S̶p̶a̶c̶e̶m̶a̶c̶s̶ ̶s̶p̶e̶c̶i̶f̶i̶c̶ ̶e̶x̶p̶e̶r̶t̶s̶.̶Nevermind, you've opened an issue already: github.com/syl20bnr/spacemacs/issues/10348
    – hyiltiz
    Feb 27 '20 at 19:51

Your Answer

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

Browse other questions tagged or ask your own question.