Subject: Re: bug#76107: Consider image specs when scanning for a column

From: Eli Zaretskii <[email-masked]>
Date: Fri, 07 Feb 2025 10:10:45 +0200

> From: Thuna <[email-masked]>
> Date: Fri, 07 Feb 2025 00:29:38 +0100
> 
> This patch handles display specs within `scan_for_column', which mainly
> works to handle it in `current-column' and `move-to-column', which then
> effects the filling functions and commands, and visual-fill-column, and
> so on.
> 
> The patch seems to be working, as far as I can tell, but it would be
> nice if someone could take a look.  Specifically, I copied the code to
> convert the Lisp_Object holding the width into an integer from the code
> above handling the space display properties, so that needs
> double-checking.
> 
> I decided to use `Fcar_safe' instead of `XCAR' when taking the `car' of
> `Fimage_size' just to be safe but it doesn't look to be necessary?  If
> that's fine, then feel free to make the change.

Thanks, but I don't see how this could work with just this code.  The
display property that uses images could be much more complex than just
giving the image file name or data.  First, there's the 'slice'
display spec, which shows a slice of an image.  More importantly, the
IMAGE-SPEC part of the display property could include properties that
affect the size of the image on display, and Fimage_size doesn't
necessarily take them into consideration, AFAIR.  Which image
properties that can appear in an image spec did you try with this
patch?  And finally, images are clipped on display when they exceed
the length of a screen line, which Fimage_size doesn't take into
consideration, because it doesn't know at which horizontal coordinate
the image will be shown.

So I'm afraid fixing check_display_width to support images will need
to simulate the display, i.e. use the move_it_* functions defined in
xdisp.c; just taking the image's size is not enough.  Or maybe you
could use Fbuffer_text_pixel_size (which needs a window to do its
calculations, which is another complication of supporting images in
this case).