BufferInterface for lower level text buffer manipulation

Review Request #111407 - Created July 5, 2013 and discarded - Latest diff uploaded

Sven Brauch
For implementing collaborative editing in KTE, an interface to insert text into the buffer without e.g. replacing tabs by spaces is needed. This patch suggests such an interface and an implementation of the interface in KateDocument.

This review request is supposed to be an early suggestion of the interface which I'd like some feedback on, not as a final proposal which I want to merge tomorrow. :)

For details on the interface, see the docstrings in the diff. The implementation is basically just the same what editInsertText() does, but without manipulating the text it inserts (e.g. tabs -> spaces).
See the mailing list thread [1] on this topic, too.

I have been using the interface for a few weeks now, and it seems to work fine. Regarding text manipulation, it indeed seems to be all which is needed for collaborative editing in KTE. I will need to propose an additional interface for properly implementing undo/redo and the line modification markers, but I will do that later (or do you think it makes sense to group undo/redo manipulation into the same interface as this? I don't think it does).

Oh, here's something I'd like to discuss: Scripts and plugins can connect to the textInserted() / textRemoved() signals, which means they will synchroneously (aka during the call to document->insertText()) execute code which has the power to change text again. As a result, the user of the interface can again not rely on the exact text it gives to the method to be inserted into the document. I currently solve this problem by blocking signals from the document while inserting the text of a remote user, since I didn't find anything which should react to such changes done (e.g. snippets should not be evaluated for remote users, auto-brackets should not be placed, ...). However I'm not sure this is a good way to do things although so far, it works perfectly fine.
The reason I bring this point up is because one could consider to not emit the textInserted() / textRemoved() signals when text is inserted/removed through the BufferInterface in the first place. I would like to have an opinion on that from you. Does that make sense, or will things likely break?

[1] http://lists.kde.org/?l=kwrite-devel&m=137021138600908&w=3