1

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:
elisp
(c-c++ emacs-lisp evil-snipe git ivy org shell spell-checking)
- System configuration features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND DBUS GCONF GSETTINGS NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 MODULES XWIDGETS

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
values."
  ;; This setq-default sexp is an exhaustive list of all the supported
  ;; spacemacs settings.
  (setq-default
...
   ;; 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

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.