]> git.eshelyaron.com Git - emacs.git/commitdiff
; * lisp/window-x.el (window--transpose-1): Simplify.
authorEshel Yaron <me@eshelyaron.com>
Sat, 11 Jan 2025 18:10:08 +0000 (19:10 +0100)
committerEshel Yaron <me@eshelyaron.com>
Sun, 12 Jan 2025 10:59:02 +0000 (11:59 +0100)
lisp/window-x.el

index 82271aa1d4c2289c73e47cd34551b6917c006f25..7eee7368859a787a1b2886b4cee959ebde73e5cb 100644 (file)
@@ -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)))