Subject: Re: bug#53910: [External] : bug#53910: 29.0.50; context-menu-mode breaks help in read-only buffers

From: Eli Zaretskii <[email-masked]>
Date: Sat, 19 Feb 2022 19:22:36 +0200

> Date: Sat, 19 Feb 2022 18:07:03 +0100
> Cc: [email-masked], [email-masked], [email-masked],
>  [email-masked], [email-masked]
> From: martin rudalics <[email-masked]>
> 
>  > What exactly do you mean by "interactive use only"?  Several commands
>  > invoke bury-buffer as part of their job -- or do you consider that to
>  > be "interactive use" as well?
> 
> No.  Consider the following two forms:
> 
> (defun foo (&optional buffer)
>    (interactive)
>    (let ((buffer (window-normalize-buffer buffer)))
>      (if (or (and (window-next-sibling)
> 		 (eq (window-buffer (window-next-sibling)) buffer))
> 	    (and (window-prev-sibling)
> 		 (eq (window-buffer (window-prev-sibling)) buffer)))
> 	(bury-buffer buffer)
>        (kill-buffer buffer))))
> 
> (defun foo (&optional buffer)
>    (interactive)
>    (if (let ((buffer (window-normalize-buffer buffer)))
> 	(or (and (window-next-sibling)
> 		 (eq (window-buffer (window-next-sibling)) buffer))
> 	    (and (window-prev-sibling)
> 		 (eq (window-buffer (window-prev-sibling)) buffer))))
>        (bury-buffer buffer)
>      (kill-buffer buffer)))
> 
> If, after C-x 2, I do M-x foo, the first will leave the windows' buffers
> unchanged while the second will show another buffer in the selected
> window.  So my conclusion is to never use 'bury-buffer' in Lisp code.

That bury-buffer can be mis-used or abused doesn't mean it should not
be used correctly, especially since we do that in many places.
Moreover, bury-buffer does little besides bury-buffer-internal, so I
still don't understand the emotional reaction.