Undo

Undo support in Neomacs is provided by undo-mode.

Class: undo-mode inherits (standard-object)
Support undo in current buffer.
Slot: undo-entry
Slot: amalgamate-limit
Maximum number of consecutive commands to amalgamate undo.
Slot: amalgamate-count
Number of already amalgamated commands.

Undo commands

Function: undo (&optional (buffer (current-buffer)))
Move undo state up one undo-entry.
Function: redo (&optional (branch-index 0) (buffer (current-buffer)))
Move undo state down to BRANCH-INDEX-th child.
Command in undo-mode: next-branch (&optional (buffer (current-buffer)))
Goto next sibling branch in undo history.
Command in undo-mode: previous-branch (&optional (buffer (current-buffer)))
Goto previous sibling branch in undo history.
Command in undo-mode (C-x u): undo-history ()
Show undo history and enable active-undo-mode.
Command in active-undo-mode (q, C-g, enter): quit-undo-history ()

Recording undo information

The primitive record-undo adds a pair of thunks to the undo history, which are called to undo or redo some changes.

Function: record-undo (undo-thunk redo-thunk buffer)
Add UNDO-THUNK and REDO-THUNK to BUFFER's undo history.
If *inhibit-record-undo* is non-nil, do nothing instead.
Variable: *inhibit-record-undo*
If non-nil, record-undo has no effect.
This is bound to non-nil during undo process itself.

All editing primitives maintain undo information themselves. Changes to attributes are normally not recorded in undo history, but you can bind *record-attribute-undo* to t to make attribute changes undoable.

Variable: *record-attribute-undo*
Record undo information when setting attributes.
Note that this only affects (setf attribute), not computed attributes (set-attribute-function).

Undo boundaries

Undo commands and the undo-history buffer both group series of undoable changes and operates on them as a whole. An undo boundary marks the end of previous group and the start of a new one. The command loop inserts an undo boundary before every command invocation, but this can be removed by remove-undo-boundary, or automatically by undo-auto-amalgamate.

Function: undo-boundary (&optional (buffer (current-buffer)))
Ensure undo state is at a undo boudary, insert one if necessary.
Function: remove-undo-boundary (buffer)
Remove undo boudary (if any) at current undo state.
Function: undo-auto-amalgamate ()
Call at the beginning of a command to amalgamate undo entry.
This amalgamate the undo entry if *this-command* is the same as *last-command*, and if amalgamate-count will not exceed amalgamate-limit.