When everything else fails, try Emacs

Even though I've defected to Eclipse for Java coding[1], and even occasionally use Vim[2], there are times when I flee back to the tender loving embrace of Emacs.

We've been doing a bit of software archaeology at work, mapping old requirements specifications to a newer code base. The chosen method was to append specially formatted comments to the end of each line participating in the implementation of a requirement, in the form of // req <requirement identifier>. How to do this in Eclipse? It doesn't have a macro facility; there are the snippets or whatever they are called, but using it for this purpose would be pretty painful. And the lines are formatted to be long enough (padded with spaces) to make it easier to read the code with the comments inserted. Which is nice and all, but with my screen I can't even see what lines have the comments which don't. Not good.

But, hey, sometimes everything isn't a nail even though you have a hammer. There's always Emacs. 50 lines of elisp later and I have it prompting me for the requirement id, inserting and removing the comments with one key press and highlighting the lines with the current requirement id. Make it truncate long lines and the only thing different from the normal display is the pink background on the lines I'm interested in. Because the Emacs manual (and function doc strings) is as good as it is, all that was stupidly easy to accomplish even though I had never played with faces and overlays before. And of course no restarts were required while I was hacking the code, trying out every change as soon as I made it. I'm still waiting for another environment that is as malleable as Emacs.

[1] So I can't live without all the searches and other magic. Its editor is still pretty weak.

[2] Vi style indentation is better than broken Emacs style indentation. Some Emacs language modes are less than perfect. Also, AA fonts[3].

[3] The good news is that the Xft-enabled emacs-unicode-2 branch has been working for me now happily for a day. Smooth Bitstream Vera is love. If only it were packaged in Ubuntu, the way the main development branch is in the emacs-snapshot package.

© Juri Pakaste 2023