Subject: Re: bug#51995: 29.0.50; `string-pixel-width' depends on the current window width

From: martin rudalics <[email-masked]>
Date: Sat, 20 Nov 2021 09:48:39 +0100

> I think the best solution is to modify `window-text-pixel-size' so that
 > X-LIMIT may be specified as having "no limit".  Y-LIMIT already offers
 > this possibility: when it is nil, the entirety of the buffer is considered
 > (in reality, it seems to be simply set to INT_MAX, and that does the job).

Since 'window-text-pixel-size' has to deal with arbitrary buffers, it is
not a good idea to set X-LIMIT or Y-LIMIT to very large values.  The
doc-string of 'window-text-pixel-size' explicitly warns about X-LIMIT
that

   Since calculating the width of long lines can take some time, it's
   always a good idea to make this argument as small as possible; in
   particular, if the buffer contains long lines that shall be truncated
   anyway.

and about Y-LIMIT that

   Since calculating the text height of a large buffer can take some time,
   it makes sense to specify this argument if the size of the buffer is
   large or unknown.

So any such fix has to be made in 'string-pixel-width' itself.

 > I'm experience some different problems with this function, and I'm pretty sure
 > it don't stem from this same issue, but from WINDOW being buffer.
 > Should I open a new bug report? Or expand upon the issue on this same thread?

'string-pixel-width' and the accompanying change of
'window-text-pixel-size' are broken in many ways, see also

   https://mail.gnu.org/archive/html/emacs-devel/2021-11/msg00339.html

If you see a problem that is not mentioned there, please tell us.

I hopefully fixed most of the issues here but cannot send you a patch at
the moment to test because my local copy is completely out of synch with
master.  So please bear with me.

martin