From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: karthikchikmagalur@gmail.com, 74276@debbugs.gnu.org, jimjoe@gmx.net
Subject: bug#74276: 30.0.90; undo does not account for overlays now that markers are not used
Date: Thu, 14 Nov 2024 10:36:22 -0500 [thread overview]
Message-ID: <jwvh689ub0c.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <865xowmmo8.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 09 Nov 2024 17:50:15 +0200")
>> > Stefan, does undo restore overlays, and if so, how?
>> No, I don't think `undo` has ever tried to restore overlays.
>> But it does attempt to restore marker positions, so I guess there can be
>> cases where the switch to itree has caused overlays' boundaries to be
>> restored less well than before.
> Well, in this particular recipe Emacs 29 and 30 behave exactly like
> Emacs 25, do at least in this case there was no regression.
Which suggests that maybe the code we have to save/restore the position of
markers in `buffer-undo-list` doesn't(didn't?) really do its job.
> But maybe we should add to undo the capability of restoring the
> overlays.
Maybe.
Stefan
PS: Reading the `record_marker_adjustments` in Emacs-28, it seems that
this code would happily add to the `buffer-undo-list` markers that were
"internal" to overlays. That reminds me of a discussion many years ago
where I suggested we add functions to return the begin/end markers of an
overlay so that ELisp code could use `set-marker-insertion-type` to
change the insertion type of the beginning/end of an overlay (which is
currently otherwise fixed at creation). This was rejected because
exposing such internals would be undesirable (e.g. making
backward-incompatible the change we implemented in Emacs-29) and risky
(allowing inconsistencies like overlays whose beg and end don't point to
the same buffer). It turns out that such functions could have been
hacked all along in ELisp by (ab)using this `record_marker_adjustments`
code:
(defun overlay-markers (ol)
"Return the two markers of an overlay as (BEG . END)."
(with-temp-buffer
(insert "aa")
(let ((beg (point))
(_ (insert "bbb"))
(end (point)))
(insert "cccc")
(move-overlay ol beg end (current-buffer))
(let ((buffer-undo-list ()))
(delete-region (point-min) (point-max))
(cons (car (rassq -2 buffer-undo-list))
(car (rassq -5 buffer-undo-list)))))))
🙂
prev parent reply other threads:[~2024-11-14 15:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-09 6:41 bug#74276: 30.0.90; undo does not account for overlays now that markers are not used James Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-09 8:12 ` Eli Zaretskii
2024-11-09 15:05 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-09 15:50 ` Eli Zaretskii
2024-11-14 15:36 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvh689ub0c.fsf-monnier+emacs@gnu.org \
--to=bug-gnu-emacs@gnu.org \
--cc=74276@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=jimjoe@gmx.net \
--cc=karthikchikmagalur@gmail.com \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.