"Ehud Karni" <[EMAIL PROTECTED]> 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. _______________________________________________ Help-gnu-emacs mailing list Help-gnu-emacs@gnu.org http://lists.gnu.org/mailman/listinfo/help-gnu-emacs