[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to temporarily show an image in an Emacs buffer?
From: |
Ruijie Yu |
Subject: |
Re: How to temporarily show an image in an Emacs buffer? |
Date: |
Wed, 08 Mar 2023 14:19:10 +0800 |
User-agent: |
mu4e 1.8.14; emacs 30.0.50 |
Marcin Borkowski <mbork@mbork.pl> writes:
> On 2023-03-08, at 05:53, Marcin Borkowski <mbork@mbork.pl> wrote:
>
>> Alternatively, it _may_ change the buffer contents but in a way that is
>> not recorded in `buffer-undo-list'. Is that possible?
>
> I did some experimenting, and this
>
> (defvar no-undo-marker (make-marker))
> (defun no-undo-insert ()
> "Test undo."
> (save-excursion
> (let ((buffer-undo-list))
> (set-marker no-undo-marker (point))
> (insert "this can't be undone\n"))))
>
> (defun no-undo-uninsert ()
> (save-excursion
> (goto-char no-undo-marker)
> (let ((buffer-undo-list))
> (when (looking-at-p "this can't be undone\n")
> (delete-char 21)))))
>
> seems to do the trick, but depending on the order of typing and calling
> these functions, the undo list becomes corrupted (I get "primitive-undo:
> Changes to be undone are outside visible portion of buffer").
>
> Any hints?
Maybe you can make use of overlays [1]? That sounds like a great fit
according to the description of your need.
[1]: (info "(elisp) Managing Overlays")
--
Best,
RY
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?, Stefan Monnier, 2023/03/10