emacs-31 4ccf2584e35: Have 'replace-buffer-in-windows' remove BUFFER-OR-NAME everywhere (Bug#81370)

Martin Rudalics via Mailing list for Emacs changes <[email protected]> Tue, 7 Jul 2026 12:48:13 -0400 (EDT)
Newsgroups gmane.emacs.diffs
Message-ID <[email protected]>
branch: emacs-31
commit 4ccf2584e353ec8541ca2c95145a4a1bc7215716
Author: Martin Rudalics <[email protected]>
Commit: Martin Rudalics <[email protected]>

    Have 'replace-buffer-in-windows' remove BUFFER-OR-NAME everywhere (Bug#81370)
    
    * lisp/window.el (replace-buffer-in-windows): Unrecord
    BUFFER-OR-NAME and thus remove it from the lists of previous and
    next buffers in all live windows regardless of whether they
    currently show BUFFER-OR-NAME or not (Bug#81370).
---
 lisp/window.el | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/lisp/window.el b/lisp/window.el
index ea0de1bad24..06128cf0483 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -5328,18 +5328,18 @@ buffer by itself."
 	      (set-window-dedicated-p window nil)
 	      (if (switch-to-prev-buffer window 'kill)
                   (and dedicated-side (set-window-dedicated-p window 'side))
-		(window--delete window nil 'kill))))))
-
-	(when (window-live-p window)
-	  ;; If the fourth elements of the 'quit-restore' or
-	  ;; 'quit-restore-prev' parameters equal BUFFER, these
-	  ;; parameters become useless - in 'quit-restore-window' the
-	  ;; fourth element must equal the buffer of WINDOW in order to
-	  ;; use that parameter.  If BUFFER is mentioned in the second
-	  ;; element of the parameter, 'quit-restore-window' cannot
-	  ;; possibly show BUFFER instead; so this parameter becomes
-	  ;; useless too.
-	  (unrecord-window-buffer window buffer t))))))
+		(window--delete window nil 'kill)))))))
+
+      (when (window-live-p window)
+	;; If the fourth elements of the 'quit-restore' or
+	;; 'quit-restore-prev' parameters equal BUFFER, these
+	;; parameters become useless - in 'quit-restore-window' the
+	;; fourth element must equal the buffer of WINDOW in order to
+	;; use that parameter.  If BUFFER is mentioned in the second
+	;; element of the parameter, 'quit-restore-window' cannot
+	;; possibly show BUFFER instead; so this parameter becomes
+	;; useless too.
+	(unrecord-window-buffer window buffer t)))))
 
 (defcustom quit-window-hook nil
   "Hook run before performing any other actions in the `quit-window' command."