Subject: Re: bug#21612: 24.5; Configuration variable to delete auto-save file when intentionally killing buffer

From: Lars Ingebrigtsen <[email-masked]>
Date: Wed, 18 Aug 2021 14:45:21 +0200

Argh!

I now implemented this...  but then I discovered the
delete-auto-save-files variable, which seems to be providing just what
was requested here, just about.

And it worked in the initial revision:

commit 1ab256cb9997cf15983abc63310cdf32f0533bca
Author:     Roland McGrath <[email-masked]>
AuthorDate: Mon Jul 15 21:27:11 1991 +0000

    Initial revision

diff --git a/src/buffer.c b/src/buffer.c
--- /dev/null
+++ b/src/buffer.c
@@ -0,0 +678,9 @@
+  /* Delete any auto-save file.  */
+  if (XTYPE (b->auto_save_file_name) == Lisp_String)
+    {
+      Lisp_Object tem;
+      tem = Fsymbol_value (intern ("delete-auto-save-files"));
+      if (! NULL (tem))
+	unlink (XSTRING (b->auto_save_file_name)->data);
+    }
+

But Richard changed this in 2001:

commit 9cf712eb57c0a1fef56487508e89d08c91f98db1
Author:     Richard M. Stallman <[email-masked]>
AuthorDate: Tue Nov 6 04:48:15 2001 +0000

    (Fkill_buffer): Don't delete auto save file if buffer is modified.

diff --git a/src/buffer.c b/src/buffer.c
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1370,11 +1370,13 @@
-  /* Delete any auto-save file, if we saved it in this session.  */
+  /* Delete any auto-save file, if we saved it in this session.
+     But not if the buffer is modified.  */
   if (STRINGP (b->auto_save_file_name)
       && b->auto_save_modified != 0
-      && BUF_SAVE_MODIFF (b) < b->auto_save_modified)
+      && BUF_SAVE_MODIFF (b) < b->auto_save_modified
+      && BUF_SAVE_MODIFF (b) < BUF_MODIFF (b))
     {
       Lisp_Object tem;
       tem = Fsymbol_value (intern ("delete-auto-save-files"));
       if (! NILP (tem))
 	internal_delete_file (b->auto_save_file_name);
     }
 
No now this option is basically pointless (when killing buffers) -- the
only reason we'd want to delete an auto-save file is if the buffer is
modified.  Otherwise there won't be an auto-save file.  (Except when
it's made by a different Emacs, and in that case, we really shouldn't be
deleting it anyway.)

The commit message or the comments don't explain what the reasoning
behind changing the semantics here were.

Richard, do you have any recollection why you made these changes 20
years ago?  They seem to make the delete-auto-save-files variable in a
kill-buffer context pointless.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no