[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#54380: 29.0.50; Unexpected nil value of 'rest' in 'balance-windows-2
From: |
Matt Beshara |
Subject: |
bug#54380: 29.0.50; Unexpected nil value of 'rest' in 'balance-windows-2' |
Date: |
Tue, 15 Mar 2022 21:20:13 +1100 |
User-agent: |
K-9 Mail for Android |
On 14 March 2022 8:30:40 pm AEDT, martin rudalics <rudalics@gmx.at> wrote:
>If the code had used a term like say 'number-of-resizable-children' we
>might have been able to avoid this bug in the first place. Too bad ...
>
> > Attempting to use ‘balance-windows’ in a frame displaying many
> > windows, two of which are displaying buffers which both have the
> > buffer-local variable ‘window-size-fixed’ set to t, fails with the
> > error “Wrong type argument: number-or-marker-p, nil”. This error is
> > produced by line 5765 of window.el, “(while (and sub (> rest 0))”. It
> > appears that the code in this function always expects ‘rest’ to have a
> > non-nil value, but in this case ‘rest’ is nil. Modifying line 5765 to
> > read “(while (and sub rest (> rest 0))” so that it checks ‘rest’ is
> > non-nil before attemping to call ‘>’ seems to fix it. I haven’t
> > attached a patch as a patch for a one-line diff seems excessive, but
> > if it would be useful, I can provide one.
>
>Thanks for the report. The bug is a consequence of the following
>sequence of steps in 'balance-windows-2':
>
>- If an internal window has only fixed-size children, we eventually set
> 'number-of-children' to zero here
>
> (setq number-of-children (1- number-of-children))
>
>- We set 'rest' only if 'number-of-children' is greater zero here
>
> (when (> number-of-children 0)
> (setq rest (% total-sum number-of-children))
>
>- We ask for the value of 'rest' when a window has at least one child as
>
> (let* (...
> (first (window-child window))
>
> (setq sub first)
> (while (and sub (> rest 0))
>
>I checked in a fix, please try with latest master.
>
>Thanks again, martin
The fix works very well, thank you.