n-t-roff / heirloom-doctools

The Heirloom Documentation Tools: troff, nroff, and related utilities
http://n-t-roff.github.io/heirloom/doctools.html
Other
129 stars 22 forks source link

-mgchar undoes part of -mg #96

Open subrook opened 4 years ago

subrook commented 4 years ago

One important effect of the -mg flag is to set the .g register to 1.

However, -mgchar—another flag commonly used by those processing groff-originating documents—has a side effect of setting the .g register to 0.

This seems to be because the first line in tmac.gchar runs the .xflag 3 request. As documented, "Any use of the xflag request disables groff compatibility."

Thus specifying -mgchar -mg on the command line enables groff compatibility, and specifying -mg -mgchar does not. This is surely an undesired (and definitely an undocumented) side effect of -mgchar, an option designed to aid groff compatibility.

n-t-roff commented 4 years ago

The simplest fix would be to document that -mgchar disables groff compatibility but surely it's better to fix gchar. Would you mind preparing a pull request for that?

subrook commented 4 years ago

I don't know enough about the Heirloom troff ecosystem to determine the best fix.

Calling .cp 0 for full groff compatibility seems beyond tmac.gchar's scope, but I don't know the use case for specifying -mgchar without -mg. If -mgchar is only ever used in combination with -mg, that fix is probably OK.

But I don't know the design rationale for spreading the groff compatibility macros across two separate tmac files rather than putting them all in one. This separation could imply that some users want -mgchar without -mg, or it could be a historical anomaly (which is also suggested by the naming inconsistency between this file and every other file in the tmac directory).

And if it's not appropriate for tmac.gchar to turn on full groff compatibility, what's the best way to get the functionality of extension level 3 without actually running .xflags 3? Would every line of tmac.gchar need to be wrapped in a .do?