diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi index 01baf742cd7..1611ecb7389 100644 --- a/doc/lispref/windows.texi +++ b/doc/lispref/windows.texi @@ -2453,52 +2453,6 @@ selected window will change to the window that appears at the location of the selected window before any of these commands were invoked. @end defopt -The next command allows to split the window layout of a frame and move -the resulting parts to one or several new frames. - -@cindex split window layout -@cindex split frame -@deffn Command split-frame &optional arg frame -This commands splits the window layout of @var{frame} which must be a -live frame and defaults to the selected one. It moves the resulting -parts into one or several new frames and returns these frames. - -If the optional argument @var{arg} is @code{nil}, it makes a new frame -whose root window occupies approximately one half of @var{frame}'s -original estate. If @var{arg} is a number, it creates @var{arg} - 1 new -frames and puts any child window of the main window of @var{frame} into -one of these frames. As a special case, if @var{arg} equals 1, it makes -one new frame containing all children but the first of the main window -of @var{frame}. With a non-numeric prefix @var{arg}, it tries to put -all children of @var{frame}'s main window but the first into a new -frame. Interactively, @var{arg} is the prefix argument. - -Note that any window put on a new frame is a clone (@pxref{Window -Configurations}) of the original window and the original window is -deleted. -@end deffn - -The effect of @code{split-frame} can be undone with the following -command which merges the window layout of one frame into the layout of -another. - -@cindex merge window layouts -@cindex merge frames -@deffn Command merge-frames &optional vertical frame1 frame2 -This commands merges the window layout of @var{frame2} into that of -@var{frame1}. For this purpose, it splits the root window of -@var{frame1} and makes the new window display the root window of -@var{frame2}. Both @var{frame1} and @var{frame2} must be distinct, live -frames where @var{frame1} defaults to the selected frame and -@var{frame2} to the frame following @var{frame1} in the frame list. -@var{frame2} gets deleted if its windows have been merged successfully. - -If @var{vertical} is non-@code{nil}, this makes the new window appear -below the old main window of @var{frame1}. Otherwise, it makes the new -window on the right of @var{frame1}'s main window. Interactively, -@var{vertical} is the prefix argument. -@end deffn - @node Cyclic Window Ordering @section Cyclic Ordering of Windows diff --git a/etc/NEWS b/etc/NEWS index 8ddc9fe3407..f61825f531b 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -420,12 +420,6 @@ adjacent windows and subsequently operate on that parent. 'uncombine-window' can then be used to restore the window configuration to the state it had before running 'combine-windows'. -+++ -*** New commands 'split-frame' and 'merge-frames'. -These commands allow splitting the window layout of an existing frame -into several frames, and merging the window layouts of two existing -frames into one frame, respectively. - ** Frames +++ diff --git a/lisp/window-x.el b/lisp/window-x.el index 4220e0d2880..37344e9101a 100644 --- a/lisp/window-x.el +++ b/lisp/window-x.el @@ -313,121 +313,7 @@ ones in `window--transpose'." (let ((is-atom (memq (cadr (cadr (cddddr subtree))) atom-windows))) (window--transpose-1 (car (cddddr subtree)) cwin (if is-atom '(nil . t) conf) - no-resize atom-windows))))) - -;;;###autoload -(defun merge-frames (&optional vertical frame1 frame2) - "Merge FRAME2 into FRAME1. -Split the root window of FRAME1 and make the new window display the root -window of FRAME2. Both FRAME1 and FRAME2 must be distinct, live frames -where FRAME1 defaults to the selected frame and FRAME2 to the frame -following FRAME1 in the frame list. Delete FRAME2 if it has been merged -successfully. - -If VERTICAL is non-nil, make the new window below the old main window -of FRAME1. Otherwise, make the new window on the right of FRAME1's main -window. Interactively, VERTICAL is the prefix argument, FRAME1 is the -selected frame and FRAME2 is the frame following FRAME1 in the frame -list." - (interactive "P") - (let* ((frame1 (window-normalize-frame frame1)) - (frame2 (if frame2 - (window-normalize-frame frame2) - (next-frame frame1)))) - (if (eq frame1 frame2) - (user-error "Cannot merge frame into itself") - (window-state-put - ;; Source window on frame2. - (window-state-get (window-main-window frame2)) - ;; Make new window on frame1. - (split-window (window-main-window frame1) nil (not vertical))) - (delete-frame frame2) - frame1))) - -;;;###autoload -(defun split-frame (&optional arg frame) - "Split FRAME. -FRAME must be a live frame and defaults to the selected frame. - -Interactively, ARG is the prefix argument. If ARG is nil, make a new -frame whose root window occupies approximately one half of FRAME's -original estate. If ARG is a number, make ARG - 1 new frames and put -any child window of the main window of FRAME into one of these frames. -As a special case, if ARG equals 1, make one new frame containing all -children but the first of the main window of FRAME. With a non-numeric -prefix ARG, try to put all children of FRAME's main window but the first -into a new frame. In either case, any window put on a new frame is a -clone of the original window and the original window is deleted." - (interactive "P") - (let* ((mw (window-main-window frame)) - (first-child (window-child mw)) - (nwindows (window-child-count mw))) - (cond - ((<= nwindows 1) - (user-error "Cannot split a one-window frame")) - ;; One frame for each window. - ((or (eq nwindows 2) (and arg (not (numberp arg)))) - (let ((sib (window-next-sibling first-child)) - frames) - (while sib - (let* ((state (window-state-get sib)) - (frame (make-frame)) - (next-sib (window-next-sibling sib))) - (push frame frames) - (window-state-put state (window-main-window frame)) - (delete-window sib) - (setq sib next-sib))) - frames)) - ;; Two windows. - ((eq 1 arg) - (let* ((snd-sib (window-next-sibling first-child)) - (sib (combine-windows snd-sib (window-last-child mw))) - (state (window-state-get sib)) - (frame (make-frame))) - (window-state-put state (window-main-window frame)) - (delete-window sib) - frame)) - ;; Smart window splitting. - (t - (let ((nframes (or arg 2))) - (when (< nwindows nframes) - (user-error "%i frames cannot be made from %i windows" arg nwindows)) - (let* ((horizontal (window-combined-p first-child t)) - (ideal (/ (window-size mw horizontal) nframes)) - (current-window first-child) - (sum (window-size current-window horizontal)) - (windows (list (list first-child))) - frames) - ;; Need to come up with the inital windows split using sliding - ;; sum technique. - (while (setq current-window (window-next-sibling current-window)) - (setq sum (seq-reduce '+ (mapcar - (lambda (w) - (window-size w horizontal)) - (car (last windows))) - 0)) - (let ((remaining-frames (- nframes (length windows))) - (remaining-windows - (- nwindows (seq-reduce '+ (mapcar 'length windows) 0)))) - (if (or (= remaining-windows remaining-frames) - ;; HACK ALERT! - (>= sum (* ideal 0.85))) - (progn - (setq sum 0) - (nconc windows (list (list current-window)))) - (nconc (car (last windows)) (list current-window))))) - (when (cdar windows) - (combine-windows (caar windows) (car (last (car windows))))) - (dolist (wls (cdr windows) frames) - (let* ((cwin (if (cdr wls) - (combine-windows (car wls) (car (last wls))) - (car wls))) - (state (window-state-get cwin)) - (frame (make-frame))) - (push frame frames) - (delete-window cwin) - (window-state-put state (window-main-window frame)))))))))) + no-resize atom-windows))))) (provide 'window-x) - ;;; window-x.el ends here