I have described my experiences of using Emacs for writing ontologies previously (n.d.a) I was not entirely happy with omn-mode, even after recent changes (n.d.b) so I have taken the opportunity to update it a little more. This article most describes some implementation changes.

Originally, omn-mode was based on generic.el; this is a package which enables development of simple major modes. However, the emphasis was on simple, and my code was getting a little bit complex; generic.el was starting to get in the way. Moving to the define-derived-mode was not pain-free; it involved redoing already functioning code which is always a bit down heartening but probably worthwhile.

One thing that I did have problems with was getting comments to work properly (Emacs syntax tables are nasty). This never worked properly anyway, as I had defined “# ” as the comment starter; the reason for this is that Manchester syntax also uses URIs, within which any character is basically legal, including “#” but not a space. I think I have now found a better workaround for this. Manchester syntax requires URIs to be <surrounded>. I’ve now defined “<” and “>” to be string delimiters, which means that I can now use “#” as a comment starter without it being recognised in a URI. This isn’t perfect; in particular, Emacs will not recognise “<” and “>” as paired, so <URI> is equivalent to <URI< and >URI>, although only the former is correct.

I’ve also update the indentation logic somewhat. This now uses the syntax-table parser rather than font-lock to work out whether point is in comment or string. Of course, it should have been this way all along but the syntax-ppss function is new to me.

Finally, I have added some electric features. Because the identation engine works on keywords rather than brackets, the identation level really needs to be calculated when a line is finished rather than when it is started; electric mode means that the indentation updates as the user types. It’s a little jarring in some ways, although Python does something similar and for the same reason.

So, no major changes from the point of view of the user, except that it should all just work a little better. Code at Google code or website.