Skip to content

(u)ndo doesn't always do what it should #4

Description

@AnttiNykanen

Hello! @ryanprior recently e-mailed me about this amazing repository. While my original CVS repository of this thing is probably gone for good (and with that the TODO file that I once had), I spent a while trying to remember what "original" issues still might persist.

The only relevant one is that ed-cmd-undo doesn't work like in other implementantions of ed. This is mentioned in the docstring, but to clarify, here's one example I managed to think of:

In standard ed I can do this:

i
this is the first line
.
a
this is the second line
this is the third line
.
1,$p
this is the first line
this is the second line
this is the third line
u
1,$p
this is the first line

So the undo reverts the changes made to the buffer by the previous command. However, in ed-mode.el this happens:

i
this is the first line
.
a
this is the second line
this is the third line
.
1,$p
this is the first line
this is the second line
this is the third line

u
1,$p
this is the first line
this is the second line

So calling the Emacs undo doesn't revert everything that was appended by the second command but just the last line - which, now that I think about it, is quite logical since we are just doing line-by-line inserts into the buffer.

I'm not 100 % sure if this is just an issue with input mode commands (i, a and c) - but if that is the case, the fix might be a lot easier than what I thought 14 years ago: just build an intermediate buffer string while doing input mode, then insert it all in one go when . is used to exit. If everything gets inserted in one go, then I think undo should also work properly.

If someone can think of other cases than i / a / c where undo messes up, then we might need to think of something more elaborate 😄

Other than this, I just had some commands missing, and it looks like @echosa already has a pull request for adding placeholders. Nice!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions