Variable: switch-to-buffer-preserve-window-point
switch-to-buffer-preserve-window-point is a customizable variable
defined in window.el.gz.
Value
t
Documentation
If non-nil, switch-to-buffer tries to preserve window-point.
If this is nil, switch-to-buffer displays the buffer at that
buffer's point. If this is already-displayed, it tries to
display the buffer at its previous position in the selected
window, provided the buffer is currently displayed in some other
window on any visible or iconified frame. If this is t, it
unconditionally tries to display the buffer at its previous
position in the selected window.
This variable is ignored if the buffer is already displayed in
the selected window or never appeared in it before, or if
switch-to-buffer calls pop-to-buffer to display the buffer,
or non-nil switch-to-buffer-obey-display-actions displays it
in another window.
This variable was added, or its default value changed, in Emacs 26.1.
Probably introduced at or before Emacs version 24.3.
Source Code
;; Defined in /usr/src/emacs/lisp/window.el.gz
(defcustom switch-to-buffer-preserve-window-point t
"If non-nil, `switch-to-buffer' tries to preserve `window-point'.
If this is nil, `switch-to-buffer' displays the buffer at that
buffer's `point'. If this is `already-displayed', it tries to
display the buffer at its previous position in the selected
window, provided the buffer is currently displayed in some other
window on any visible or iconified frame. If this is t, it
unconditionally tries to display the buffer at its previous
position in the selected window.
This variable is ignored if the buffer is already displayed in
the selected window or never appeared in it before, or if
`switch-to-buffer' calls `pop-to-buffer' to display the buffer,
or non-nil `switch-to-buffer-obey-display-actions' displays it
in another window."
:type '(choice
(const :tag "Never" nil)
(const :tag "If already displayed elsewhere" already-displayed)
(const :tag "Always" t))
:group 'windows
:version "26.1")