Subject: bug#41537: 26.3; window-body-width wrong return value when display-line-numbers-mode is on

From: Eli Zaretskii <[email-masked]>
Date: Tue, 26 May 2020 18:25:33 +0300

tags 41537 notabug
thanks

> From: "Matsievskiy S.V." <[email-masked]>
> Date: Tue, 26 May 2020 13:50:38 +0300
> 
> `window-body-width` and `window-width` return wrong numbers when
> `display-line-numbers-mode` is on.
> 
> For example:
> ```emacs-lisp
> (message (format "Width without line numbers: %d" (window-body-width)))
> (display-line-numbers-mode 1)
> (message (format "Width with line numbers: %d" (window-body-width)))
> ```
> 
> return these lines:
> ```
> Width without line numbers: 209
> Width with line numbers: 209
> ```
> 
> This is obviously wrong since line numbers take some window space.

This is not wrong, since these functions measure the body without the
line numbers.  This is not a bug, but the intended behavior.

> This breaks some packages that rely on `window-body-width` and
> `window-width` to align strings. 

Those packages should adapt to display-line-numbers-mode by taking
into account the value returned by line-number-display-width.