Function: split-window-right
split-window-right is an interactive and byte-compiled function
defined in window.el.gz.
Signature
(split-window-right &optional SIZE WINDOW-TO-SPLIT)
Documentation
Split WINDOW-TO-SPLIT into two side-by-side windows.
WINDOW-TO-SPLIT defaults to the selected window if omitted or nil. The newly created window will be to the right of WINDOW-TO-SPLIT and will show the same buffer as WINDOW-TO-SPLIT, if it is a live window, else the buffer shown in the WINDOW-TO-SPLIT's frame's selected window. Return the new window.
If optional argument SIZE is omitted or nil, both windows get the
same width, or close to it. If SIZE is positive, the left-hand
(selected) window gets SIZE columns. If SIZE is negative, the
right-hand (new) window gets -SIZE columns. Here, SIZE includes
the width of the window's scroll bar; if there are no scroll
bars, it includes the width of the divider column to the window's
right, if any. Interactively, SIZE is the prefix numeric argument.
This function has :around advice: treemacs--split-window-advice.
Probably introduced at or before Emacs version 24.1.
Key Bindings
Aliases
Source Code
;; Defined in /usr/src/emacs/lisp/window.el.gz
(defun split-window-right (&optional size window-to-split)
"Split WINDOW-TO-SPLIT into two side-by-side windows.
WINDOW-TO-SPLIT defaults to the selected window if omitted or nil.
The newly created window will be to the right of WINDOW-TO-SPLIT and
will show the same buffer as WINDOW-TO-SPLIT, if it is a live window,
else the buffer shown in the WINDOW-TO-SPLIT's frame's selected window.
Return the new window.
If optional argument SIZE is omitted or nil, both windows get the
same width, or close to it. If SIZE is positive, the left-hand
\(selected) window gets SIZE columns. If SIZE is negative, the
right-hand (new) window gets -SIZE columns. Here, SIZE includes
the width of the window's scroll bar; if there are no scroll
bars, it includes the width of the divider column to the window's
right, if any. Interactively, SIZE is the prefix numeric argument."
(interactive `(,(when current-prefix-arg
(prefix-numeric-value current-prefix-arg))
,(selected-window)))
(let (new-window)
(when (and size (< size 0) (< (- size) window-min-width))
;; `split-window' would not signal an error here.
(error "Size of new window too small"))
(setq new-window (split-window window-to-split size t))
;; Always copy quit-restore parameter in interactive use.
(let ((quit-restore (window-parameter window-to-split 'quit-restore)))
(when quit-restore
(set-window-parameter new-window 'quit-restore quit-restore)))
new-window))