> Just now I am reading "Unix Text Processing" by Dale Dougherty and Tim > O'Reilly, a freely available book (pmartin proposes it as well). There > are several chapters on the topic, so perhaps I'll get what I want in > the end.
I was going to mention that one, but I figured it was so long out of print as to be unobtainable. I should know better, though. abebooks.com has found me a wealth of long out-of-print UNIX material. My moment of truly understanding troff was when I stopped thinking of it as a typesetting program, and instead recognized it as a programming language. After that little epiphany, much of the smoke cleared. If you re-read the troff paper in that light, a syntax that initially appears to be line noise magically transforms itself into a concise and elegantly consistent language. There's no denying it's cryptic, though. But once you recognize the consistency of the syntax, it's a marvel to behold. There's no denying it has its warts. Number registers that are strings still offends my sensibilities, but as with irregular verbs, pretty soon you just learn to accept them and carry. But the one bit of troff black magic I still can't get my head around, even after 25 years, is how the hell .wh page-bottom traps are supposed to work :-P As for indexes, the me macro package provides macros for generating index entries: .(x and .)x. You can look in /sys/lib/tmac/tmac.e to see how they are defined. Plan 9 doesn't seem to provide any documentation for the me macros, though. I'm pretty sure Stevens talked about index creation on his web site, and you might want to check Brian Kernighan's web pages as well. --lyndon