groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AT&T troff requests


From: G. Branden Robinson
Subject: Re: AT&T troff requests
Date: Tue, 29 Mar 2022 04:54:17 +1100
User-agent: NeoMutt/20180716

Hi, Humm!

At 2022-03-27T16:10:28+0000, Humm wrote:
> After stumbling upon the .li request in v6 man pages, I took a little
> look at what requests were removed and added between v7 and Plan 9 4E
> and at what they did.
> 
> .li and .fz went away;

Yes.  `li` was "literal mode".  It could have sworn it has come up on
this list before, but I can't scare up a citation.

It appears in the _index_ of requests in the 1976 edition of CSTR #54,
but not in the section contents and not in the section text at which
that index locates it (§10).  Perhaps it was already on its way out.

> .fm, .gd, .ha, and .pt were introduced.

These are all Plan 9 troff innovations as far as I know.  I'm not aware
of them having been reimplemented in any other troff, though that's a
top-of-mind assessment.

> As far as I can tell, none of them are mentioned in the Troff User’s
> Manual (CSTR 54, Plan 9, and Heirloom versions), in Mandoc docs, or in
> Groff docs.  I suggest mentioning these somewhere in the docs, even if
> not implemented.

That's a bit beyond the scope of the groff documents we have.  I've
added substantial historical and comparative material, but that's
generally in the context of addressing compatibility issues and
motivating why features are present or work the way they do.

About flat-out unimplemented requests (or escape sequences), I can't
find much to say.

> .fm, .gd, .ha, and .pt are part of Plan 9 troff and thus usable via
> 9front and via plan9port.  .li and .fz can be used in a v7 VM.  The
> FIXES file mentioned later is part of the Plan 9 and plan9port source
> trees ((/sys/)src/cmd/troff/FIXES).

That's a really useful artifact.  Contemporaneous (and comprehensive)
manuals for troffs of that era are hard to come by.

> Hereafter, I describe what I found about the requests.  (Take it with
> a grain of salt, as I don’t know my way around troff sources well.)
> 
> I’m not sure what .fz did.

It zoomed fonts and is analogous to groff's `fzoom` requests.  It is
documented in a one-page addendum to CSTR #54.  To get at it you need a
printed copy of the 7th Edition Unix Programmer's manual.

Or you can inspect the document source thanks to TUHS.

https://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/doc/troff/add

(This answers a question I had a while back about where the language
'User Abort.' comes from.  IMO that default was a botch.)

> `.li N` read N (default 1) lines literally.
> 
>       .li
>       .ab
> 
> would have the same effect as
> 
>       \&.ab

I assume that's why Murray Hill decided they didn't really need it.

For the following, I'll contrast the Plan 9 features you describe with
their groff counterparts, more for the edification of the mailing list
than anything else.

> `.ha N` sets the hyphenation algorithm.  The FIXES file, entry from
> January 1991:
> 
> > added tex hyphenation, using standard tex data files, but not the
> > elaborate compressed trie, which is a lot of trouble to save maybe
> > 40k bytes.  this appears to run at exactly the same speed as before.

Yes.  groff has always used TeX's hyphenation patterns, and to some
significant extent, its algorithm as well.

> > the command .ha sets the algorithm.  .ha 1 => tex, with troff rules
> > if tex doesn't hyphenate;  .ha 0 gives troff rules, and .ha resets
> > to the default, which is tex.

groff doesn't have that "suftab" stuff so you can have any hyphenation
color you like as long as it's black.

> > the hyphenation algorithm is part of the environment, a nod to a
> > future in which i handle more than one language.

groff does this.

> `.fm filename string` writes string to a file.

groff has analogous and generalized feature.

  .open    open a file (O_TRUNC)
  .opena   open a file (O_APPEND)
  .write   write a string with newline appended
  .writec  write a string without newline appended
  .writem  write macro contents
  .close   close a stream

All of the foregoing take an arbitrary, user-selected stream name for an
argument, permitting writes to multiple files simultaneously (well,
alternately), which is more power than I've seen used.  Also, `open` and
`opena` are disabled by default for security reasons.  We don't want
random man pages writing a billion laughs to the file system.

> `.pt N` sets the trace mode.  The FIXES file, entry from 1992-07-12:
> 
> > added .pt request to trace macros and requests (from jaap).
> > .pt N Print trace of macros (N=1), requests (N=2) or both (N=3)

groff's choice for this appears to be the "trace" package, which I only
recently bothered to explore in any depth (because the style of its man
page grated on me).  Some hacks were bolted onto the language to permit
such an implementation, and I do wonder if Kernighan (if that's who it
was) had the better idea to just put tracing in the language.

Tracing has been a painful issue for a long time.  A while back I fixed
a thirty-year old bug in groff's backtrace facility[1].

Another thing I noticed recently is that groff's `pev` request will
blast you with every detail of every defined environment...but won't
actually show you the state of the environment stack (below the top).
I tried to implement this, but it didn't work out[2].  Someday I'll have
another go.

> > Numeric arguments error reporting:
> > 
> > Controlled by .pt, illegal numbers are now reported (default
> > trace mode is 1).  This is also true for the escapes:
> > \h'..', \v'..' \H'..', \S'..', \N'..', \D'..', \l'.., \L'..
> > and \x'..'.

This matter is addressed in groff via a warning mechanism, though the
names and organization of its warning categories have come under some
criticism.

> > The .pt now pops the previous values when no argument is
> > specified. Turned out to be handy when chasing for problems.
> > Just ``bracked'' the code with .pt 7 and .pt and you get
> > a trace of only that block.

Good design.  I wish someone had thought to make .hy work that way back
before the cement set.

> The meaning of the arguments
> > is now:
> >     01      trace numeric arguments (default on)
> >     02      trace requests
> >     04      trace macros
> > 
> > […]

I've occasionally wanted step-by-step tracing of nested escape
interpolations.

> `.gd xx` sets number registers dn and dl to the size of diversion xx.

This is something I think groff _doesn't_ have.  I guess you could
simulate it by reopening a diversion and then immediately reclosing it
without writing to it.

  .di xx
  .di
  .nr xx.dn \n[dn]
  .nr xx.dl \n[dl]

Both approaches require saving copies of any existing `dn` and `dl`
register values.

Regards,
Branden

[1] https://savannah.gnu.org/bugs/?58153
[2] https://savannah.gnu.org/bugs/?60954

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]