News for hackers. Stuff that matters.
Re:Resolving the Great Undo-Redo Quandary by unholiness on Friday November 11, 2022 @10:24AM (#33561929)
Interesting. So basically the last chain of undo doesn't enter the history until you do something else.

I often use undo as a faster delete when making edits, so I think I would still be annoyed by this (why am I seeing this crap I undid reappearing?) Now after a long undo chain I'm afraid to type for a new reason: it will pollute my undo stack. But it might be reasonable if my brain was used to it. Can't knock something I've never tried.

Re:Resolving the Great Undo-Redo Quandary by jefftk on Friday November 11, 2022 @11:19AM (#33562683)
How is undo a faster delete?
Re:Resolving the Great Undo-Redo Quandary by TuringTest on Friday November 11, 2022 @11:20AM (#33562700)
If you're only adding content, undo removes the most recent content inserted. But that's a very limited case of everything that undo can achieve.
Re:Resolving the Great Undo-Redo Quandary by a_e_k on Friday November 11, 2022 @04:14PM (#33566941)
Like the GP, I also use undo as a faster delete. The key is that undo in Emacs doesn't just go one keystroke at a time. By default it will basically quash a whole chunk of similar operations and undo/redo them together:

> amalgamating-undo-limit is a variable defined in ‘simple.el’.

> Its value is 20

> The maximum number of changes to possibly amalgamate when undoing changes. The ‘undo’ command will normally consider "similar" changes (like inserting characters) to be part of the same change. This is called "amalgamating" the changes. This variable says what the maximum number of changes considered is when amalgamating. A value of 1 means that nothing is amalgamated.

There's also a hidden 10s idle timer that will insert a boundary to break up the amalgamation. So if you type, pause and think, and then start typing again, the chunked undo/redo will always stop at the point that you started typing again. Taken together, it's usually quite effective at guessing how much to delete.

Re:Resolving the Great Undo-Redo Quandary by TuringTest on Friday November 11, 2022 @11:19AM (#33562689)
Note that if you delete something and press Undo, it restores the content that was there before removing it.

The "branching undo" in the article extends the concept to being able to recover things that were at some point in your "redo" pile, but which in other editors would been have lost when you typed something else while in that state.

As the article explains, the simplest mental model is "rewind in time to the point I was 5 minutes, 10, 15, 20 minutes in the past". If you've been undoing and redoing things, going through that point in the past will retrieve those removals and retrievals.