unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* 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

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).