From: Eshel Yaron Date: Sat, 11 Jan 2025 18:10:08 +0000 (+0100) Subject: ; * lisp/window-x.el (window--transpose-1): Simplify. X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=6659cce7bfd21fad1b1aa9a7a6c988dd72a56fe6;p=emacs.git ; * lisp/window-x.el (window--transpose-1): Simplify. --- diff --git a/lisp/window-x.el b/lisp/window-x.el index 82271aa1d4c..7eee7368859 100644 --- a/lisp/window-x.el +++ b/lisp/window-x.el @@ -231,68 +231,58 @@ ones in `window--transpose'." (flen (if (xor no-resize (car subtree)) (float (window-pixel-width cwin)) (float (window-pixel-height cwin))))) - (mapc - (pcase-lambda (`(,window . ,size)) - (prog1 - (let* ((split-size (- (round (* flen size)))) - (split-type - (funcall (if (car subtree) #'car #'cdr) conf)) - (return-win - (if (listp window) - ;; `window' is a window subtree. - ;; `first-child' is a live window that is an descended of window - (let* ((first-child window) - ;; If the window being split is atomic - (is-atom - ;; cadr will return the internal parent window - (memq (cadr first-child) atom-windows))) - ;; (caar (cddddr first-child)) is the first window in the - ;; list if there is a live window. - (while (not (windowp (caar (cddddr first-child)))) - (setq first-child (car (cddddr first-child)))) - (window--transpose-1 - window - (let ((window-combination-limit parent-window-is-set)) - (split-window - cwin - split-size - split-type - t - (if window-combination-limit - (cons (caar (cddddr first-child)) (cadr subtree)) - (caar (cddddr first-child))))) - (if is-atom '(nil . t) conf) - no-resize - atom-windows)) - ;; `window' is a window. - (split-window - cwin - split-size - split-type t - ;; We need to set parent window if it hasn't been set - ;; already. - (if parent-window-is-set - (cons window (cadr subtree)) - window))))) - (when (eq window-combination-limit t) - (set-window-combination-limit (cadr subtree) nil)) - return-win) - (setq parent-window-is-set nil))) - (mapcar - (lambda (e) - (pcase-let* ((`(,window . ,window-size-info) - (if (windowp (car e)) - (cons (car e) e) - (cons e (cdr e))))) - (cons window - ;; The respective size of the window. - (if (car subtree) - (cadr window-size-info) - (caddr window-size-info))))) - ;; We need to ignore first 5 elements of window list, we ignore - ;; window split type, sizes and the first window (it's - ;; implicitly created). We just have a list of windows. - (nreverse (cdr (cddddr subtree))))) + (pcase-dolist + (`(,window . ,size) + (mapcar + (lambda (e) + (pcase-let* ((`(,window . ,window-size-info) + (if (windowp (car e)) + (cons (car e) e) + (cons e (cdr e))))) + (cons window + ;; The respective size of the window. + (if (car subtree) + (cadr window-size-info) + (caddr window-size-info))))) + ;; We need to ignore first 5 elements of window list, we ignore + ;; window split type, sizes and the first window (it's + ;; implicitly created). We just have a list of windows. + (nreverse (cdr (cddddr subtree))))) + (let* ((split-size (- (round (* flen size)))) + (split-type (funcall (if (car subtree) #'car #'cdr) conf))) + (if (listp window) + ;; `window' is a window subtree. + ;; `first-child' is a live descendent of `window'. + (let* ((first-child window) + ;; If the window being split is atomic + (is-atom + ;; cadr will return the internal parent window + (memq (cadr first-child) atom-windows))) + ;; (caar (cddddr first-child)) is the first window in the + ;; list if there is a live window. + (while (not (windowp (caar (cddddr first-child)))) + (setq first-child (car (cddddr first-child)))) + (window--transpose-1 + window + (let ((window-combination-limit parent-window-is-set)) + (split-window cwin split-size split-type t + (if window-combination-limit + (cons (caar (cddddr first-child)) + (cadr subtree)) + (caar (cddddr first-child))))) + (if is-atom '(nil . t) conf) + no-resize + atom-windows)) + ;; `window' is a window. + (split-window cwin split-size split-type t + ;; We need to set parent window if it hasn't + ;; been set already. + (if parent-window-is-set + (cons window (cadr subtree)) + window))) + (when (eq window-combination-limit t) + (set-window-combination-limit (cadr subtree) nil))) + (setq parent-window-is-set nil)) ;; (caar (cddddr subtree)) is the first child window of subtree. (unless (windowp (caar (cddddr subtree))) (let ((is-atom (memq (cadr (cadr (cddddr subtree))) atom-windows)))