This patch converts the undo stack from GTextDocument into GUndoStack, and GTextDocumentUndoCommand now inherits from GCommand. Let's turn this into a generic mechanism that can be used to implement undo/redo in any application. :^)