unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Katsumi Yamaoka <yamaoka@jpl.org>
To: 67791@debbugs.gnu.org
Subject: bug#67791: 30.0.50; `t' command on Gnus summary buffer sometimes causes an error
Date: Tue, 12 Dec 2023 11:15:54 +0900	[thread overview]
Message-ID: <b4mr0jsmahx.fsf@jpl.org> (raw)

Because the `gnus-article-treat-fold-headers' function does not
work as expected.  `t' command, i.e. `gnus-summary-toggle-header'
is invoked on the Gnus summary buffer, that runs by default
`gnus-article-treat-fold-headers' by way of `gnus-treat-article'.
It works on the article buffer and folds headers with the help of
the pixel-fill functions.  One of them, `pixel-fill-region' uses
the built-in `window-text-pixel-size' function, that is required
to run on the selected window in which there is the text to
measure the pixel size (since `pixel-fill-region' passes nil to
`window-text-pixel-size' as the 1st argument `WINDOW').
,----
| (window-text-pixel-size &optional WINDOW FROM TO ...)
|
| Return the size of the text of WINDOW's buffer in pixels.
| WINDOW must be a live window and defaults to the selected one.
`----
Therefore, the window should be that of the article.  However,
in that situation the selected one is that of the summary, as
mentioned above.  Because of this, the `window-text-pixel-size'
sometimes returns a funny value and it causes the error like
this:

Debugger entered--Lisp error: (error "The indentation (640) is wider than th...
  signal(error ("The indentation (640) is wider than the fill width (623)"))...
  error("The indentation (%s) is wider than the fill width (%s)" 640 623)...
  (progn (error "The indentation (%s) is wider than the fill width (%s)" ind...
  (if (> indentation pixel-width) (progn (error "The indentation (%s) is wid...
  (let ((indentation (car (window-text-pixel-size nil (line-beginning-positi...
  (save-excursion (goto-char start) (let ((indentation (car (window-text-pix...
  pixel-fill-region(101 181 623)
 [...]
  command-execute(gnus-summary-toggle-header)

Another possible cause might be the recent change (33b6de7a)
made in `window-text-pixel-size', because such an error doesn't
look to cause in Emacs 29.1.90 (the function before the change
might possibly have worked on the current buffer, not the
selected window).

Here is a quick hack:

* lisp/gnus/gnus-art.el (gnus-article-treat-fold-headers): Make sure
the article window is selected while running pixel-fill-region.

--8<---------------cut here---------------start------------->8---
--- 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 ()
--8<---------------cut here---------------end--------------->8---

In GNU Emacs 30.0.50 (build 1, x86_64-pc-cygwin, GTK+ Version
 3.22.28, cairo version 1.17.4) of 2023-12-12 built on localhost
Windowing system distributor 'The Cygwin/X Project', version 11.0.12101008
Configured using:
 'configure 'CFLAGS=-O0 -g3' --verbose
 --infodir=/usr/local/info/emacs --with-x-toolkit=gtk3
 --with-cairo-xcb --with-imagemagick
 --with-native-compilation=no'





             reply	other threads:[~2023-12-12  2:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-12  2:15 Katsumi Yamaoka [this message]
2023-12-12 11:51 ` bug#67791: 30.0.50; `t' command on Gnus summary buffer sometimes causes an error Eli Zaretskii
2023-12-13  2:11   ` Katsumi Yamaoka
2023-12-13 11:55     ` Eli Zaretskii
2023-12-20  0:34       ` Katsumi Yamaoka
2023-12-20 12:53         ` Eli Zaretskii
2023-12-21  0:39           ` Katsumi Yamaoka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b4mr0jsmahx.fsf@jpl.org \
    --to=yamaoka@jpl.org \
    --cc=67791@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).