From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.bugs Subject: bug#16383: balance-windows fails in Emacs 24.3.50.1 Date: Sat, 11 Jan 2014 11:25:18 +0100 Message-ID: <52D11C0E.7010706@gmx.at> References: <52CC39FC.2090902@gmx.at> <52CC5576.3080507@gmx.at> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1389435982 6679 80.91.229.3 (11 Jan 2014 10:26:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 11 Jan 2014 10:26:22 +0000 (UTC) Cc: 16383@debbugs.gnu.org To: Steven Edwards Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jan 11 11:26:28 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1W1vlo-0001BN-4A for geb-bug-gnu-emacs@m.gmane.org; Sat, 11 Jan 2014 11:26:24 +0100 Original-Received: from localhost ([::1]:60896 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W1vln-0008Gg-N6 for geb-bug-gnu-emacs@m.gmane.org; Sat, 11 Jan 2014 05:26:23 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38291) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W1vlc-00084P-P0 for bug-gnu-emacs@gnu.org; Sat, 11 Jan 2014 05:26:20 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W1vlV-000225-7G for bug-gnu-emacs@gnu.org; Sat, 11 Jan 2014 05:26:12 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:60248) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W1vlV-00021q-4w for bug-gnu-emacs@gnu.org; Sat, 11 Jan 2014 05:26:05 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1W1vlT-0003up-V6 for bug-gnu-emacs@gnu.org; Sat, 11 Jan 2014 05:26:04 -0500 X-Loop: help-debbugs@gnu.org Resent-From: martin rudalics Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 11 Jan 2014 10:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 16383 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 16383-submit@debbugs.gnu.org id=B16383.138943593215008 (code B ref 16383); Sat, 11 Jan 2014 10:26:02 +0000 Original-Received: (at 16383) by debbugs.gnu.org; 11 Jan 2014 10:25:32 +0000 Original-Received: from localhost ([127.0.0.1]:46034 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W1vkx-0003tz-57 for submit@debbugs.gnu.org; Sat, 11 Jan 2014 05:25:31 -0500 Original-Received: from mout.gmx.net ([212.227.15.19]:52208) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W1vko-0003ti-EA for 16383@debbugs.gnu.org; Sat, 11 Jan 2014 05:25:27 -0500 Original-Received: from [62.47.53.225] ([62.47.53.225]) by mail.gmx.com (mrgmx001) with ESMTPSA (Nemesis) id 0M86Cn-1V6eMi0njd-00vgTN for <16383@debbugs.gnu.org>; Sat, 11 Jan 2014 11:25:21 +0100 In-Reply-To: X-Provags-ID: V03:K0:b4IWijPubVZAg3FELf1RgCktrSeFaTAqWorNFs4fmECcs/NcjZb AkvseFTq8pxJzfjUWRFX9p18kt5D+5XikAMKbL9axs9TOrz4ftUr8+8ElFngO6LNB6YYEAH iHBvupY0QdbURsfky+Y0ciTXxEmrHOknRtxiN0/YK5aTLAWiRh4OZO5q4QR/4/vNFNovSdM KCicU5LuiJPvbuwmk3ZRA== X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:83284 Archived-At: > I applied the changes manually with no luck. I suppose you applied the changes but did not recompile/evaluate window.el afterwards. Even if you did, the changes won't be picked up when you restart Emacs because you did not change the corresponding part of the executable (you would have to "make" Emacs for that purpose). So simply take the patched code of `balance-windows-2' (for example, as it is at the end of this mail), add it to your .emacs, and run it until ... > The Debian snapshot will > be updated soon, I hope. ... this happens. > Thank you for letting me know it's fixed... that gives me something to > look forward to. :) Don't look forward, try now ;-) Thanks, martin (defun balance-windows-2 (window horizontal) "Subroutine of `balance-windows-1'. WINDOW must be a vertical combination (horizontal if HORIZONTAL is non-nil)." (let* ((char-size (if window-resize-pixelwise 1 (frame-char-size window horizontal))) (first (window-child window)) (sub first) (number-of-children 0) (parent-size (window-new-pixel window)) (total-sum parent-size) failed size sub-total sub-delta sub-amount rest) (while sub (setq number-of-children (1+ number-of-children)) (when (window-size-fixed-p sub horizontal) (setq total-sum (- total-sum (window-size sub horizontal t))) (set-window-new-normal sub 'ignore)) (setq sub (window-right sub))) (setq failed t) (while (and failed (> number-of-children 0)) (setq size (/ total-sum number-of-children)) (setq failed nil) (setq sub first) (while (and sub (not failed)) ;; Ignore child windows that should be ignored or are stuck. (unless (window--resize-child-windows-skip-p sub) (setq sub-total (window-size sub horizontal t)) (setq sub-delta (- size sub-total)) (setq sub-amount (window-sizable sub sub-delta horizontal nil t)) ;; Register the new total size for this child window. (set-window-new-pixel sub (+ sub-total sub-amount)) (unless (= sub-amount sub-delta) (setq total-sum (- total-sum sub-total sub-amount)) (setq number-of-children (1- number-of-children)) ;; We failed and need a new round. (setq failed t) (set-window-new-normal sub 'skip))) (setq sub (window-right sub)))) ;; How can we be sure that `number-of-children' is NOT zero here ? (setq rest (% total-sum number-of-children)) ;; Fix rounding by trying to enlarge non-stuck windows by one line ;; (column) until `rest' is zero. (setq sub first) (while (and sub (> rest 0)) (unless (window--resize-child-windows-skip-p window) (set-window-new-pixel sub (min rest char-size) t) (setq rest (- rest char-size))) (setq sub (window-right sub))) ;; Fix rounding by trying to enlarge stuck windows by one line ;; (column) until `rest' equals zero. (setq sub first) (while (and sub (> rest 0)) (unless (eq (window-new-normal sub) 'ignore) (set-window-new-pixel sub (min rest char-size) t) (setq rest (- rest char-size))) (setq sub (window-right sub))) (setq sub first) (while sub ;; Record new normal sizes. (set-window-new-normal sub (/ (if (eq (window-new-normal sub) 'ignore) (window-size sub horizontal t) (window-new-pixel sub)) (float parent-size))) ;; Recursively balance each window's child windows. (balance-windows-1 sub horizontal) (setq sub (window-right sub)))))