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).
This commit is contained in:
Martin Rudalics 2026-07-07 18:47:44 +02:00
parent 0b30e299f5
commit 4ccf2584e3

View file

@ -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))))))
(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))))))
(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."