all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jim Porter <jporterbugs@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: R.Stewart@hw.ac.uk, 72771@debbugs.gnu.org, kevin.legouguec@gmail.com
Subject: bug#72771: 31.0.50; shr html renderer throwing "Specified window is not displaying the current buffer"
Date: Sat, 24 Aug 2024 10:10:06 -0700	[thread overview]
Message-ID: <a258d8b9-70e0-1d3d-ea65-7b01fc8d476a@gmail.com> (raw)
In-Reply-To: <867cc6pi5b.fsf@gnu.org>

On 8/23/2024 11:08 PM, Eli Zaretskii wrote:
>> Date: Fri, 23 Aug 2024 15:39:00 -0700
>> Cc: Rob Stewart <R.Stewart@hw.ac.uk>, 72771@debbugs.gnu.org
>> From: Jim Porter <jporterbugs@gmail.com>
>>
>> Here's a patch. I've tested this in a few configurations (in the current
>> window, in a buffer that's not being displayed, in a terminal Emacs) and
>> it all seems to work.
>>
>> One question, Eli: is there a better way than I'm using to get the font
>> that would be used for a character in the buffer? When the buffer is
>> being displayed in a window, '(font-at position window)' works, but that
>> doesn't address this bug, where the buffer isn't displayed. (The font
>> that we get back doesn't have to be 100% accurate; just a good guess
>> should be fine for this case.)
> 
> AFAIU, the code needs the width of the space character of a font used
> to show some text, is that correct?

Close, it needs the "average width", since the goal is to make a pixel 
specification like "(1.23 . width)". Based on my reading of 
'calc_pixel_width_or_height' in xdisp.c, the average width is the value 
the display engine uses for the 'width' unit.

> And the patch solves the problem of font-at by pretending that the
> relevant text is displayed in the current window, is that correct?

Yep. I figure there's a very good chance that the text in question 
(which is already in the current buffer) will soon be displayed in the 
current window, or failing that, a different window in the same frame. 
So it seemed like an ok guess to me. (Also, even if we guess wrong, 
things should usually look fine; it would only fail with certain 
pathological fonts, and even then it would just be a slight visual 
misalignment.)

> Alternatives to the solution in the patch are:

Thanks for the suggestions. (I reordered the list below when replying.)

>   . use the font obtained from (face-font 'default) (or the actual face
>     of the text, if you can get at it easily), like this:
> 
>        (aref (font-info (face-font 'default)) 10)

I think the problem is getting the actual face, which works for simple 
cases via 'get-text-property', but not for more complex ones, e.g. when 
the 'face' property is a list; 'face-font' raises an error in that case. 
Effectively what I want would be a Lisp version of 
'face_at_buffer_position', but that requires a window object anyway, so 
I'm back to the original problem...

>   . temporarily display the buffer in some window (if there is already
>     a window showing the buffer, use with-selected-window)

That could work, though I think it ends up being just as much code 
complexity as my current patch, and it might perform worse with all the 
temporary window-switching...

>   . use buffer-text-pixel-size or string-pixel-width to measure the
>     width of a string of a single SPC character

I think this wouldn't work since I want the average font width, not the 
width of SPC.

In light of the above, I think what I have now might be the best way to 
do it for the time being, unless my comments above gave you another idea 
for an alternative. If not, do you have any objections to me merging 
this patch?





  reply	other threads:[~2024-08-24 17:10 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-23  8:15 bug#72771: 31.0.50; shr html renderer throwing "Specified window is not displaying the current buffer" Rob Stewart via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-23  9:13 ` Rob Stewart via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-23 13:12 ` Eli Zaretskii
2024-08-23 17:10   ` Kévin Le Gouguec
2024-08-23 22:39     ` Jim Porter
2024-08-24  6:08       ` Eli Zaretskii
2024-08-24 17:10         ` Jim Porter [this message]
2024-08-24 19:01           ` Eli Zaretskii
2024-08-24 19:42             ` Jim Porter
2024-08-25  5:05               ` Eli Zaretskii
2024-08-25  6:11                 ` Jim Porter
2024-08-25  6:22                   ` Eli Zaretskii
2024-08-25 17:18                     ` Jim Porter
2024-08-25 17:49                       ` Eli Zaretskii
2024-08-25 18:51                         ` Jim Porter

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

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

  git send-email \
    --in-reply-to=a258d8b9-70e0-1d3d-ea65-7b01fc8d476a@gmail.com \
    --to=jporterbugs@gmail.com \
    --cc=72771@debbugs.gnu.org \
    --cc=R.Stewart@hw.ac.uk \
    --cc=eliz@gnu.org \
    --cc=kevin.legouguec@gmail.com \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.