If you perform some command (even a navigation command such as C-f)
after a sequence of undo operations, all the undos are pushed on to the operation stack. So the next undo undoes the last command. Suppose you do have an operation sequence that looks like this:
- Insert "foo"
- Insert "bar"
- Insert "I love spam"
Now, you undo. It undoes the last action, resulting in the following list:
- Insert "foo"
- Insert "bar"
If you do something other than undo at this point - say, C-f,
the operation stack looks like this:
- Insert "foo"
- Insert "bar"
- Insert "I love spam"
- Undo insert "I love spam"
Now, when you undo, the first thing that is undone is the undo. Resulting in your original stack (and document state):
- Insert "foo"
- Insert "bar"
- Insert "I love spam"
If you do a modifying command to break the undo sequence, that command is added after the undo and is thus the first thing to be undone afterwards. Suppose you backspaced over "bar" instead of hitting C-f.
Then you would have had
- Insert "foo"
- Insert "bar"
- Insert "I love spam"
- Undo insert "I love spam"
- Delete "bar"
This adding/re-adding happens ad infinitum. It takes a little getting used to, but it really does give Emacs a highly flexible and powerful undo/redo mechanism.
本文详细解析了Emacs编辑器中独特的撤销机制。通过具体的例子说明了如何通过一系列的插入操作及撤销操作来理解Emacs如何管理和恢复撤销历史。特别强调了在执行其他命令后撤销操作如何被推送到操作堆栈上,以及这如何影响后续的撤销行为。
475

被折叠的 条评论
为什么被折叠?



