4 ms·
The undo system is confusing if you are accustomed to undo/redo in practically every other piece of software, but it does make sense (in its own kind of way). S
by todd8 8y ago
The undo system is confusing if you are accustomed to undo/redo in practically every other piece of software, but it does make sense (in its own kind of way). See the documentation for the undo commmand[1]. Emacs undo is powerful albeit with more cognitive load to use.
I have occasionally had to take over the controls for new emacs users while pair programming because the undo, while logical and consistent, doesn’t work as it does in other software. Each consecutive sequence of undo commands, once interrupted by any command that is not an undo is considered itself to be an atomic undoable change. This means that there is no need for a redo command, just stop undoing and the last undo sequence can be undone. Because emacs has a large undo limit you can keep undoing even past sequences of undos back to the original edit points of the file’s history.
That probably made no sense if you haven’t already mastered it, but another way to think of it is that edits and undos produce a branching tree of all the history of changes being made to the file. The entire tree of changes can be navigated with one command (undo) because that command makes a traversal of the tree, kind of like a post-order tree traversal. This is sufficiently confusing in practice that seeing the nanigation through the tree via the popular undo-tree emacs package helps a lot. I use the undo-tree command when I want to get to a version of the file not on the current main line of edits.
[1] https://www.gnu.org/software/emacs/manual/html_node/emacs/Undo.html#Undo https://www.gnu.org/software/emacs/manual/html_node/emacs/Un...
- martincmartin 8y agoThanks for the tip! Despite using emacs for decades, I never properly read the undo docs. I'll try binding the undo keystroke to "undo-only", and a redo to normal undo definition, to see if I can get something approximating undo/redo semantics.
- bitexploder 8y agoAnyone that wants to use emacs seriously has to learn a about the kill ring. Something like Helm kill ring is great. It lets you go way back in time and re-pasted killed things.
- kiaulen 8y agoThe problem with this is I'm a web dev and I can't really do all my work in emacs. For backend people you can live entirely in emacs. Once you hit the frontend you have to start interacting with a browser. That's why I always get a clipboard manager and have my editor kill (cut) to the clipboard. Then I can hit C-V and get a popup menu (similar to helm kill ring, navigable both with mouse and keyboard) with the last 100 or so things I've cut/copied.
- nerdponx 8y agoVim also has an undo tree, but still manages to retain a sane user experience. Not that Vim is any paragon of UX design. The point is that you can have a powerful undo system without breaking user expectations.
- LukeShu 8y ago> Vim also has an undo tree There is an undo-tree implementation for Emacs (based off of Vim), but the default undo described above isn't an undo-tree.