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

From: martin rudalics <[email-masked]>
Date: Sat, 19 Feb 2022 18:07:03 +0100

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

martin