unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: Steven Edwards <cureadvocate@gmail.com>
Cc: 16383@debbugs.gnu.org
Subject: bug#16383: balance-windows fails in Emacs 24.3.50.1
Date: Sat, 11 Jan 2014 11:25:18 +0100	[thread overview]
Message-ID: <52D11C0E.7010706@gmx.at> (raw)
In-Reply-To: <CAA3vWKB0ed9iXNykAeUdJe5Gcu8KUJHjJFJqs=eyFwSEddCK_Q@mail.gmail.com>

 > 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)))))





  reply	other threads:[~2014-01-11 10:25 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-07 16:01 bug#16383: balance-windows fails in Emacs 24.3.50.1 Steven Edwards
2014-01-07 17:31 ` martin rudalics
2014-01-07 19:06   ` Steven Edwards
2014-01-07 19:28     ` martin rudalics
2014-01-07 20:12       ` Steven Edwards
2014-01-11 10:25         ` martin rudalics [this message]
2014-01-11 11:39           ` Steven Edwards
2014-01-11 13:28             ` Steven Edwards
2014-01-11 14:01               ` martin rudalics
2014-01-11 16:26                 ` Steven Edwards
2014-01-12  9:53                   ` martin rudalics
2014-01-12 10:46                     ` Steven Edwards
2014-01-12 11:44                       ` martin rudalics
2014-01-12 12:32                         ` Steven Edwards
2014-01-12 17:26                           ` martin rudalics
2014-01-13 17:52                             ` martin rudalics

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52D11C0E.7010706@gmx.at \
    --to=rudalics@gmx.at \
    --cc=16383@debbugs.gnu.org \
    --cc=cureadvocate@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).