Function: switch-to-buffer-other-window

switch-to-buffer-other-window is an interactive and byte-compiled function defined in window.el.gz.

Signature

(switch-to-buffer-other-window BUFFER-OR-NAME &optional NORECORD)

Documentation

Select the buffer specified by BUFFER-OR-NAME in another window.

BUFFER-OR-NAME may be a buffer, a string (a buffer name), or nil. Return the buffer switched to.

If called interactively, read the buffer name using read-buffer. The variable confirm-nonexistent-file-or-buffer(var)/confirm-nonexistent-file-or-buffer(fun) determines whether to request confirmation before creating a new buffer. See read-buffer for features related to input and completion of buffer names.

If BUFFER-OR-NAME is a string and does not identify an existing buffer, create a new buffer with that name. If BUFFER-OR-NAME is nil, switch to the buffer returned by other-buffer.

Optional second argument NORECORD non-nil means do not put this buffer at the front of the list of recently selected ones.

This uses the function display-buffer as a subroutine; see its documentation for additional customization information. If this command needs to split the current window, it by default obeys the user options split-height-threshold and split-width-threshold, when it decides whether to split the window horizontally or vertically.

View in manual

Probably introduced at or before Emacs version 17.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/window.el.gz
(defun switch-to-buffer-other-window (buffer-or-name &optional norecord)
  "Select the buffer specified by BUFFER-OR-NAME in another window.
BUFFER-OR-NAME may be a buffer, a string (a buffer name), or
nil.  Return the buffer switched to.

If called interactively, read the buffer name using `read-buffer'.
The variable `confirm-nonexistent-file-or-buffer' determines
whether to request confirmation before creating a new buffer.
See `read-buffer' for features related to input and completion
of buffer names.

If BUFFER-OR-NAME is a string and does not identify an existing
buffer, create a new buffer with that name.  If BUFFER-OR-NAME is
nil, switch to the buffer returned by `other-buffer'.

Optional second argument NORECORD non-nil means do not put this
buffer at the front of the list of recently selected ones.

This uses the function `display-buffer' as a subroutine; see its
documentation for additional customization information.
If this command needs to split the current window, it by default obeys
the user options `split-height-threshold' and `split-width-threshold',
when it decides whether to split the window horizontally or vertically."
  (interactive
   (list (read-buffer-to-switch "Switch to buffer in other window: ")))
  (let ((pop-up-windows t))
    (pop-to-buffer buffer-or-name t norecord)))