Subject: Re: bug#46464: 27.1; wide images are hidden partially at the right edge of window

From: [email-masked]
Date: Mon, 15 Feb 2021 22:40:56 +0900

Eli Zaretskii <[email-masked]> writes:

>> From: [email-masked]
>> Cc: [email-masked]
>> Date: Sun, 14 Feb 2021 23:30:27 +0900
>> 
>> > This is the intended behavior: Emacs silently crops images that don't
>> > fit on their screen line.
>> 
>> What means by "images that don't fit on their screen line"?
>
> It means the image is wider than the space left on the screen line
> from the image's position to the edge of the window.
>
>> If a edge of a image is near the right edge of the window,
>> the image is mostly hidden. It is not preferable.
>
> That's how Emacs behaved since v21.

If the width of the iamge is 200 pixels, typing some characters at the
beginning of the same line, the image moves to the right and gets hidden
gradually and is wrapped to the next visual line.

If the width of the image is 150 pixels, the entire image does not get
hidden and it is wrapped when the image right edge is going to across
the right edge of the window.

What is the difference?

>> And if :margin is specified, the image may be hidden completely.
>> 
>> By the way, if :margin is specified, a partial image on the right edge
>> of the window is displayed with right margin.
>
> I don't think I understand what you mean by that.  Can you show a test
> case?

Evaluating the form below, four images are supposed to be displayed in
the first visual line. But the fourth image is invisible. Similar for
the second visual line.

If ':margin 5' is replaced with ':margin 20', three images are displayed
in the first to third visual lines. Third image in each visual line is
truncated at the x-coordinate 20 pixels apart from the right edge of the
window. It looks as if the image is not truncated and is small.

(dotimes (i 10)
  (let* ((w 200) (h 30) (sw 6)
         (color (nth (% i 5) '("red" "green" "blue" "yellow" "orange")))
         (svg (format "<svg width=\"%g\" height=\"%g\"
 version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">
<rect x=\"%g\" y=\"%g\" width=\"%g\" height=\"%g\" stroke=\"%s\"
 stroke-width=\"%g\" fill=\"grey\"/>
</svg>" w h (/ sw 2) (/ sw 2) (- w sw) (- h sw) color sw)))
    (insert-image (create-image svg 'svg t :margin 5 :scale 1))))