* Overlay boundaries and undo
@ 2024-11-07 22:48 Karthik Chikmagalur
2024-11-08 4:23 ` James Thomas
2024-11-08 7:22 ` Eli Zaretskii
0 siblings, 2 replies; 7+ messages in thread
From: Karthik Chikmagalur @ 2024-11-07 22:48 UTC (permalink / raw)
To: emacs-devel
I'm trying to understand how overlay boundaries interact with undo. The
reason is that I'm tracking a region of a buffer with an overlay, and
would like to be able to restore overlay boundaries when text deleted at
the overlay boundary is reinserted via undo.
- When I delete some text in a range that includes an overlay boundary,
the overlay boundary is moved. This works as expected. In the
example below I deleted one character, ".", at the end of an overlay,
and the overlay boundary moved one character to the left.
- If I then undo, the deleted text is reinserted but the overlay
boundary is not moved back to its original position.
- Checking `buffer-undo-list', I see entries that look like this:
("." . -18)
(#<marker at 18 in *Scratch for fundamental-mode*> . -1)
(#<marker at 18 in *Scratch for fundamental-mode*> . -1)
(#<marker at 18 in *Scratch for fundamental-mode*> . -1)
(#<marker at 18 in *Scratch for fundamental-mode*> . -1)
(#<marker at 18 in *Scratch for fundamental-mode*> . -1)
(#<marker at 18 in *Scratch for fundamental-mode*> . -1)
(#<marker at 18 in *Scratch for fundamental-mode*> . -1)
[Several more duplicate entries of this type]
- From (info "(elisp) Undo"), it looks like these entries are of the
types
(TEXT . POSITION)
(MARKER . ADJUSTMENT)
1. Are the markers being adjusted above the overlay boundary markers?
If so, why are there so many marker adjustment entries for a one
character deletion?
2. The manual seems to suggest that when undoing, markers are moved back
to their original positions if the adjustments are compatible with the
corresponding text:
If the marker's location is consistent with the (TEXT . POSITION)
element preceding it in the undo list, then undoing this element
moves MARKER − ADJUSTMENT characters.
However this doesn't seem to happen. Is there some way to restore
overlay boundaries when undoing text deletions?
Thanks,
Karthik
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Overlay boundaries and undo
2024-11-07 22:48 Overlay boundaries and undo Karthik Chikmagalur
@ 2024-11-08 4:23 ` James Thomas
2024-11-08 7:22 ` Eli Zaretskii
1 sibling, 0 replies; 7+ messages in thread
From: James Thomas @ 2024-11-08 4:23 UTC (permalink / raw)
To: emacs-devel
Karthik Chikmagalur wrote:
> I'm trying to understand how overlay boundaries interact with undo.
> The reason is that I'm tracking a region of a buffer with an overlay,
> and would like to be able to restore overlay boundaries when text
> deleted at the overlay boundary is reinserted via undo.
> ...
> However this doesn't seem to happen. Is there some way to restore
> overlay boundaries when undoing text deletions?
Try with 'rear-advance' set as well, if you haven't.
--
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Overlay boundaries and undo
2024-11-07 22:48 Overlay boundaries and undo Karthik Chikmagalur
2024-11-08 4:23 ` James Thomas
@ 2024-11-08 7:22 ` Eli Zaretskii
2024-11-09 5:45 ` James Thomas
` (2 more replies)
1 sibling, 3 replies; 7+ messages in thread
From: Eli Zaretskii @ 2024-11-08 7:22 UTC (permalink / raw)
To: Karthik Chikmagalur; +Cc: emacs-devel
> From: Karthik Chikmagalur <karthikchikmagalur@gmail.com>
> Date: Thu, 07 Nov 2024 14:48:27 -0800
>
> I'm trying to understand how overlay boundaries interact with undo. The
> reason is that I'm tracking a region of a buffer with an overlay, and
> would like to be able to restore overlay boundaries when text deleted at
> the overlay boundary is reinserted via undo.
>
> - When I delete some text in a range that includes an overlay boundary,
> the overlay boundary is moved. This works as expected. In the
> example below I deleted one character, ".", at the end of an overlay,
> and the overlay boundary moved one character to the left.
>
> - If I then undo, the deleted text is reinserted but the overlay
> boundary is not moved back to its original position.
>
> - Checking `buffer-undo-list', I see entries that look like this:
>
> ("." . -18)
> (#<marker at 18 in *Scratch for fundamental-mode*> . -1)
> (#<marker at 18 in *Scratch for fundamental-mode*> . -1)
> (#<marker at 18 in *Scratch for fundamental-mode*> . -1)
> (#<marker at 18 in *Scratch for fundamental-mode*> . -1)
> (#<marker at 18 in *Scratch for fundamental-mode*> . -1)
> (#<marker at 18 in *Scratch for fundamental-mode*> . -1)
> (#<marker at 18 in *Scratch for fundamental-mode*> . -1)
> [Several more duplicate entries of this type]
>
> - From (info "(elisp) Undo"), it looks like these entries are of the
> types
>
> (TEXT . POSITION)
> (MARKER . ADJUSTMENT)
>
> 1. Are the markers being adjusted above the overlay boundary markers?
> If so, why are there so many marker adjustment entries for a one
> character deletion?
In what version of Emacs do you see this? The implementation of
overlays was fundamentally changed in Emacs 29, and one of the aspects
of that change was that overlays are not based on markers anymore.
> 2. The manual seems to suggest that when undoing, markers are moved back
> to their original positions if the adjustments are compatible with the
> corresponding text:
>
> If the marker's location is consistent with the (TEXT . POSITION)
> element preceding it in the undo list, then undoing this element
> moves MARKER − ADJUSTMENT characters.
>
> However this doesn't seem to happen. Is there some way to restore
> overlay boundaries when undoing text deletions?
Please show a reproducible recipe for investigating the issue you are
describing, and please do that in a bug report submitted via
"M-x report-emacs-bug" (which will collect important data about your
build and OS).
Thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Overlay boundaries and undo
2024-11-08 7:22 ` Eli Zaretskii
@ 2024-11-09 5:45 ` James Thomas
2024-11-09 6:48 ` James Thomas
2024-11-10 0:37 ` Karthik Chikmagalur
2 siblings, 0 replies; 7+ messages in thread
From: James Thomas @ 2024-11-09 5:45 UTC (permalink / raw)
To: emacs-devel
Eli Zaretskii wrote:
>> I'm trying to understand how overlay boundaries interact with undo. The
>> reason is that I'm tracking a region of a buffer with an overlay, and
>> would like to be able to restore overlay boundaries when text deleted at
>> the overlay boundary is reinserted via undo.
>>
>> - When I delete some text in a range that includes an overlay boundary,
>> the overlay boundary is moved. This works as expected. In the
>> example below I deleted one character, ".", at the end of an overlay,
>> and the overlay boundary moved one character to the left.
>>
>> - If I then undo, the deleted text is reinserted but the overlay
>> boundary is not moved back to its original position.
>> ...
>
> In what version of Emacs do you see this? The implementation of
> overlays was fundamentally changed in Emacs 29, and one of the aspects
> of that change was that overlays are not based on markers anymore.
If that's the case, undoing deletions that straddle overlay boundaries
would not restore the overlay, because the boundary position is lost.
I just tried it and it seems to be so.
--
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Overlay boundaries and undo
2024-11-08 7:22 ` Eli Zaretskii
2024-11-09 5:45 ` James Thomas
@ 2024-11-09 6:48 ` James Thomas
2024-11-09 8:14 ` Eli Zaretskii
2024-11-10 0:37 ` Karthik Chikmagalur
2 siblings, 1 reply; 7+ messages in thread
From: James Thomas @ 2024-11-09 6:48 UTC (permalink / raw)
To: emacs-devel
Eli Zaretskii wrote:
> Please show a reproducible recipe for investigating the issue you are
> describing, and please do that in a bug report submitted via
> "M-x report-emacs-bug" (which will collect important data about your
> build and OS).
I took the liberty: bug#74276.
--
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Overlay boundaries and undo
2024-11-09 6:48 ` James Thomas
@ 2024-11-09 8:14 ` Eli Zaretskii
0 siblings, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2024-11-09 8:14 UTC (permalink / raw)
To: James Thomas; +Cc: emacs-devel
> From: James Thomas <jimjoe@gmx.net>
> Date: Sat, 09 Nov 2024 12:18:50 +0530
>
> Eli Zaretskii wrote:
>
> > Please show a reproducible recipe for investigating the issue you are
> > describing, and please do that in a bug report submitted via
> > "M-x report-emacs-bug" (which will collect important data about your
> > build and OS).
>
> I took the liberty: bug#74276.
Thanks.
But you haven't used report-emacs-bug (so those important details
aren't in the report)...
We the veteran users and contributors to Emacs should practice what we
preach, IMNSHO.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Overlay boundaries and undo
2024-11-08 7:22 ` Eli Zaretskii
2024-11-09 5:45 ` James Thomas
2024-11-09 6:48 ` James Thomas
@ 2024-11-10 0:37 ` Karthik Chikmagalur
2 siblings, 0 replies; 7+ messages in thread
From: Karthik Chikmagalur @ 2024-11-10 0:37 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel
> In what version of Emacs do you see this? The implementation of
> overlays was fundamentally changed in Emacs 29, and one of the aspects
> of that change was that overlays are not based on markers anymore.
This is Emacs 29.4, on Linux, built with the Lucid toolkit.
I wasn't aware that overlays don't use markers anymore. Then it makes
sense that undo doesn't restore overlay boundaries.
>> 2. The manual seems to suggest that when undoing, markers are moved back
>> to their original positions if the adjustments are compatible with the
>> corresponding text:
>>
>> If the marker's location is consistent with the (TEXT . POSITION)
>> element preceding it in the undo list, then undoing this element
>> moves MARKER − ADJUSTMENT characters.
>>
>> However this doesn't seem to happen. Is there some way to restore
>> overlay boundaries when undoing text deletions?
>
> Please show a reproducible recipe for investigating the issue you are
> describing, and please do that in a bug report submitted via
> "M-x report-emacs-bug" (which will collect important data about your
> build and OS).
I see that James filed one already (bug#74276), so I'll add more
supporting details to it.
Karthik
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-11-10 0:37 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-07 22:48 Overlay boundaries and undo Karthik Chikmagalur
2024-11-08 4:23 ` James Thomas
2024-11-08 7:22 ` Eli Zaretskii
2024-11-09 5:45 ` James Thomas
2024-11-09 6:48 ` James Thomas
2024-11-09 8:14 ` Eli Zaretskii
2024-11-10 0:37 ` Karthik Chikmagalur
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).