Record an undo operation. Also clears the redo stack. Raises IndexError
        when no group is open.

def register(self, func, *args, **kwargs):
        """
        Record an undo operation. Also clears the redo stack. Raises IndexError
        when no group is open.
        """
        self._open[-1].append(UndoOperation(func, *args, **kwargs))
        if not (self._undoing or self._redoing):
            self._redo = []
        self.notify()