From: Zajcev Evgeny Date: Tue, 1 Dec 2020 08:33:05 +0000 (+0100) Subject: Fix use of 'switch-to-buffer-preserve-window-point' X-Git-Tag: emacs-28.0.90~4984 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=8a27b0cad7dcffd0af9b3b38028ac12276a85c1b;p=emacs.git Fix use of 'switch-to-buffer-preserve-window-point' * lisp/window.el (switch-to-buffer): Respect buffer local value of 'switch-to-buffer-preserve-window-point' variable. --- diff --git a/lisp/window.el b/lisp/window.el index 82976bf8364..daa5c67df8b 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -8566,13 +8566,13 @@ Return the buffer switched to." (when set-window-start-and-point (let* ((entry (assq buffer (window-prev-buffers))) - (displayed (and (eq switch-to-buffer-preserve-window-point - 'already-displayed) + (preserve-win-point + (buffer-local-value 'switch-to-buffer-preserve-window-point + buffer)) + (displayed (and (eq preserve-win-point 'already-displayed) (get-buffer-window buffer 0)))) (set-window-buffer nil buffer) - (when (and entry - (or (eq switch-to-buffer-preserve-window-point t) - displayed)) + (when (and entry (or (eq preserve-win-point t) displayed)) ;; Try to restore start and point of buffer in the selected ;; window (Bug#4041). (set-window-start (selected-window) (nth 1 entry) t)