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
|
For interactive use, Emacs provides two commands which always split
|
||||||
the selected window. These call @code{split-window} internally.
|
the selected window. These call @code{split-window} internally.
|
||||||
|
|
||||||
@deffn Command split-window-right &optional size
|
@deffn Command split-window-right &optional size window-to-split
|
||||||
This function splits the selected window into two side-by-side
|
This function splits the window @var{window-to-split} into two
|
||||||
windows, putting the selected window on the left. If @var{size} is
|
side-by-side windows, putting @var{window-to-split} on the left.
|
||||||
positive, the left window gets @var{size} columns; if @var{size} is
|
@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.
|
negative, the right window gets @minus{}@var{size} columns.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@deffn Command split-window-below &optional size
|
@deffn Command split-window-below &optional size window-to-split
|
||||||
This function splits the selected window into two windows, one above
|
This function splits the window @var{window-to-split} into two
|
||||||
the other, leaving the upper window selected. If @var{size} is
|
windows, one above the other, leaving the upper window selected.
|
||||||
positive, the upper window gets @var{size} lines; if @var{size} is
|
@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.
|
negative, the lower window gets @minus{}@var{size} lines.
|
||||||
@end deffn
|
@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
|
@defopt split-window-keep-point
|
||||||
If the value of this variable is non-@code{nil} (the default),
|
If the value of this variable is non-@code{nil} (the default),
|
||||||
@code{split-window-below} behaves as described above.
|
@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
|
** 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'.
|
*** New user option 'display-buffer-avoid-small-windows'.
|
||||||
If non-nil, this should be a window height, a number. Windows smaller
|
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
|
:type 'boolean
|
||||||
:group 'windows)
|
:group 'windows)
|
||||||
|
|
||||||
(defun split-window-below (&optional size)
|
(defun split-window-below (&optional size window-to-split)
|
||||||
"Split the selected window into two windows, one above the other.
|
"Split WINDOW-TO-SPLIT into two windows, one above the other.
|
||||||
The selected window is above. The newly split-off window is
|
WINDOW-TO-SPLIT is above. The newly split-off window is
|
||||||
below and displays the same buffer. Return the new window.
|
below and displays the same buffer. Return the new window.
|
||||||
|
|
||||||
If optional argument SIZE is omitted or nil, both windows get the
|
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.
|
lower (new) window gets -SIZE lines.
|
||||||
|
|
||||||
If the variable `split-window-keep-point' is non-nil, both
|
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
|
Otherwise, the window starts are chosen so as to minimize the
|
||||||
amount of redisplay; this is convenient on slow terminals."
|
amount of redisplay; this is convenient on slow terminals."
|
||||||
(interactive "P")
|
(interactive `(,(when current-prefix-arg
|
||||||
(let ((old-window (selected-window))
|
(prefix-numeric-value current-prefix-arg))
|
||||||
(old-point (window-point))
|
,(selected-window)))
|
||||||
(size (and size (prefix-numeric-value size)))
|
(let ((old-point (window-point))
|
||||||
moved-by-window-height moved new-window bottom)
|
moved-by-window-height moved new-window bottom)
|
||||||
(when (and size (< size 0) (< (- size) window-min-height))
|
(when (and size (< size 0) (< (- size) window-min-height))
|
||||||
;; `split-window' would not signal an error here.
|
;; `split-window' would not signal an error here.
|
||||||
(error "Size of new window too small"))
|
(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
|
(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
|
;; 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
|
;; header line, up to two lines of the buffer may not show up
|
||||||
;; in the resulting configuration.
|
;; in the resulting configuration.
|
||||||
(save-excursion
|
(save-excursion
|
||||||
@ -5713,24 +5713,31 @@ amount of redisplay; this is convenient on slow terminals."
|
|||||||
(setq bottom (point)))
|
(setq bottom (point)))
|
||||||
(and moved-by-window-height
|
(and moved-by-window-height
|
||||||
(<= bottom (point))
|
(<= bottom (point))
|
||||||
(set-window-point old-window (1- bottom)))
|
(set-window-point window-to-split (1- bottom)))
|
||||||
(and moved-by-window-height
|
(and moved-by-window-height
|
||||||
(<= (window-start new-window) old-point)
|
(<= (window-start new-window) old-point)
|
||||||
(set-window-point new-window old-point)
|
(set-window-point new-window old-point)
|
||||||
(select-window new-window))))
|
(select-window new-window))))
|
||||||
;; Always copy quit-restore parameter in interactive use.
|
;; 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
|
(when quit-restore
|
||||||
(set-window-parameter new-window 'quit-restore quit-restore)))
|
(set-window-parameter new-window 'quit-restore quit-restore)))
|
||||||
new-window))
|
new-window))
|
||||||
|
|
||||||
(defalias 'split-window-vertically 'split-window-below)
|
(defalias 'split-window-vertically 'split-window-below)
|
||||||
|
|
||||||
(defun split-window-right (&optional size)
|
(defun split-root-window-below (&optional size)
|
||||||
"Split the selected window into two side-by-side windows.
|
"Split root window of current frame in two.
|
||||||
The selected window is on the left. The newly split-off window
|
The current window configuration is retained in the top window,
|
||||||
is on the right and displays the same buffer. Return the new
|
the lower window takes up the whole width of the frame. SIZE is
|
||||||
window.
|
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
|
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
|
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
|
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
|
bars, it includes the width of the divider column to the window's
|
||||||
right, if any."
|
right, if any."
|
||||||
(interactive "P")
|
(interactive `(,(when current-prefix-arg
|
||||||
(let ((old-window (selected-window))
|
(prefix-numeric-value current-prefix-arg))
|
||||||
(size (and size (prefix-numeric-value size)))
|
,(selected-window)))
|
||||||
new-window)
|
(let (new-window)
|
||||||
(when (and size (< size 0) (< (- size) window-min-width))
|
(when (and size (< size 0) (< (- size) window-min-width))
|
||||||
;; `split-window' would not signal an error here.
|
;; `split-window' would not signal an error here.
|
||||||
(error "Size of new window too small"))
|
(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.
|
;; 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
|
(when quit-restore
|
||||||
(set-window-parameter new-window 'quit-restore quit-restore)))
|
(set-window-parameter new-window 'quit-restore quit-restore)))
|
||||||
new-window))
|
new-window))
|
||||||
|
|
||||||
(defalias 'split-window-horizontally 'split-window-right)
|
(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.
|
;;; 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-horizontally)
|
||||||
(define-key ctl-x-map "-" 'shrink-window-if-larger-than-buffer)
|
(define-key ctl-x-map "-" 'shrink-window-if-larger-than-buffer)
|
||||||
(define-key ctl-x-map "+" 'balance-windows)
|
(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 "0" 'kill-buffer-and-window)
|
||||||
(define-key ctl-x-4-map "1" 'same-window-prefix)
|
(define-key ctl-x-4-map "1" 'same-window-prefix)
|
||||||
(define-key ctl-x-4-map "4" 'other-window-prefix)
|
(define-key ctl-x-4-map "4" 'other-window-prefix)
|
||||||
|
Loading…
Reference in New Issue
Block a user