mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-30 08:09:04 +00:00
Add new functions for splitting the root window
* lisp/window.el (split-window-right): Add optional argument to control which window is split (previously, would only split selected window). Update docstring. * doc/lispref/windows.texi (Splitting Windows): Update docs for `split-window-right'. * lisp/window.el (split-window-below): Add optional argument to control which window is split (previously, would only split selected window). Update docstring. * doc/lispref/windows.texi (Splitting Windows): Update docs for `split-window-below'. * lisp/window.el (ctl-x-map): Bind `split-root-window-right' to 9 in ctl-x-map. This is consistent with binding other window-splitting operations to numbers in this map. * lisp/window.el (ctl-x-map): Bind `split-root-window-below' to 7 in ctl-x-map. This is consistent with binding other window-splitting operations to numbers in this map. * lisp/window.el (split-root-window-right): New function to split whole frame. * doc/lispref/windows.texi (Splitting Windows): Add documentation for `split-root-window-right'. * lisp/window.el (split-root-window-below): New function to split whole frame. * doc/lispref/windows.texi (Splitting Windows): Add documentation for `split-root-window-below' (bug#56791).
This commit is contained in:
parent
21c725dfe0
commit
6a2ee981c3
@ -1472,20 +1472,36 @@ the new root window.
|
||||
For interactive use, Emacs provides two commands which always split
|
||||
the selected window. These call @code{split-window} internally.
|
||||
|
||||
@deffn Command split-window-right &optional size
|
||||
This function splits the selected window into two side-by-side
|
||||
windows, putting the selected window on the left. If @var{size} is
|
||||
positive, the left window gets @var{size} columns; if @var{size} is
|
||||
@deffn Command split-window-right &optional size window-to-split
|
||||
This function splits the window @var{window-to-split} into two
|
||||
side-by-side windows, putting @var{window-to-split} on the left.
|
||||
@var{window-to-split} defaults to the selected window. If @var{size}
|
||||
is positive, the left window gets @var{size} columns; if @var{size} is
|
||||
negative, the right window gets @minus{}@var{size} columns.
|
||||
@end deffn
|
||||
|
||||
@deffn Command split-window-below &optional size
|
||||
This function splits the selected window into two windows, one above
|
||||
the other, leaving the upper window selected. If @var{size} is
|
||||
positive, the upper window gets @var{size} lines; if @var{size} is
|
||||
@deffn Command split-window-below &optional size window-to-split
|
||||
This function splits the window @var{window-to-split} into two
|
||||
windows, one above the other, leaving the upper window selected.
|
||||
@var{window-to-split} defaults to the selected window. If @var{size}
|
||||
is positive, the upper window gets @var{size} lines; if @var{size} is
|
||||
negative, the lower window gets @minus{}@var{size} lines.
|
||||
@end deffn
|
||||
|
||||
@deffn Command split-root-window-below &optional size
|
||||
This function splits the whole frame in two. The current window
|
||||
configuration is retained on the top, and a new window is created
|
||||
below, taking up the whole width of the frame. @var{size} is treated
|
||||
as by @code{split-window-below}.
|
||||
@end deffn
|
||||
|
||||
@deffn Command split-root-window-right &optional size
|
||||
This function splits the whole frame in two. The current window
|
||||
configuration is retained on the left, and a new window is created on
|
||||
the right, taking up the whole height of the frame. @var{size} is treated
|
||||
as by @code{split-window-right}.
|
||||
@end deffn
|
||||
|
||||
@defopt split-window-keep-point
|
||||
If the value of this variable is non-@code{nil} (the default),
|
||||
@code{split-window-below} behaves as described above.
|
||||
|
5
etc/NEWS
5
etc/NEWS
@ -943,6 +943,11 @@ non-nil in 'special-mode' and its derivatives.
|
||||
|
||||
** Windows
|
||||
|
||||
+++
|
||||
*** New commands 'split-root-window-below' and 'split-root-window-right'.
|
||||
These commands split the root window in to, and are are bound to 'C-x
|
||||
7' and 'C-x 9' respectively.
|
||||
|
||||
+++
|
||||
*** New user option 'display-buffer-avoid-small-windows'.
|
||||
If non-nil, this should be a window height, a number. Windows smaller
|
||||
|
@ -5672,9 +5672,9 @@ the original point in both windows."
|
||||
:type 'boolean
|
||||
:group 'windows)
|
||||
|
||||
(defun split-window-below (&optional size)
|
||||
"Split the selected window into two windows, one above the other.
|
||||
The selected window is above. The newly split-off window is
|
||||
(defun split-window-below (&optional size window-to-split)
|
||||
"Split WINDOW-TO-SPLIT into two windows, one above the other.
|
||||
WINDOW-TO-SPLIT is above. The newly split-off window is
|
||||
below and displays the same buffer. Return the new window.
|
||||
|
||||
If optional argument SIZE is omitted or nil, both windows get the
|
||||
@ -5683,22 +5683,22 @@ same height, or close to it. If SIZE is positive, the upper
|
||||
lower (new) window gets -SIZE lines.
|
||||
|
||||
If the variable `split-window-keep-point' is non-nil, both
|
||||
windows get the same value of point as the selected window.
|
||||
windows get the same value of point as the WINDOW-TO-SPLIT.
|
||||
Otherwise, the window starts are chosen so as to minimize the
|
||||
amount of redisplay; this is convenient on slow terminals."
|
||||
(interactive "P")
|
||||
(let ((old-window (selected-window))
|
||||
(old-point (window-point))
|
||||
(size (and size (prefix-numeric-value size)))
|
||||
(interactive `(,(when current-prefix-arg
|
||||
(prefix-numeric-value current-prefix-arg))
|
||||
,(selected-window)))
|
||||
(let ((old-point (window-point))
|
||||
moved-by-window-height moved new-window bottom)
|
||||
(when (and size (< size 0) (< (- size) window-min-height))
|
||||
;; `split-window' would not signal an error here.
|
||||
(error "Size of new window too small"))
|
||||
(setq new-window (split-window nil size))
|
||||
(setq new-window (split-window window-to-split size))
|
||||
(unless split-window-keep-point
|
||||
(with-current-buffer (window-buffer)
|
||||
(with-current-buffer (window-buffer window-to-split)
|
||||
;; Use `save-excursion' around vertical movements below
|
||||
;; (Bug#10971). Note: When the selected window's buffer has a
|
||||
;; (Bug#10971). Note: When WINDOW-TO-SPLIT's buffer has a
|
||||
;; header line, up to two lines of the buffer may not show up
|
||||
;; in the resulting configuration.
|
||||
(save-excursion
|
||||
@ -5713,24 +5713,31 @@ amount of redisplay; this is convenient on slow terminals."
|
||||
(setq bottom (point)))
|
||||
(and moved-by-window-height
|
||||
(<= bottom (point))
|
||||
(set-window-point old-window (1- bottom)))
|
||||
(set-window-point window-to-split (1- bottom)))
|
||||
(and moved-by-window-height
|
||||
(<= (window-start new-window) old-point)
|
||||
(set-window-point new-window old-point)
|
||||
(select-window new-window))))
|
||||
;; Always copy quit-restore parameter in interactive use.
|
||||
(let ((quit-restore (window-parameter old-window 'quit-restore)))
|
||||
(let ((quit-restore (window-parameter window-to-split 'quit-restore)))
|
||||
(when quit-restore
|
||||
(set-window-parameter new-window 'quit-restore quit-restore)))
|
||||
new-window))
|
||||
|
||||
(defalias 'split-window-vertically 'split-window-below)
|
||||
|
||||
(defun split-window-right (&optional size)
|
||||
"Split the selected window into two side-by-side windows.
|
||||
The selected window is on the left. The newly split-off window
|
||||
is on the right and displays the same buffer. Return the new
|
||||
window.
|
||||
(defun split-root-window-below (&optional size)
|
||||
"Split root window of current frame in two.
|
||||
The current window configuration is retained in the top window,
|
||||
the lower window takes up the whole width of the frame. SIZE is
|
||||
handled as in `split-window-below'."
|
||||
(interactive "P")
|
||||
(split-window-below size (frame-root-window)))
|
||||
|
||||
(defun split-window-right (&optional size window-to-split)
|
||||
"Split WINDOW-TO-SPLIT into two side-by-side windows.
|
||||
WINDOW-TO-SPLIT is on the left. The newly split-off window is on
|
||||
the right and displays the same buffer. 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
|
||||
@ -5739,21 +5746,30 @@ 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."
|
||||
(interactive "P")
|
||||
(let ((old-window (selected-window))
|
||||
(size (and size (prefix-numeric-value size)))
|
||||
new-window)
|
||||
(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 nil size t))
|
||||
(setq new-window (split-window window-to-split size t))
|
||||
;; Always copy quit-restore parameter in interactive use.
|
||||
(let ((quit-restore (window-parameter old-window 'quit-restore)))
|
||||
(let ((quit-restore (window-parameter window-to-split 'quit-restore)))
|
||||
(when quit-restore
|
||||
(set-window-parameter new-window 'quit-restore quit-restore)))
|
||||
new-window))
|
||||
|
||||
(defalias 'split-window-horizontally 'split-window-right)
|
||||
|
||||
(defun split-root-window-right (&optional size)
|
||||
"Split root window of current frame into two side-by-side windows.
|
||||
The current window configuration is retained within the left
|
||||
window, and a new window is created on the right, taking up the
|
||||
whole height of the frame. SIZE is treated as by
|
||||
`split-window-right'."
|
||||
(interactive "P")
|
||||
(split-window-right size (frame-root-window)))
|
||||
|
||||
;;; Balancing windows.
|
||||
|
||||
@ -10564,6 +10580,8 @@ displaying that processes's buffer."
|
||||
(define-key ctl-x-map "{" 'shrink-window-horizontally)
|
||||
(define-key ctl-x-map "-" 'shrink-window-if-larger-than-buffer)
|
||||
(define-key ctl-x-map "+" 'balance-windows)
|
||||
(define-key ctl-x-map "7" 'split-root-window-below)
|
||||
(define-key ctl-x-map "9" 'split-root-window-right)
|
||||
(define-key ctl-x-4-map "0" 'kill-buffer-and-window)
|
||||
(define-key ctl-x-4-map "1" 'same-window-prefix)
|
||||
(define-key ctl-x-4-map "4" 'other-window-prefix)
|
||||
|
Loading…
Reference in New Issue
Block a user