help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: New balance-windows


From: Pascal Bourguignon
Subject: Re: New balance-windows
Date: Sat, 06 Aug 2005 18:39:14 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

"Ehud Karni" <address@hidden> writes:

> Following the recent discussion of `balance-windows' on help-gnu-emacs
> I looked into it and wrote a replacement (new) function based on
> somewhat different logic to achieve the balancing.

Thanks very much.  It's nice.  But it's not perfect, see at the end.

> The logic is this: group all windows that has the same "left" (or "top"
> for horizontal) edge, and balance their height (width).
>
> The actual resizing is dependent on the window structure.
> e.g. the two symmetrical window structures below will be balanced
> differently (the diagrams are after vertical balancing):
>
>        +-------+--------+             +-------+--------+
>        |       |        |             |       |        |
>        | 1 / 3 |        |             |       | 1 / 4  |
>        |       |        |             | 1 / 2 +--------+
>        +-------|  2 / 3 |             |       |        |
>        |       |        |             |       | 1 / 4  |
>        | 1 / 3 |        |             +-------+--------+
>        |       |        |             |                |
>        +-------+--------+             |                |
>        |                |             |     1 / 2      |
>        |     1 / 3      |             |                |
>        |                |             |                |
>        +-------+--------+             +-------+--------+

I'm not sure it's justified.

Note that:

        +------+------+
        |      |      |
        |      |      |
        +------+------+
        |      |      |
        |      |      |
        +------+------+

may represent two different structures: C-x 2 C-x 3 C-x o C-x 3
or C-x 3 C-x 2 C-x o C-x 2


But in both these cases:

        +-------+--------+             +-------+--------+
        |       |        |             |       |        |
        | 1 / 3 |        |             |       | 1 / 4  |
        |       |        |             | 1 / 2 +--------+
        +-------|  2 / 3 |             |       |        |
        |       |        |             |       | 1 / 4  |
        | 1 / 3 |        |             +-------+--------+
        |       |        |             |                |
        +-------+--------+             |                |
        |                |             |     1 / 2      |
        |     1 / 3      |             |                |
        |                |             |                |
        +-------+--------+             +-------+--------+

the hierarchy of splits is the same, so I don't see why it should
balance differently.

I think a correct algorithm should recover the split tree, then make
the balancing depending on the window counts in subtrees.




C-x 2 C-x 3 C-x 2 C-x 2 M-x balance-window RET  is OK:

        +-------+-------+
        |       |       |
        |       |       |
        +-------+       |
        |       |       |
        |       |       |
        +-------+       |
        |       |       |
        |       |       |
        +-------+-------+
        |               |
        |               |
        +---------------+

but then: C-X o C-X o C-X o C-X o C-x 2, giving:

        +-------+-------+
        |       |       |
        |       |       |
        +-------+       |
        |       |       |
        |       |       |
        +-------+       |
        |       |       |
        |       |       |
        +-------+-------+
        |               |
        +---------------+
        |               |
        +---------------+

and M-x balance-window RET doesn't balance at all:

        +-------+-------+
        |       |       |
        |       |       |
        +-------+       |
        |       |       |
        |       |       |
        +-------+       |
        |       |       |
        |       |       |
        +-------+-------+
        +---------------+
        |               |
        |               |
        +---------------+



I'd expect:

        +-------+-------+
        |       |       |
        +-------+       |
        |       |       |
        +-------+       |
        |       |       |
        +-------+-------+
        |               |
        +---------------+
        |               |
        +---------------+



-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

The world will now reboot.  don't bother saving your artefacts.


reply via email to

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