emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Add function to rotate/transpose all windows


From: martin rudalics
Subject: Re: Add function to rotate/transpose all windows
Date: Sat, 19 Oct 2024 10:33:05 +0200
User-agent: Mozilla Thunderbird

>> If you optionally can supply REFER as a cons where the car is the
>> previous (currently deleted) parent and the cdr the previous (currently
>> deleted) leaf window (you have to keep pointers to all of them just in
>> case the collector runs in between), we can easily fix that.  Just that
>> 'window-tree-pixel-sizes' would have to report the old parent window too
>> (in front of the flag telling whether it constitutes a horizontal or
>> vertical split, probably).  It's easy to do, believe me.
>>
>
> I don't understand

Suppose I had defined 'window-tree-pixel-sizes' as

(defun window-tree-pixel-sizes (window &optional next)
  "Return pixel sizes of all windows rooted at WINDOW.
The return value is a list where each internal window is represented by
a list of four elements: The window object, an indicator that is t if
the window is a horizontal combination and nil otherwise, the size of
the window as a cons of its pixel height and pixel width and a recursive
list of the window's child windows using the same list structure.  A
live window is represented by a cons consisting of the window object and
a cons of its pixel height and pixel width."
  (let (list child)
    (while window
      (setq list
            (cons
             (if (window-live-p window)
                 (cons window (cons (window-pixel-height window)
                                    (window-pixel-width window)))
               (list window
                     (not (window-top-child window))
                     (cons (window-pixel-height window)
                           (window-pixel-width window))
                     (window-tree-pixel-sizes
                      (or (window-top-child window)
                          (window-left-child window))
                      t)))
             list))
      (setq window (when next (window-next-sibling window))))
    (nreverse list)))

Then

(pp (window-tree-pixel-sizes (frame-root-window)))

gets me here with a three live windows frame instead of your

((nil (979 . 1680) (#<window 15 on window-transpose.el> (979 . 840))
      (t (979 . 840) (#<window 89 on *Messages*> (490 . 840))
         (#<window 95 on *scratch*> (489 . 840)))))

something like

((#<window 56> t (979 . 1680)
           ((#<window 15 on window-transpose.el> 979 . 840)
            (#<window 60> nil (979 . 840)
                      ((#<window 57 on *Messages*> 490 . 840)
                       (#<window 61 on *scratch*> 489 . 840))))))

The first element for each window would be its object: So #<window 56>
is a horizontal combination with the live #<window 15> as left and the
internal window #<window 60> as its right child.  Now when you want to
recreate #<window #15> you would have to pass 'split-window' a cons cell
referencing #<window 56> and #<window #15> and 'split-window-internal'
would resurrect the first as the parent and the second as its child.

martin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]