Subject: Re: bug#33669: 26.1; Buffer-menu-mode bad UX

From: Eli Zaretskii <[email-masked]>
Date: Sat, 08 Dec 2018 13:07:42 +0200

> From: Devon Sean McCullough <[email-masked]>
> Date: Sat, 8 Dec 2018 10:06:48 +0800
> 
> When Buffer-menu-execute asks
> 
> 	Buffer foo modified; kill anyway? (yes or no)
> 
> and the reply is no,
> that line is removed anyway, deceiving the user
> by making the buffer menu incorrect.
> 
> The user will promptly seek out such buffers — but they disappeared,
> giving the distressing wrong impression that they were killed anyway.

Thanks for reporting this.  Does the patch below give good results?

diff --git a/lisp/buff-menu.el b/lisp/buff-menu.el
index bc1288a..95746b3 100644
--- a/lisp/buff-menu.el
+++ b/lisp/buff-menu.el
@@ -476,9 +476,10 @@ Buffer-menu-execute
 			 (tabulated-list-set-col 2 " " t))
 		     (error (warn "Error saving %s" buffer))))
 		 (if delete
-		     (unless (eq buffer (current-buffer))
-		       (kill-buffer buffer)
-		       (tabulated-list-delete-entry))
+		     (if (and (not (eq buffer (current-buffer)))
+                              (kill-buffer buffer))
+                         (tabulated-list-delete-entry)
+                       (forward-line 1))
 		   (forward-line 1)))))))))
 
 (defun Buffer-menu-select ()