Subject: Re: bug#5314: 23.1; Inconsistent treatment of auto-save files

From: Stefan Monnier <[email-masked]>
Date: Tue, 05 Jan 2010 14:28:10 -0500

> Hi, I am a maintainer of VM.

[ Always glad to see people from my field participate in Emacs
development. ]

> 1. If there is an old auto-save file, and you visit the file, make
> some changes and kill the buffer without saving, then the old
> auto-save file is silently deleted.

That's bad!
But I cannot reproduce it here:

   % emacs23 -Q ~/tmp/foo.test
   [type...type...type...]
   % l ~/tmp/\#foo.test\#
   -rw-r--r-- 1 monnier monnier 259 jan  5 14:06 /home/monnier/tmp/#foo.test#
   [kill Emacs]
   % emacs23 -Q ~/tmp/foo.test
   [type a little something to modify the buffer]
   C-x k RET
   % l ~/tmp/\#foo.test\#
   -rw-r--r-- 1 monnier monnier 259 jan  5 14:06 /home/monnier/tmp/#foo.test#

Could you try and provide a more precise recipe?

Or maybe the old auto-save file was overwritten by a new auto-save file
before you killed the buffer?  It does sound like a likely reason.
And indeed it's a problem, tho I'm not sure how to best fix it:
- We could try and rename the old auto-save file before saving the new one
  and let recover-file choose among the various possible auto-save files.
- Maybe make it harder for the user to start modifying the buffer when
  there's an old auto-save file (e.g. make the buffer read-only and
  warn/prompt when the user tries to C-x C-q).
- Prompt just before saving the new auto-save file so the user
  gets a chance to prevent the old auto-save from being overwritten.
- Disable auto-saving when there's an old auto-save file (together with
  an appropriate warning, in the same way as we disable auto-saving when
  the file/buffer got much smaller).

> 2. The inline documentation for delete-auto-save-file-if-necessary
> says "Normally delete only if the file was written by this Emacs since
> the last real save".  This gives one the impression that Emacs is
> keeping track of when the last real save was done, but in reality it
> only seems to be checking the buffer-modified-p status.  If so, a more
> accurate way to word the doc string might be

If the behavior doesn't match the docstring, I think the problem would
be in the code rather than in the doc.  AFAICT the code doesn't just
check buffer-modified-p but really checks whether the current buffer has
been auto-saved.

> If the buffer-modified-p is nil, then even recent auto-save files seem
> to be left lying around.  This is the opposite problem of that in
> point 1.

I cannot reproduce this either.  Do you have a recipe?

> 4. The Elisp manual descriptions for
> delete-auto-save-file-if-necessary and
> recent-auto-save-p need to be similarly modified.

Just to be sure: do you want to change the doc because you don't like
the behavior it describes, or because it doesn't match the behavior
you see?

We clearly would rather fix the code to match the doc if the doc
describes the behavior we want.

        Stefan