The method generic-write does buffered insertions into edit. Each time it is called it inserts s into edit and then calls style-func with the starting and ending range of the insertion.
It calls begin-edit-sequence and creates a thread to call end-edit-sequence, unless such a thread is already running. That thread is also responsible to end edit-sequences for an embedded edits that are displaying io.
The methods generic-write should not be called from any procedures except this-out-write, this-err-write, and this-result-write. If generic-write is to be called directly; it must not be called from a killable thread. Instead, if the current thread is killable, generic-write must be called from within a thunk passed to kill-protect.