GNU bug report logs - #64986
30.0.50; window-text-pixel-size sometimes returns 0 width when called from temporary buffer

Previous Next

Package: emacs;

Reported by: Ihor Radchenko <yantar92 <at> posteo.net>

Date: Tue, 1 Aug 2023 07:48:01 UTC

Severity: normal

Tags: confirmed

Found in version 30.0.50

Full log


Message #11 received at 64986 <at> debbugs.gnu.org (full text, mbox):

From: Ihor Radchenko <yantar92 <at> posteo.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 64986 <at> debbugs.gnu.org
Subject: Re: bug#64986: 30.0.50; window-text-pixel-size sometimes returns 0
 width when called from temporary buffer
Date: Tue, 01 Aug 2023 13:13:08 +0000
Eli Zaretskii <eliz <at> gnu.org> 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>




This bug report was last modified 1 year and 287 days ago.

Previous Next


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