Subject: Re: bug#67791: 30.0.50; `t' command on Gnus summary buffer sometimes causes an error

From: Katsumi Yamaoka <[email-masked]>
Date: Wed, 20 Dec 2023 09:34:00 +0900

reopen 67791

The bugs is getting back again with the error such as the one I
reported in <[email-masked]>
(<https://lists.gnu.org/archive/html/bug-gnu-emacs/2023-12/msg00690.html>).

On Wed, 13 Dec 2023 13:55:32 +0200, Eli Zaretskii wrote:
>> On Tue, 12 Dec 2023 13:51:30 +0200, Eli Zaretskii wrote:
>>> Did you try using the newer buffer-text-pixel-size instead?

>> Thanks, but I didn't know and not tried it.  Probably the buffer
>> needs to be narrowed to FROM and TO, that are the arguments
>> passed to `window-text-pixel-size'.

> I don't think you need to narrow the buffer, no.

`pixel-fill-region' measures the pixel width of the first letter
of a message header using `window-text-pixel-size' as follows:

(window-text-pixel-size nil (line-beginning-position) (point))

Where the point is just after the first letter of a header.  So,
how do we use `buffer-text-pixel-size' so to do the same thing?
It's nice if it can be used even when the window in which a letter
to be measured exists is not the selected one.  But if it's not
possible, I think the best way whould be to use the patch I posted
first:

--- gnus-art.el~	2023-12-10 23:22:23.410103300 +0000
+++ gnus-art.el	2023-12-12 02:11:11.364620000 +0000
@@ -2240,7 +2240,9 @@
         (if (not (gnus--variable-pitch-p (get-text-property (point) 'face)))
 	    (mail-header-fold-field)
           (forward-char 1)
-          (pixel-fill-region (point) (point-max) (pixel-fill-width)))
+          (save-window-excursion
+            (set-window-buffer nil (current-buffer))
+            (pixel-fill-region (point) (point-max) (pixel-fill-width))))
 	(goto-char (point-max))))))
 
 (defun gnus-article-treat-suspicious-headers ()

This makes `window-text-pixel-size' sure to run on the article
window.

Regards,