You get an edit object passed in to a TextCommands run() function. This is used to encapsulate all the modifications that are done by the text command into a single undo group. You can pass edit objects to other functions, but it doesn’t make sense to store them in objects, pass them to other threads, or pass them to set_timeout calls. When the run() function of the text command returns, the edit object should never be accessed again: it wouldn’t make sense to try and group the modifications into the same undo group, as other undo groups may have been created in the mean time.
In S3, using an edit object after run() has returned will result in your insert/erase/replace calls silently failing. I’ll change this so an exception is thrown, making things a little more explicit.
begin_edit() was removed from the S3 API because it was too easy for plugins to call begin_edit without a matching end_edit, or to call begin_edit and expect the edit object to be valid over time, and leave the undo stack in an invalid state.