[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to temporarily show an image in an Emacs buffer?
From: |
Marcin Borkowski |
Subject: |
Re: How to temporarily show an image in an Emacs buffer? |
Date: |
Wed, 08 Mar 2023 17:00:11 +0100 |
User-agent: |
mu4e 1.1.0; emacs 30.0.50 |
On 2023-03-08, at 14:38, Eli Zaretskii <eliz@gnu.org> wrote:
>> From: Marcin Borkowski <mbork@mbork.pl>
>> Date: Wed, 08 Mar 2023 05:53:46 +0100
>>
>> I need to insert an image in the buffer in a way that doesn't interfere
>> with the undo mechanism. In other words, `insert-image' won't help me
>> because (as I understand it) it needs to insert a space or some other
>> string so that it can put display property on it. How to achieve this?
>
> You can put a display property on the existing text in the buffer
> without inserting any new text. See the node "Other Display
> Properties" in the ELisp manual, where it describes the
> ‘(image . IMAGE-PROPS)’ display property spec.
You're right, of course, but it's a bit more complex than that. Since
an overlay with the `image' property "hides" the text beneath it, the
key is to create an overlay with a `before-string' property whose value
is a dummy string (say, a space), and put the `image' /text/ property on
that very string. I did some experiments and it seems to work, though
I'll have a (hopefully) working prototype by the end of the week (no
more time for this today).
Thanks a lot! (Also, once I have it working, I will definitely describe
it on my blog; I may also copy it here if someone is interested.)
Best,
--
Marcin Borkowski
http://mbork.pl
Re: How to temporarily show an image in an Emacs buffer?, Eli Zaretskii, 2023/03/08
- Re: How to temporarily show an image in an Emacs buffer?,
Marcin Borkowski <=
Re: How to temporarily show an image in an Emacs buffer?, Stefan Monnier, 2023/03/10