Previous: Implementation, Up: Undo Protocol
Class precedence list:
undo-mixin, standard-object, slot-object, tSlots:
treeReturns the undo-tree of the buffer.
undo-accumulateThe undo records created since the start of the undo context.
performing-undoTrue if we are currently performing undo, false otherwise.
This is a mixin class that buffer classes can inherit from. It contains an undo tree, an undo accumulator and a flag specifyng whether or not it is currently performing undo. The undo tree and undo accumulators are initially empty.
The undo-tree object associated with the buffer. This usually contains a record of every change that has been made to the buffer since it was created.
Undo is implemented as :before methods on, insert-buffer-object, insert-buffer-sequence and delete-buffer-range specialized on undo-mixin.
A list of the changes that have been made to
buffersince the last time undo was added to the undo tree for the buffer. The list returned by this function is initially NIL (the empty list). The :before methods oninsert-buffer-object,insert-buffer-sequence, anddelete-buffer-rangepush undo records on to this list.
If true, the buffer is currently performing an undo operation. The :before methods on
insert-buffer-object,insert-buffer-sequence, anddelete-buffer-rangepush undo records onto the undo accumulator only ifperforming-undois false, so that no undo information is added as a result of an undo operation.
Three subclasses insert-record, delete-record, and
compound-record of undo-record are used. An insert record stores a
position and some sequence of objects to be inserted, a delete record
stores a position and the length of the sequence to be deleted, and a
compound record stores a list of other undo records.
The :before methods on insert-buffer-object and
insert-buffer-sequence push a record of type delete-record onto the
undo accumulator for the buffer, and the :before method on
delete-buffer-range pushes a record of type insert-record onto
the undo accumulator.
This macro executes the forms of
body, registering changes made to the list of buffers retrieved by evaluatingget-buffers-exp. Whenbodyhas run, for each buffer it will calladd-undowith an undo record and the undo tree of the buffer. If the changes done bybodyto the buffer has resulted in only a single undo record, it is passed as is toadd-undo. If it contains several undo records, a compound undo record is constructed out of the list and passed toadd-undo. Finally, if the buffer has no undo records,add-undois not called at all.
To avoid storing an undo record for each object that is inserted, the with-undo macro may in some cases just increment the length of the sequence in the last delete-record.
The method on flip-undo-record specialized on insert-record
binds performing-undo for the buffer to T, inserts the
sequence of objects in the buffer, and calls change-class to
convert the insert-record to a delete-record, giving it a the
length of the stored sequence.
The method on flip-undo-record specialized on delete-record
binds performing-undo for the buffer to T, deletes the range
from the buffer, and calls change-class to convert the
delete-record to an insert-record, giving it the sequence at
the stored offset in the buffer with the specified length.
The method on flip-undo-record specialized on compound-record
binds performing-undo for the buffer to T, recursively calls
flip-undo-record on each element of the list of undo records, and
finally destructively reverses the list.
Class precedence list:
drei-undo-record, standard-undo-record, undo-record, standard-object, slot-object, tSlots:
buffer— initargs::bufferThe buffer to which the record belongs.
A base class for all output records in Drei.
Class precedence list:
simple-undo-record, drei-undo-record, standard-undo-record, undo-record, standard-object, slot-object, tSlots:
offset— initargs::offsetThe offset that determines the position at which the undo operation is to be executed.
A base class for output records that modify buffer contents at a specific offset.
Class precedence list:
insert-record, simple-undo-record, drei-undo-record, standard-undo-record, undo-record, standard-object, slot-object, tSlots:
objects— initargs::objectsThe sequence of objects that are to be inserted whenever flip-undo-record is called on an instance of insert-record.
Whenever objects are deleted, the sequence of objects is stored in an insert record containing a mark.
Class precedence list:
delete-record, simple-undo-record, drei-undo-record, standard-undo-record, undo-record, standard-object, slot-object, tSlots:
length— initargs::lengthThe length of the sequence of objects to be deleted whenever
flip-undo-recordis called on an instance ofdelete-record.Whenever objects are inserted, a
delete-recordcontaining a mark is created and added to the undo tree.