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

From: Eli Zaretskii <[email-masked]>
Date: Wed, 18 Aug 2021 16:34:14 +0300

> From: Lars Ingebrigtsen <[email-masked]>
> Cc: [email-masked],  [email-masked], Richard M. Stallman <[email-masked]>
> Date: Wed, 18 Aug 2021 14:45:21 +0200
> 
> 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.)

We could make that variable have a third value, which would then
override the above logic, no?

> 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.

I guess the reason was the fear of losing edits, as discussed
previously.  But if the user explicitly wants to take those risks,
it's okay, especially if we ask for confirmation.