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: Thu, 3 Oct 2024 10:17:31 +0200
User-agent: Mozilla Thunderbird

>>> (defun transpose-windows--rearrange (frame-or-window conf norm-size)
>>
>> I'd call this just 'window--transpose'.
>
> done

Not really IIUC.

>> CONF is confusing.  Why is it a cons cell in the first place?  Wouldn't
>> a simple boolean - t for horizontal and nil for vertical - suffice?  If
>> not, please explain why.
>
> You can also have below split and abvoe split, not just nil and t

Aha...  So the values are the possible values of the SIDE argument of
'split-window'.

> I already explained the arguments in transpose-windows--rearrange.  As
> far as I can tell most other -1 postfix don't explain their arguments eg
> window--resize-reset-1.

Then please say "the arguments are the same as for `window--transpose'".

> btw, what are the plans for the keybindings? imo they should be added
> top level in C-x w map, as there are lots of spots avaiable, and there
> are only 5 total new functions.

Once we have installed it, we'll consult Juri Linkov.  He knows more
about keybindings in this area.  BTW, you could have a look at the
function 'window-swap-states'.  IIUC it should then be rewritten in
terms of the 'flip-windows-...' functions to get rid of window states
and the overlay rigmarole.

> (defun rotate-windows-anticlockwise (&optional frame-or-window)
>    "Rotate windows of FRAME-OR-WINDOW anti-clockwise by 90 degrees.
> FRAME-OR-WINDOW must be a live frame or window and defaults to the
> selected frame.  If FRAME-OR-WINDOW is a frame, rotate the main window
> of the frame, otherwise rotate FRAME-OR-WINDOW.  See
> `rotate-windows-clockwise' for how to rotate windows in the opposite
> direction"
>    (interactive `(,(and current-prefix-arg (window-parent))))

Please test what happens if you have a keybinding for this and you hit
that key in the minibuffer window, for example, after typing C-h f.

> (defun flip-windows-horizontally (&optional frame-or-window)
>    "Horizontally flip windows of FRAME-OR-WINDOW.  When the windows are
> flipped horzontally, the window layout is made to it's reflection from
> the side edge.  FRAME-OR-WINDOW must be a live frame or window and
> defaults to the selected frame. If FRAME-OR-WINDOW is a frame, flip from

Still a space missing after the "."

> (defun flip-windows-vertically (&optional frame-or-window)
>    "Horizontally flip windows of FRAME-OR-WINDOW.  When the windows are

Newline missing after ".".

> flipped vertically, the window layout is made to it's reflection from
> the top edge.  FRAME-OR-WINDOW must be a live frame or window and
> defaults to the selected frame. If FRAME-OR-WINDOW is a frame, flip from

Space missing after ".".

> (defun transpose-windows--rearrange (frame-or-window conf do-not-convert-size)

Rename to 'window--transpose' as you claimed above.

>    "Rearrange windows of FRAME-OR-WINDOW recursively.
> CONF should be a cons cell: (HORIZONTAL-SPLIT . VERTICAL-SPLIT) where
> HORIZONTAL-SPLIT will be used as the third argument of `split-window'
> when splitting a window that was previously horizontally split, and
> VERTICAL-SPLIT as third argument `split-window' for a window that was

... third argument _of_ ...

> previously vertically split.  When is DO-NOT-CONVERT-SIZE non-nil, the

Should become "If DO-NOT-CONVERT-SIZE is non-nil, ..."

> size argument of the window-split is converted from vertical to
> horizontal or vice versa, with the same proportion of the total split."
>    (pcase-let ((`(,rwin . ,frame)
>           (if (framep frame-or-window)
>               (cons (window-main-window frame-or-window) frame-or-window)
>             (cons frame-or-window (window-frame frame-or-window)))))
>      (if (or (not rwin)
>        (zerop (window-child-count rwin)))

Actually

(zerop (window-child-count rwin))

is equivalent to

(window-live-p rwin)

and the latter should be cheaper.

>            ;; The relevent size of the window.

I think "respective size" is what you mean.

>        ;; By using cdddr, we ignore over window split type, sizes and

Rather "ignore window split type" without the "over".

>        ;; the first window (it's implicitly created).
>        (nreverse (cdddr subtree))))
>      ;; (caaddr subtree) is the first window.
>      (unless (windowp (caaddr subtree))
>        (window--transpose-1 (caddr subtree) cwin conf do-not-convert-size))))

What I forgot to ask so far: Have you completed copyright assignment
for Emacs?  I can't look into this myself.

martin



reply via email to

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