Collaborative editing of source code
I would like to have a real-time collaborative editor for code source. The real-time collaborative edition feature already exists in Gobby or AbiWord. But I still want to use vim for source code, and some colleague will not accept to leave its alternative editor.
It would be better to have a common protocol in order to have collaboration features between vim, emacs, gedit and more. The existing collaboration features in vim cannot interoperate with GNU Emacs, and the existing collaboration features in GNU Emacs cannot interoperate with vim. The AbiWord’s plugin Collab protocol has good ideas to avoid and resolve conflicts as explained in a GNOME Journal article (and more good ideas will come with the abicollab.net service). But the Collab’s protocol is tied to Abiword internal structures. Aseigo discussed the issue and want a generic library for collaborative features.
A common protocol would be useful for editing source code with my contacts (I want to use Telepathy tubes!) but also when one user want to use both vim and emacs on the same buffer. D-Bus is now the way to go for applications to communicate with one another, and D-Bus tubes are available in Telepathy.
The editors landscape use very different languages: Emacs Lisp for GNU Emacs, the Vim script language for vim (although Python can be used, see this presentation from PyCon), C and Python for gedit. Whatever the way we choose to resolve conflicts that happens in real-time editing, it seems complex: it took some years to the Abiword team to build the Collab plugin. I would prefer to avoid writing complex things in all theses differents editors and languages.
So I am thinking of an architecture with an intermediary component that make the difficult job of handling conflicts. Let’s call it text-remote-control now but I am looking for a better name.

Then, editors would have to implement a basic D-Bus specification. I don’t know yet if it is possible to isolate the complexity from the editor, but I would like to explore this possibility.
So I started to hack on gedit:
And I have built this screencast:
I have also a plugin for vim (on git) that fires a D-Bus signal each time the buffer is changed. The problem here is that vim use its own mainloop and I don’t know how to integrate the GLib mainloop used by the python-dbus. So my vim plugin cannot receives method calls yet.
I don’t know how to use GNU Emacs but I hope someone will take the opportunity to show that writing plugins in emacs is easier!

This looks really cool! Can’t wait to try it out.
BTW, just to be nitpicky…the word you’re looking for is “editing”, not “edition”. I was very confused when I saw your post’s title show up in my feed reader.
Comment by Sandy — May 11, 2008 @ 4:14 pm
Gobby’s code is reusable and handles all the conflict resolving and network stuff. Then you would simply need to translate your editor’s text commands into Obby commands, and a means of updating the buffer with remote changes. I’m not sure how much of this is doable as a pure editor plugin, without patching vim or emacs itself…
Comment by Damien — May 11, 2008 @ 4:19 pm
Is the Gobby’s protocol and algorithms explained somewhere?
I found your post interesting:
http://typo.cdlm.fasmz.org/articles/2007/04/24/collaborative-development
I didn’t know GNU Emacs has an implementation of the Gobby protocol.
Comment by Alban — May 11, 2008 @ 5:45 pm
Awesome!
Can’t wait to see this properly integrated into GNOME and Empathy!
Comment by Guillaume — May 11, 2008 @ 6:21 pm
Emacs 23 has dbus bindings. So it’s just a bit of lisp that needs written…
Comment by gah — May 12, 2008 @ 9:14 pm
Obby protocol is documented. http://gobby.0×539.de/trac/wiki/ObbyProtocol has some stuff. Supposedly they were working on a revamp; I suggest contacting them directly.
Comment by rektide — May 13, 2008 @ 4:12 am
The D-Bus specification speaks about the org.freedesktop.TextEditor interface. Unfortunately, it isn’t specified in detail.
Kate’s D-Bus interface org.kde.KTextEditor.Document seems to be the best starting point, see . Collaborative working isn’t the focus there, though.
I have some vague ideas for adding such an D-Bus interface to GNU Emacs, but I haven’t started yet. Maybe we could join our efforts?
Comment by michael — May 13, 2008 @ 9:31 pm
This would be amazing to have. GObby lacks out on the Telepathy, but is a mean deal otherwise. I saw your post about an DBus interface for Vim, now that would be a godsend to anyone wanting to embed vim (like myself). I’d like to see if I could you help out.
Comment by Arun — May 31, 2008 @ 1:04 am