Subject: bug#62637: 29.0.60; Issues when displaying images

From: Al Haji-Ali <[email-masked]>
Date: Mon, 03 Apr 2023 19:30:38 +0100

Thanks Lars for explaining.

I understand the issue now regarding indentation. I think passing a non-empty string to `insert-image` in `mml-inline-image` (and maybe by default in `insert-image`?) would be better IMO.

Regarding the overlay visibility, the issue for me was the different behaviour of `put-image` and `insert-image` in different cases. Which can be seen in the following example:

(let (content-begin content-end
      (img (create-image "/tmp/tmp.png")))
  (goto-char (point-max))

  (insert "\ninsert-image:\n")
  (setq content-begin (point))
  (insert-image img "I")
  (insert "\n")
  (setq content-end (point))
  (overlay-put (make-overlay content-begin content-end) 'invisible t)

  (insert "\nput-image without new line:\n")
  (setq content-begin (point))
  (put-image img (point-marker))
  (setq content-end (point))
  (overlay-put (make-overlay content-begin content-end) 'invisible t)
  
  (insert "\nput-image with new line:\n")
  (setq content-begin (point))
  (put-image img (point-marker))
  (insert "\n")
  (setq content-end (point))
  (overlay-put (make-overlay content-begin content-end) 'invisible t))

This code tests overlay visibility for images with three cases:
- using insert-image: as you explained this does not work as expected.
- using put-image: Since put-images uses an overlay, I guess the same logic applies.
- put-image with a newline: Seems to work for some reason. This is what `mml-inline-image` was using before and why notmuch was working.

Sorry for the noise. I am not sure there's a bug in this case, only unjustified expectations as you put it.

Best regards,
-- Al

On 03/04/2023, Eli Zaretskii wrote:
>
>
>> Cc: [email-masked]
>> Date: Mon, 03 Apr 2023 16:35:02 +0300
>> From: Eli Zaretskii <[email-masked]>
>>
>> As for indentation: put-image uses a different default for the text on
>> which it puts the image 'display' property.  That explains why
>> re-indentation didn't remove the image in Emacs 28.
>
> Actually, put-image uses an overlay string with the 'display'
> property, so it doesn't put the property on buffer text, and thus
> re-indentation doesn't affect it.