From c3d3f5fe6b4ffb32ccd846ec8031859a960e50d9 Mon Sep 17 00:00:00 2001 From: Martin Rudalics Date: Sun, 23 Jun 2024 10:26:57 +0200 Subject: [PATCH] Fix a bug in 'switch-to-buffer' * lisp/window.el (switch-to-buffer): When asked to switch to the buffer of the selected window, 'switch-to-buffer-obey-display-actions' is non-nil and 'pop-to-buffer' uses the selected window, don't try to restore window start and point from 'window-prev-buffers' (Bug#71616). (cherry picked from commit 5f8a9cd4b6f4441c158a750ad7c5b937b559edd4) --- lisp/window.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lisp/window.el b/lisp/window.el index e25704f4386..27833c4e4cd 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -9180,9 +9180,14 @@ Return the buffer switched to." (pop-to-buffer buffer norecord))) (t (when switch-to-buffer-obey-display-actions - (let ((selected-window (selected-window))) + (let* ((selected-window (selected-window)) + (old-window-buffer (window-buffer selected-window))) (pop-to-buffer-same-window buffer norecord) - (when (eq (selected-window) selected-window) + ;; Do not ask for setting start and point when showing the + ;; same buffer in the old selected window (Bug#71616). + (when (and (eq (selected-window) selected-window) + (not (eq (window-buffer selected-window) + old-window-buffer))) (setq set-window-start-and-point t)))) (when set-window-start-and-point -- 2.39.2