If stack is not specified, then clear the undo and redo stacks. Otherwise only clear the specified stack. The specified stack must be either undo or redo, otherwise an error will be thrown.
Especially clearing the redo stack without clearing the undo stack might be very useful in certain situations. The other case, clearing the undo stack without clearing the redo stack, is rather unusual, but will be provided for completeness. Obviously this extension is not breaking the compatibility to prior versions of the text widget.
The new undo implementation needs an extended edit separator command:
Inserts a separator (boundary) on the undo stack. Does nothing when the -undo option is false. Per default the insertion of the separator will be postponed until the next insert/delete/edit undo/edit redo command will be performed. If option -immediately is specified then the separator will be pushed immediately; this is required if mark or tag operations should be separated.
Command edit separator is still compatible to old library. The new option -immediately allows a more detailed control how to separate mark and tag operations. In general the use of edit separator without any option is sufficient.