Function: pop-to-buffer-same-window
pop-to-buffer-same-window is a byte-compiled function defined in
window.el.gz.
Signature
(pop-to-buffer-same-window BUFFER &optional NORECORD)
Documentation
Select buffer BUFFER in some window, preferably the same one.
BUFFER may be a buffer, a string (a buffer name), or nil. If it is a string not naming an existent buffer, create a buffer with that name. If BUFFER is nil, choose some other buffer. Return the buffer.
Optional argument NORECORD, if non-nil means do not put this buffer at the front of the list of recently selected ones.
Unlike pop-to-buffer, this function prefers using the selected
window over popping up a new window or frame. Specifically, if
the selected window is neither a minibuffer window (as reported
by window-minibuffer-p), nor is dedicated to another buffer
(see window-dedicated-p), BUFFER will be displayed in the
currently selected window; otherwise it will be displayed in
another window.
Probably introduced at or before Emacs version 26.1.
Aliases
org-pop-to-buffer-same-window (obsolete since 9.0)
Source Code
;; Defined in /usr/src/emacs/lisp/window.el.gz
(defun pop-to-buffer-same-window (buffer &optional norecord)
"Select buffer BUFFER in some window, preferably the same one.
BUFFER may be a buffer, a string (a buffer name), or nil. If it
is a string not naming an existent buffer, create a buffer with
that name. If BUFFER is nil, choose some other buffer. Return
the buffer.
Optional argument NORECORD, if non-nil means do not put this
buffer at the front of the list of recently selected ones.
Unlike `pop-to-buffer', this function prefers using the selected
window over popping up a new window or frame. Specifically, if
the selected window is neither a minibuffer window (as reported
by `window-minibuffer-p'), nor is dedicated to another buffer
(see `window-dedicated-p'), BUFFER will be displayed in the
currently selected window; otherwise it will be displayed in
another window."
(pop-to-buffer buffer display-buffer--same-window-action norecord))