Alban’s blog

May 11, 2008

Collaborative editing of source code

Filed under: Uncategorized — alban @ 3:02 pm

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.

Collaborative edition of source code, architecture schema

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:

  • gedit’s remote control plugin: file (on git)
  • text-remote-control: script (on git)

And I have built this screencast:

Gedit's plugin 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!

11 Comments »

  1. 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

  2. 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

  3. 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

  4. Awesome!
    Can’t wait to see this properly integrated into GNOME and Empathy!

    Comment by Guillaume — May 11, 2008 @ 6:21 pm

  5. 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

  6. 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

  7. 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

  8. 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

  9. […] the fun features of Gedit while still retaining the collaboration activities that gobby provides.  Alban has a prototype up using dbus which allows collaborative activities using editors of choice (in his example, VIM […]

    Pingback by Joey Stanford » Wanted: obby plugin for Gedit — August 18, 2008 @ 9:06 pm

  10. […] This looks fascinating and exciting to me — collaboration across tools and systems using D-Bus and telepathy. It would be nice to see some sort of XML “exploder/imploder” that would allow OpenOffice.org documents to benefit from this approach too. (I’ve often wondered why, with the open formats we champion, that hasn’t been done yet.) But hey, even text files would be a big step forward. Good luck with this Alban, it looks like a superb idea and long overdue. […]

    Pingback by The Grand Fallacy » The silver lining. — August 24, 2008 @ 11:29 pm

  11. Great idea, but I can’t get it working, could you write some how to install and use it? thanks.

    Comment by Franco — June 2, 2009 @ 10:01 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress