Take a look at this editor window:
What do you see that's different about it? I'll tell you, there are two margin lines. Is this a new feature of the soon-to-be-released Eclipse Galileo? Did I write my own Java editor?
I hacked Eclipse to make that second margin.
I added this because I really like having two margins: I consider the first one a 'warning track' indicator. I don't mind writing code longer than 80 characters, but will go to 100, and prefer to stay inside the warning track.
So, how did I do this? I used patch fragments. Some pages on the Eclipse wiki claim that Patch Fragments are a horrific misuse of Eclipse, and one actually taught me how to do it. (It missed one important point, though, that cost me about an hour. The page has been adjusted accordingly.)
Here's the best part, thanks to patch fragments, I was able to perform this surgery at exactly the right place. The same small piece of code (and really, this actual amount of code was shockingly small) provides two margins in any editor, such as the plain-ol text editor:
or the plug-in manifest editor.
Look, there are down-sides to doing this: if I plan to support this patch, I need to apply it with each release of Eclipse. But honestly, how likely do you think it would be for an enhancement like this to make it in to the release? Not very bloody likely.
This is purely a proof-of-concept, but I plan to finish this up and publish it as an EPL contribution.
In a subsequent blog post* I will document how I got it to work, but for now, I'll tell you: as a total hack, I changed about six lines of code in org.eclipse.ui.texteditor.SourceViewerDecorationSupport, and added a sibling class called org.eclipse.ui.texteditor.TwoColumnMarginPainter.
zx, thanks for the offer, I don't need the patch fragment tutorial! :-)
* Googlers, in the draft of this article I accidentally used "changelist" instead of "blog post". Apparently I do "subsequent changelists" a little too often. :)