From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Pascal Bourguignon Newsgroups: gmane.emacs.help Subject: Re: New balance-windows Date: Sat, 06 Aug 2005 18:39:14 +0200 Organization: Informatimago Message-ID: <87vf2juij1.fsf@thalassa.informatimago.com> References: <87pssv3kai.fsf@thalassa.informatimago.com> <1123035204.009217.187300@g14g2000cwa.googlegroups.com> <87fytr3ea2.fsf@thalassa.informatimago.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1123346607 30019 80.91.229.2 (6 Aug 2005 16:43:27 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 6 Aug 2005 16:43:27 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Aug 06 18:43:23 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1E1Rkc-0002F5-GH for geh-help-gnu-emacs@m.gmane.org; Sat, 06 Aug 2005 18:42:22 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1E1RnX-0007uv-0b for geh-help-gnu-emacs@m.gmane.org; Sat, 06 Aug 2005 12:45:23 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!news3.google.com!news.glorb.com!easynet-quince!easynet.net!easynet-post2!not-for-mail Original-Newsgroups: gnu.emacs.help Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:dPwLT0GAzZOX8mh7Fpcq+c0hkEM= Original-Lines: 142 Original-NNTP-Posting-Host: 62.93.174.79 Original-X-Trace: DXC=<6UiOW\8L[kIZIZ;;>=]Ymi_giQ7bjRVjbBd4DjF1d]a Original-Xref: shelby.stanford.edu gnu.emacs.help:132961 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:28481 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:28481 "Ehud Karni" 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.