From: Barry OReilly <gundaetiapo@gmail.com>
To: 17235@debbugs.gnu.org
Subject: bug#17235: Undo in region adjusts past positions incorrectly
Date: Thu, 10 Apr 2014 10:00:06 -0400 [thread overview]
Message-ID: <CAFM41H2nvTK8ed3yaoBo2sqk++zBKFkBmtenmEQJL-VO2JXuQA@mail.gmail.com> (raw)
I constructed a recipe using emacs -Q to demonstrate a flaw in
undo-make-selective-list. Each bullet should be a distinct change
group:
* Insert 12345
* Delete the 4, buffer has: 1235
* Insert xxxx such that: xxxx1235
* Insert yy such that: xxxxyy1235
* Select "35", undo in region, expected 4 to come back, but nothing
changed
* Select "1235", undo in region, the 4 returns to the wrong place,
buffer has: xxxxyy14235
After these steps are executed in *scratch*, buffer-undo-list is:
(nil
(199 . 200)
nil
(196 . 198)
nil
(192 . 196)
nil
(#("4" 0 1
(fontified t))
. -195)
nil
(192 . 197)
(t . 0)
nil
(1 . 192)
(t . 0))
Clearly the (196 . 198) ought to have caused the ("4" . -195) to
adjust by 2, but it didn't because its adjustment due to (192 . 196)
was not applied yet.
I think the algorithm would be simpler to make correct if adjustments
are applied forward chronologically rather than backwards. That is,
the algorithm keeps a list of undo-deltas that grows as the algorithm
iterates backwards through undo history. As it does so, the positions
are adjusted chronologically forward through the undo-deltas. This
approach is O(N**2), as the current algorithm also is, but the bright
side is the proposed algorithm lends itself to short circuiting better
than the current.
Let me know if you have other ideas and I'll prepare a patch.
next reply other threads:[~2014-04-10 14:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-10 14:00 Barry OReilly [this message]
2014-04-23 2:31 ` bug#17235: Undo in region adjusts past positions incorrectly Stefan Monnier
2014-04-23 16:20 ` Barry OReilly
2014-04-23 17:56 ` Stefan Monnier
2014-04-26 21:00 ` Barry OReilly
2014-05-02 0:49 ` bug#17235: Barry OReilly
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=CAFM41H2nvTK8ed3yaoBo2sqk++zBKFkBmtenmEQJL-VO2JXuQA@mail.gmail.com \
--to=gundaetiapo@gmail.com \
--cc=17235@debbugs.gnu.org \
/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.