* bug#74276: 30.0.90; undo does not account for overlays now that markers are not used
@ 2024-11-09 6:41 James Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-09 8:12 ` Eli Zaretskii
0 siblings, 1 reply; 5+ messages in thread
From: James Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-11-09 6:41 UTC (permalink / raw)
To: 74276; +Cc: karthikchikmagalur
- emacs -Q
- Type: abcdef
- C-a
- M-: (overlay-put (make-overlay (point) (+ (point) 3)) 'face 'highlight)
- Mark the text 'bcd' and delete it
- M-x undo (does not restore overlay correctly)
(The solution seems to me to be for undo to also store the overlay,
adjustment, and whether left, right or both boundaries are involved, and
use it)
--
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#74276: 30.0.90; undo does not account for overlays now that markers are not used
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
0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2024-11-09 8:12 UTC (permalink / raw)
To: James Thomas, Stefan Monnier; +Cc: karthikchikmagalur, 74276
> Cc: karthikchikmagalur@gmail.com
> Date: Sat, 09 Nov 2024 12:11:50 +0530
> From: James Thomas via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>
> - emacs -Q
> - Type: abcdef
> - C-a
> - M-: (overlay-put (make-overlay (point) (+ (point) 3)) 'face 'highlight)
> - Mark the text 'bcd' and delete it
> - M-x undo (does not restore overlay correctly)
>
> (The solution seems to me to be for undo to also store the overlay,
> adjustment, and whether left, right or both boundaries are involved, and
> use it)
This didn't work with the old implementation of overlays, either. I
just tested in Emacs 25 and I see the same results there.
Stefan, does undo restore overlays, and if so, how? I don't see
anything pertinent in the Undo section of the ELisp manual except the
reference to markers (which overlays don't have anymore). Did that
ever work, and if so, how? And how should it work now?
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#74276: 30.0.90; undo does not account for overlays now that markers are not used
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
0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-11-09 15:05 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: karthikchikmagalur, 74276, James Thomas
> 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.
Stefan
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#74276: 30.0.90; undo does not account for overlays now that markers are not used
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
0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2024-11-09 15:50 UTC (permalink / raw)
To: Stefan Monnier; +Cc: karthikchikmagalur, 74276, jimjoe
> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: James Thomas <jimjoe@gmx.net>, 74276@debbugs.gnu.org,
> karthikchikmagalur@gmail.com
> Date: Sat, 09 Nov 2024 10:05:51 -0500
>
> > 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.
But maybe we should add to undo the capability of restoring the
overlays.
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#74276: 30.0.90; undo does not account for overlays now that markers are not used
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
0 siblings, 0 replies; 5+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-11-14 15:36 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: karthikchikmagalur, 74276, jimjoe
>> > 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)))))))
🙂
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-11-14 15:36 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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.