Subject: bug#32214: [PATCH] 'message-kill-buffer': fix backup delete question

From: Sven Willner <[email-masked]>
Date: Thu, 19 Jul 2018 19:16:06 +0200

good idea!

have incorporated that in the appended patch.
also, the 'when' part should only include the actual deletion of 
the backup file
>  	(ignore-errors
>  	  (delete-file auto-save-file-name))
rather than also draft diassociation
>  	(let ((message-draft-article draft-article))
>  	  (message-disassociate-draft)))
also fixed in the updated patch.

Sven

>From 754d5c02f6b8c47c59fdd88e3c71f1a74761591a Mon Sep 17 00:00:00 2001
From: Sven Willner <[email-masked]>
Date: Thu, 19 Jul 2018 13:20:26 +0200
Subject: [PATCH] 'message-kill-buffer': fix backup delete question

Before 'message-kill-buffer' would ask to delete backup file if draft has been
saved regardless if a backup file has actually been created. Now only ask if
a backup file exists.

Copyright-paperwork-exempt: yes
---
 etc/NEWS             |  3 +++
 lisp/gnus/message.el | 42 +++++++++++++++++++++---------------------
 2 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index f30ab69823..55997b1bf2 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -562,6 +562,9 @@ GnuTLS manual) is recommended instead.
 
 ** Message
 
+---
+*** 'message-kill-buffer' asks to delete backup file only if one actually exists
+
 +++
 *** Messages can now be systematically encrypted
 when the PGP keyring contains a public key for every recipient.  To
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index dde9c28656..e830d7f239 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -4085,23 +4085,23 @@ Instead, just auto-save the buffer and then bury it."
 	  (modified (buffer-modified-p)))
       (setq buffer-file-name nil)
       (kill-buffer (current-buffer))
-      (when (and (or (and auto-save-file-name
-			  (file-exists-p auto-save-file-name))
-		     (and file-name
-			  (file-exists-p file-name)))
-		 (progn
-		   ;; If the message buffer has lived in a dedicated window,
-		   ;; `kill-buffer' has killed the frame.  Thus the
-		   ;; `yes-or-no-p' may show up in a lowered frame.  Make sure
-		   ;; that the user can see the question by raising the
-		   ;; current frame:
-		   (raise-frame)
-		   (yes-or-no-p (format "Remove the backup file%s? "
-					(if modified " too" "")))))
-	(ignore-errors
-	  (delete-file auto-save-file-name))
-	(let ((message-draft-article draft-article))
-	  (message-disassociate-draft)))
+      (when (and auto-save-file-name
+                 (file-exists-p auto-save-file-name)
+                 file-name
+                 (file-exists-p file-name)
+                 (progn
+                   ;; If the message buffer has lived in a dedicated window,
+                   ;; `kill-buffer' has killed the frame.  Thus the
+                   ;; `yes-or-no-p' may show up in a lowered frame.  Make sure
+                   ;; that the user can see the question by raising the
+                   ;; current frame:
+                   (raise-frame)
+                   (yes-or-no-p (format "Remove the backup file%s? "
+                                        (if modified " too" "")))))
+	    (ignore-errors
+	      (delete-file auto-save-file-name)))
+	  (let ((message-draft-article draft-article))
+	    (message-disassociate-draft))
       (message-do-actions actions))))
 
 (defun message-bury (buffer)
--
2.18.0

Robert Pluim <[email-masked]> writes:

> Sven Willner <[email-masked]> writes:
>
>>  	(ignore-errors
>>  	  (delete-file auto-save-file-name))
>>  	(let ((message-draft-article draft-article))
>>  	  (message-disassociate-draft)))
>> + (when (and (and auto-save-file-name
>> + (file-exists-p auto-save-file-name))
>> + (and file-name
>> + (file-exists-p file-name))
>
> (when (and auto-save-file-name
>            (file-exists-p auto-save-file-name)
>            file-name
>            (file-exists-p file-name))
>
> perhaps? You could even drop the 'when'.
>
> Robert