GNU logs - #64986, boring messages


Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#64986: 30.0.50; window-text-pixel-size sometimes returns 0 width when called from temporary buffer
Resent-From: Ihor Radchenko <yantar92@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Tue, 01 Aug 2023 07:48:01 +0000
Resent-Message-ID: <handler.64986.B.169087605428146 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 64986
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 64986 <at> debbugs.gnu.org
X-Debbugs-Original-To: bug-gnu-emacs@HIDDEN
Received: via spool by submit <at> debbugs.gnu.org id=B.169087605428146
          (code B ref -1); Tue, 01 Aug 2023 07:48:01 +0000
Received: (at submit) by debbugs.gnu.org; 1 Aug 2023 07:47:34 +0000
Received: from localhost ([127.0.0.1]:47107 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qQk6P-0007Jt-UC
	for submit <at> debbugs.gnu.org; Tue, 01 Aug 2023 03:47:34 -0400
Received: from lists.gnu.org ([2001:470:142::17]:58600)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <yantar92@HIDDEN>) id 1qQk6O-0007Jf-3t
 for submit <at> debbugs.gnu.org; Tue, 01 Aug 2023 03:47:32 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <yantar92@HIDDEN>)
 id 1qQk6I-0004su-TV
 for bug-gnu-emacs@HIDDEN; Tue, 01 Aug 2023 03:47:26 -0400
Received: from mout01.posteo.de ([185.67.36.65])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <yantar92@HIDDEN>)
 id 1qQk6G-0001C8-D3
 for bug-gnu-emacs@HIDDEN; Tue, 01 Aug 2023 03:47:26 -0400
Received: from submission (posteo.de [185.67.36.169]) 
 by mout01.posteo.de (Postfix) with ESMTPS id C8B91240028
 for <bug-gnu-emacs@HIDDEN>; Tue,  1 Aug 2023 09:47:21 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
 t=1690876041; bh=dIcgUhnuolgVext6gDl+gdy6cGtGkBfEiEmUwOncPPA=;
 h=From:To:Subject:Date:Message-ID:MIME-Version:From;
 b=U2tZxXOqCAsInmOUc4SaH81pTed6si5chlBuHXRMlkQr1dnYRSdrudrd6Z+CH1OTm
 4sGj1HUyT5Ml/XnOUTKd6TkXBjB23iskFZn5G3bKlGJ/0WKJYfVpmt20TFZ235cazw
 7AaHpEi+QTUkORQfh3C6HUmPbcRk/hQJd2ceTqmelrHwJgVhAXvWumniriewNENlM2
 Sv/T72f3XLRRWFfJIkkDVvloXHI7LgZCNM1Eqg676kjD4dfq4NEI8/kcI3lRoEddet
 dijlE6Oub2G42hZYtSQIlRRFIAhwRFNWxZ4SRg+cM2uSA0wyRfzOrHgLtG7OVmfZGb
 nzUG0Lhk2jffQ==
Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4RFRyx11VGz9sH8
 for <bug-gnu-emacs@HIDDEN>; Tue,  1 Aug 2023 09:47:20 +0200 (CEST)
From: Ihor Radchenko <yantar92@HIDDEN>
Date: Tue, 01 Aug 2023 07:47:32 +0000
Message-ID: <87o7jrgq5n.fsf@localhost>
MIME-Version: 1.0
Content-Type: text/plain
Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@HIDDEN;
 helo=mout01.posteo.de
X-Spam_score_int: -53
X-Spam_score: -5.4
X-Spam_bar: -----
X-Spam_report: (-5.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01,
 SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.0 (+)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

Hi,

I stumbled upon apparently unexpected return value of
`window-text-pixel-size'. There is no easy reproducer involving emacs
-Q, but I can reliably reproduce it with certain variant of
`org-string-width' function. I am not 100% sure if it is a real Emacs
bug or if it is my misunderstanding of `window-text-pixel-size'.

Steps to reproduce:

1. git clone --depth 1 --branch bug/window-text-pixel-size https://git.sr.ht/~yantar92/org-mode
2. cd org-mode
3. make repro REPRO_ARGS="-l ./testing/org-test.el"
4. (setq org-confirm-babel-evaluate nil)
5. M-x debug-on-entry org-string-width
6. Insert and execute the following in *scratch*

  (org-test-with-temp-text-in-file "

#+NAME: example-list
- simple
  - not
  - nested
- list

<point>#+BEGIN_SRC emacs-lisp :var x=example-list
(print x)
#+END_SRC"

    (should (equal '("simple" "list") (org-babel-execute-src-block)))
    (forward-line 5)
    (should (string=
             "| simple | list |"
             (buffer-substring
	      (point-at-bol)
	      (point-at-eol)))))

7. If we "c" in the debugger, there is arith error originating from the
   second call to `window-text-pixel-size' returning (0 . X) in buffer
   containing text "a".

The code of `org-string-width' is:

(defun org-string-width (string &optional pixels)
  "Return width of STRING when displayed in the current buffer.
Return width in pixels when PIXELS is non-nil."
       ....
      (with-current-buffer (get-buffer-create " *Org string width*")
        (setq-local display-line-numbers nil
                    line-prefix nil
                    wrap-prefix nil)
        (setq-local buffer-invisibility-spec
                    (if (listp current-invisibility-spec)
                        (mapcar (lambda (el)
                                  ;; Consider ellipsis to have 0 width.
                                  ;; It is what Emacs 28+ does, but we have
                                  ;; to force it in earlier Emacs versions.
                                  (if (and (consp el) (cdr el))
                                      (list (car el))
                                    el))
                                current-invisibility-spec)
                      current-invisibility-spec))
        (setq-local char-property-alias-alist
                    current-char-property-alias-alist)
        (let (pixel-width symbol-width)
          (with-silent-modifications
            (erase-buffer)
            (insert string)
            (setq pixel-width
                  (car (window-text-pixel-size
                        nil (line-beginning-position) (point-max))))
            (unless pixels
              (erase-buffer)
              (insert "a")
              (setq symbol-width
                    (car (window-text-pixel-size ;; <---- unexpected return
                          nil (line-beginning-position) (point-max))))))
          (if pixels
              pixel-width
            (/ pixel-width symbol-width)))))))

In GNU Emacs 30.0.50 (build 5, x86_64-pc-linux-gnu, GTK+ Version
 3.24.38, cairo version 1.17.8) of 2023-07-29 built on localhost
Repository revision: ce48073f1597ceecb82800e71c89b53badc9f9d0
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101008
System Description: Gentoo Linux

Configured using:
 'configure --with-native-compilation'


-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>




Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Ihor Radchenko <yantar92@HIDDEN>
Subject: bug#64986: Acknowledgement (30.0.50; window-text-pixel-size
 sometimes returns 0 width when called from temporary buffer)
Message-ID: <handler.64986.B.169087605428146.ack <at> debbugs.gnu.org>
References: <87o7jrgq5n.fsf@localhost>
X-Gnu-PR-Message: ack 64986
X-Gnu-PR-Package: emacs
Reply-To: 64986 <at> debbugs.gnu.org
Date: Tue, 01 Aug 2023 07:48:01 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

Your message has been sent to the package maintainer(s):
 bug-gnu-emacs@HIDDEN

If you wish to submit further information on this problem, please
send it to 64986 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
64986: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D64986
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems


Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#64986: 30.0.50; window-text-pixel-size sometimes returns 0 width when called from temporary buffer
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Tue, 01 Aug 2023 12:08:01 +0000
Resent-Message-ID: <handler.64986.B64986.169089167832203 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 64986
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Ihor Radchenko <yantar92@HIDDEN>
Cc: 64986 <at> debbugs.gnu.org
Received: via spool by 64986-submit <at> debbugs.gnu.org id=B64986.169089167832203
          (code B ref 64986); Tue, 01 Aug 2023 12:08:01 +0000
Received: (at 64986) by debbugs.gnu.org; 1 Aug 2023 12:07:58 +0000
Received: from localhost ([127.0.0.1]:47353 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qQoAP-0008NK-OA
	for submit <at> debbugs.gnu.org; Tue, 01 Aug 2023 08:07:58 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:53966)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1qQoAL-0008N6-I9
 for 64986 <at> debbugs.gnu.org; Tue, 01 Aug 2023 08:07:55 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1qQoAG-0008Rq-3Q; Tue, 01 Aug 2023 08:07:48 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=Zk9QHSFlD4QOcUquM3FX0IJnN2aj4irK7vDUgMnSkRE=; b=qq1vEH4Kw85G
 LLCcuinJj6CkiEuOtdQTw0xpP+yrWT4vPuseCgaG10tInQSn1bDTRQj/i5sqL7Kbu6/9LtwMad0y8
 OjIBRXsvCpQ4ISz2WT6NjVxrJVB27SoPboimZj/m4MAp6l3Xs1lELy5aHgs5CE8rUrh6WStf7WmA8
 IvUYlCUe5CHwtLCzdOpMFqraMkH9m8xway658WRXMR5Nc8CJN1TNzcS0Qma3+k5t+5NG8p7FSOHvD
 VfITCmT7pJJJeqviIPE+MqaEWQusTtnV5uVfPrsimVLTM4FZKNP6yT8qpdLl6tPYhHRM1gu9AJFee
 aNi13csEnyJGVBSp19e+9g==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1qQoAF-0004c5-GH; Tue, 01 Aug 2023 08:07:47 -0400
Date: Tue, 01 Aug 2023 15:07:52 +0300
Message-Id: <83pm470xuv.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <87o7jrgq5n.fsf@localhost> (message from Ihor Radchenko on Tue,
 01 Aug 2023 07:47:32 +0000)
References: <87o7jrgq5n.fsf@localhost>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Ihor Radchenko <yantar92@HIDDEN>
> Date: Tue, 01 Aug 2023 07:47:32 +0000
> 
>       (with-current-buffer (get-buffer-create " *Org string width*")
>         (setq-local display-line-numbers nil
>                     line-prefix nil
>                     wrap-prefix nil)
>         (setq-local buffer-invisibility-spec
>                     (if (listp current-invisibility-spec)
>                         (mapcar (lambda (el)
>                                   ;; Consider ellipsis to have 0 width.
>                                   ;; It is what Emacs 28+ does, but we have
>                                   ;; to force it in earlier Emacs versions.
>                                   (if (and (consp el) (cdr el))
>                                       (list (car el))
>                                     el))
>                                 current-invisibility-spec)
>                       current-invisibility-spec))
>         (setq-local char-property-alias-alist
>                     current-char-property-alias-alist)
>         (let (pixel-width symbol-width)
>           (with-silent-modifications
>             (erase-buffer)
>             (insert string)
>             (setq pixel-width
>                   (car (window-text-pixel-size
>                         nil (line-beginning-position) (point-max))))
>             (unless pixels
>               (erase-buffer)
>               (insert "a")
>               (setq symbol-width
>                     (car (window-text-pixel-size ;; <---- unexpected return
>                           nil (line-beginning-position) (point-max))))))
>           (if pixels
>               pixel-width
>             (/ pixel-width symbol-width)))))))

You are using window-text-pixel-size incorrectly.  Its doc string
says:

   Return the size of the text of WINDOW's buffer in pixels.

Note the "WINDOW's buffer" part: it is there for a reason.

So what your code is doing is measure the size of the text of the
buffer shown in WINDOW (in your case, the selected window) between
buffer positions 1 and 2.  And the buffer shown in the selected
window, the one created by org-test-with-temp-text-in-file, begins
with an empty line, so the function correctly returns zero as the
horizontal dimensions of the text.

Your code seems to assume that with-current-buffer makes the named
buffer be "temporarily shown" in the selected window, but that is not
what happens: it just makes that buffer the current buffer.

This tricky part is why we now have buffer-text-pixel-size: it takes
care of making the buffer "temporarily shown" in the window.  So I
believe you should use that function instead.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#64986: 30.0.50; window-text-pixel-size sometimes returns 0 width when called from temporary buffer
Resent-From: Ihor Radchenko <yantar92@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Tue, 01 Aug 2023 13:14:01 +0000
Resent-Message-ID: <handler.64986.B64986.169089558315961 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 64986
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>
Cc: 64986 <at> debbugs.gnu.org
Received: via spool by 64986-submit <at> debbugs.gnu.org id=B64986.169089558315961
          (code B ref 64986); Tue, 01 Aug 2023 13:14:01 +0000
Received: (at 64986) by debbugs.gnu.org; 1 Aug 2023 13:13:03 +0000
Received: from localhost ([127.0.0.1]:47389 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qQpBP-00049N-7B
	for submit <at> debbugs.gnu.org; Tue, 01 Aug 2023 09:13:03 -0400
Received: from mout01.posteo.de ([185.67.36.65]:35745)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <yantar92@HIDDEN>) id 1qQpBN-00048s-Ov
 for 64986 <at> debbugs.gnu.org; Tue, 01 Aug 2023 09:13:02 -0400
Received: from submission (posteo.de [185.67.36.169]) 
 by mout01.posteo.de (Postfix) with ESMTPS id B1887240029
 for <64986 <at> debbugs.gnu.org>; Tue,  1 Aug 2023 15:12:55 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
 t=1690895575; bh=p/nRSL2ShaxAwOUs0dzUvuDYJrclXyfrXqz4k5+0ZWY=;
 h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From;
 b=nc8q2nx/9CEkSDO511wd36DfFrT6TOm+8ZqBsPc9X9b7G9m2hnF5cYEfyJFbZoLt9
 n4s7n0L83JbWSDXBsXIj7DH3+Kz4NNXlJ3j8PNVnylY1FpjaplMkxb9IgO3aqUV/cj
 hHNlfhU1qb9HXpmXAdM8tY2tQOlAUJmvCNTPl5xqc3VRxk7w/An8Tl8C5SH6pEgvcp
 jJViIdbNOq5RcE8nY7I5pj7DbmA7FeysXNpvl6w0a1Zy1ION29sOeZn3m95gIukzs/
 G+4o+RW+eulk0s52GSrkXL6iT3EcMHYhL/icYJe8Mqo4rUcDICyp7rrhqhkQXIXacd
 dLryucjpswOyA==
Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4RFbBZ37Sqz9rxD;
 Tue,  1 Aug 2023 15:12:54 +0200 (CEST)
From: Ihor Radchenko <yantar92@HIDDEN>
In-Reply-To: <83pm470xuv.fsf@HIDDEN>
References: <87o7jrgq5n.fsf@localhost> <83pm470xuv.fsf@HIDDEN>
Date: Tue, 01 Aug 2023 13:13:08 +0000
Message-ID: <87edkmq523.fsf@localhost>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -3.3 (---)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -4.3 (----)

Eli Zaretskii <eliz@HIDDEN> writes:

> So what your code is doing is measure the size of the text of the
> buffer shown in WINDOW (in your case, the selected window) between
> buffer positions 1 and 2.  And the buffer shown in the selected
> window, the one created by org-test-with-temp-text-in-file, begins
> with an empty line, so the function correctly returns zero as the
> horizontal dimensions of the text.

Ouch! Thanks for the explanation.

> This tricky part is why we now have buffer-text-pixel-size: it takes
> care of making the buffer "temporarily shown" in the window.  So I
> believe you should use that function instead.

Indeed. We previously used `set-window-buffer' as in shr.el, but that
felt like an awkward workaround because it can sometimes err when
selected-window is dedicated.

I am wondering if `shr-pixel-buffer-width' and `shr-pixel-column' should
also use `buffer-text-pixel-size'. The `(set-window-dedicated-p nil
nil)` is not nice as it could override user customization.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#64986: 30.0.50; window-text-pixel-size sometimes returns 0 width when called from temporary buffer
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Thu, 03 Aug 2023 08:56:01 +0000
Resent-Message-ID: <handler.64986.B64986.169105293412738 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 64986
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Ihor Radchenko <yantar92@HIDDEN>, Lars Ingebrigtsen <larsi@HIDDEN>
Cc: 64986 <at> debbugs.gnu.org
Received: via spool by 64986-submit <at> debbugs.gnu.org id=B64986.169105293412738
          (code B ref 64986); Thu, 03 Aug 2023 08:56:01 +0000
Received: (at 64986) by debbugs.gnu.org; 3 Aug 2023 08:55:34 +0000
Received: from localhost ([127.0.0.1]:50852 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qRU7J-0003JN-TL
	for submit <at> debbugs.gnu.org; Thu, 03 Aug 2023 04:55:34 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:36138)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1qRU7I-0003JA-1g
 for 64986 <at> debbugs.gnu.org; Thu, 03 Aug 2023 04:55:32 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1qRU7B-0005QO-Io; Thu, 03 Aug 2023 04:55:25 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=SS1tFpmEBJZCnEd/laXyZzTGl1BrHeQrRASBaYhjkco=; b=PO5TI0mwJ939
 740SeJTXPAjGwhddoWtOh6nHjA2zeWHAU1VRGaok7Zw0f68FN3tWqn52krct2rKiMTFckcuZI+Itv
 ZfJ/7jPJgK4m+i1dSPtADKs2kmUEerwvyjATIPRSOg3oSR2lu9CbM7043GFl2hgINQXoh2NQKtnHC
 7nRcoycvSp/9zOyQW7pDJNuwj1mvaoV4exZiAXp9fEdbu48GPf1nBGG4OkjXkFWCXSSL/m9IFhxuz
 Rqwug+mgXX/EYC3hRvIoBJgX5J7LIl2a6sLOg/82pP9porBArPOVLGsDDXsF8Lf3RjZdd6orohUkm
 WzUAs9JslCNj/LLBuM4KPw==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1qRU7B-0002GA-23; Thu, 03 Aug 2023 04:55:25 -0400
Date: Thu, 03 Aug 2023 11:55:35 +0300
Message-Id: <83fs50y06w.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <87edkmq523.fsf@localhost> (message from Ihor Radchenko on Tue,
 01 Aug 2023 13:13:08 +0000)
References: <87o7jrgq5n.fsf@localhost> <83pm470xuv.fsf@HIDDEN>
 <87edkmq523.fsf@localhost>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Ihor Radchenko <yantar92@HIDDEN>
> Cc: 64986 <at> debbugs.gnu.org
> Date: Tue, 01 Aug 2023 13:13:08 +0000
> 
> Eli Zaretskii <eliz@HIDDEN> writes:
> 
> > This tricky part is why we now have buffer-text-pixel-size: it takes
> > care of making the buffer "temporarily shown" in the window.  So I
> > believe you should use that function instead.
> 
> Indeed. We previously used `set-window-buffer' as in shr.el, but that
> felt like an awkward workaround because it can sometimes err when
> selected-window is dedicated.
> 
> I am wondering if `shr-pixel-buffer-width' and `shr-pixel-column' should
> also use `buffer-text-pixel-size'. The `(set-window-dedicated-p nil
> nil)` is not nice as it could override user customization.

Probably.  Patches to that effect are welcome.




Message received at control <at> debbugs.gnu.org:


Received: (at control) by debbugs.gnu.org; 1 Sep 2023 20:31:51 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Sep 01 16:31:51 2023
Received: from localhost ([127.0.0.1]:34145 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qcAo3-0002Hk-Hu
	for submit <at> debbugs.gnu.org; Fri, 01 Sep 2023 16:31:51 -0400
Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]:44078)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <stefankangas@HIDDEN>) id 1qcAo0-0002HV-Qd
 for control <at> debbugs.gnu.org; Fri, 01 Sep 2023 16:31:49 -0400
Received: by mail-lf1-x136.google.com with SMTP id
 2adb3069b0e04-500aed06ffcso4023147e87.0
 for <control <at> debbugs.gnu.org>; Fri, 01 Sep 2023 13:31:39 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20221208; t=1693600293; x=1694205093; darn=debbugs.gnu.org;
 h=to:subject:message-id:date:from:mime-version:from:to:cc:subject
 :date:message-id:reply-to;
 bh=XzRqvMYNus//0k9JaKtBNIpYX9fX3iAr+E/nkyphrjI=;
 b=J/gzVCoxRHhcY+EKAK10hbgaTqC2Ayl7ZjnSmVN22zm9ZaOUFXk+I11Am7eTiltga9
 UndjJM/Q27EBQKI6AwrlVrNLHWDh4LLqO93iZLHgacfYWp6nPmRSsovt2JTe7pzSmGUF
 qy89xVIb9SfGGlxcRQ0JlZg9ALV8th6F4GZl0fZfYvrWyje1LQr6w5wetTApzo7rPyta
 moGv1VL6ZsZ7awfhQBtkCPrTBxEasp+WPdy4hyqbzib1Rc0jNfDXgQOOkqk9T+0aVejg
 SA0A9MTKroQbRBln/K3+pSooH+6sL9ez6b4sBA/LKncQ/Y1xnSJy1rcyLvVS0/xgLlgr
 V+EA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20221208; t=1693600293; x=1694205093;
 h=to:subject:message-id:date:from:mime-version:x-gm-message-state
 :from:to:cc:subject:date:message-id:reply-to;
 bh=XzRqvMYNus//0k9JaKtBNIpYX9fX3iAr+E/nkyphrjI=;
 b=NATfydeJ6eavRZdKQ3yStPbq32hV/VUR/jB4lhuKdiFSy02fJkUkrEIf/+5u+4jHgy
 tQH4TEyvEstKXB9hw8QV19m6Ce8M0LYnWDkJAMglhLLRgrExGZuPbiKLFO3ZkW8QeBv3
 vYqabTtEw3cgiJlpsgSqMMNPWwgoCWZvbK991NS/5pk728yyONi3VruVuJn6+9sO0GLF
 nMoGosXCbjaBvHp66bZ2Vq9dChRHWuelNzJY5q/qEGrY5/WjtLS0XnI6lgSH6zONCR4p
 +B+SJMMn7EO9OIT3+8H4ppON0hH23reKkQSfI0lla0S+s13j3OjHQDDwEbqSnb5KI/4A
 01dQ==
X-Gm-Message-State: AOJu0YxcoW+YamotoFP5HnBtYyAG+ign0t4q2VBaNXVcuC3Jw+jGAHFB
 FcXG20iqIAlk/kCqpmY3lpo5THk5RqmK+vzUtzK6LRvSfHsNyg==
X-Google-Smtp-Source: AGHT+IE1NYouygS8ngeGE+P4eMDeAhCKsgjctqYZinACqLr0bDL5b+26KWp7ZpdoBTphZdbVD8A6QSH9zrlpGwihn5c=
X-Received: by 2002:a05:6512:202d:b0:500:982e:e2b4 with SMTP id
 s13-20020a056512202d00b00500982ee2b4mr2194117lfs.5.1693600293214; Fri, 01 Sep
 2023 13:31:33 -0700 (PDT)
MIME-Version: 1.0
From: Stefan Kangas <stefankangas@HIDDEN>
Date: Fri, 1 Sep 2023 22:31:22 +0200
Message-ID: <CADwFkmk2uJSQhhWh-RTNuJknFxw_Edayna9V7hHUHbSapPD1uA@HIDDEN>
Subject: 
To: control <control <at> debbugs.gnu.org>
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: 2.0 (++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview:  tags 64986 + confirmed thanks 
 Content analysis details:   (2.0 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.0 SPF_PASS               SPF: sender matches SPF record
 0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail
 provider (stefankangas[at]gmail.com)
 0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 -0.0 RCVD_IN_DNSWL_NONE     RBL: Sender listed at https://www.dnswl.org/,
 no trust [2a00:1450:4864:20:0:0:0:136 listed in]
 [list.dnswl.org]
 2.0 BLANK_SUBJECT          Subject is present but empty
X-Debbugs-Envelope-To: control
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

tags 64986 + confirmed
thanks





Last modified: Fri, 1 Sep 2023 20:45:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.