Subject: Re: bug#79013: `window-state-put' uses incorrect alist key `'min-weight' but should use `'min-width'.

From: Eli Zaretskii <[email-masked]>
Date: Mon, 14 Jul 2025 14:36:29 +0300

> Date: Mon, 14 Jul 2025 08:13:27 +0000
> From:  Derick Eddington via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <[email-masked]>
> 
> To reproduce:
> 
>     $ emacs -Q --batch --eval \
>             "(window-state-put '(((min-height . 12)
>                                   (min-width . 20)
>                                   (min-height-ignore . 7)
>                                   (min-width-ignore . 8)
>                                   (min-height-safe . 3)
>                                   (min-width-safe . 4))
>                                  vc
>                                  (total-width . 200)
>                                  (total-height . 60)
>                                  (normal-height . 1.0)
>                                  (normal-width . 1.0)
>                                  (combination-limit)))"
> 
> Which causes the following error:
> 
>     Wrong type argument: number-or-marker-p, nil
> 
> because (in the definition of `window-state-put'):
> 
>          (min-width (cdr (assq
>                           (if pixelwise 'min-pixel-width 'min-weight)
>                           head)))
> 
> binds `min-width' to `nil' because `'min-weight' is (correctly) not in
> the input alist.
> 
> and so:
>                  (> min-width (window-size window t pixelwise)))
> causes the error.
> 
> Whereas, if you substitute the incorrect key it's currently using,
> `'min-weight' for `'min-width', in the input alist, then it does not
> error.  But that would be invalid because it's supposed to use
> `'min-width', like `window-state-get' returns.
> 
> This mistake was introduced in commit 880e615 "Support resizing frames
> and windows pixelwise." in the year 2013.  Previously, `'min-width' had
> been used, but when that commit introduced `'min-pixel-width' it also
> typoed as `'min-weight' its attempt at preserving the `'min-width'.
> 
> I'll be submitting a patch to fix this.
> 
> The fix is simply:
> 
> --- a/lisp/window.el
> +++ b/lisp/window.el
> @@ -6803,7 +6803,7 @@ was killed since STATE was made, it will consult the variable
>  			   (if pixelwise 'min-pixel-height 'min-height)
>  			   head)))
>  	 (min-width (cdr (assq
> -			  (if pixelwise 'min-pixel-width 'min-weight)
> +			  (if pixelwise 'min-pixel-width 'min-width)
>  			  head)))
>  	 ;; Bind the following two variables.  `window--state-put-1' has
>  	 ;; to fully control them (see Bug#50867 and Bug#64405).

Thanks, fixed on the emacs-30 branch, and closing the bug.