groff
[Top][All Lists]
Advanced

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

Re: [Groff] No-space mode in diversions


From: Tadziu Hoffmann
Subject: Re: [Groff] No-space mode in diversions
Date: Mon, 7 May 2001 08:41:31 +0200

> > The troff user's manual states that no-space mode is associated
> > with the current diversion, and Unix troff behaves accordingly.
> 
> May I ask that you send me the UNIX nroff output of your example?

Here it is (20 lines):
----------------------------------------------------------------

foo







bar

baz








----------------------------------------------------------------

> > GNU troff currently implements no-space mode only for the
> > top-level diversion.  Anybody interested in a quick fix?
> 
> Yes, I'm interested.  Please send it to me. :-)

Sent separately, since this mail also goes to the mailing list.

> Nevertheless, looking into the source code of gtroff, it seems that
> James Clark has intentionally implemented .ns for the top-level
> diversion only (and this behaviour is already documented in
> groff.texinfo).  You can always use `\!.ns' within a diversion to
> induce the desired behaviour.  Does somebody know the reason behind
> this way of implementation?

The transparently embedded `.ns' doesn't work if the purpose of
the diversion is to determine the height of some text block, or
if a diversion trap is set, because then the trap might be
sprung even if it shouldn't.  Example:

----------------------------------------------------------------
.de hr
.ev 1
----
.br
.ev
..
.pl 20v
.vs 2v
.di xx
.dt 7v hr
foo
.sp 3v
bar
.br
.ns
.sp 3v
baz
.br
.di
.nf
.xx
----------------------------------------------------------------

gives in nroff -Ttn300

----------------------------------------------------------------

foo







bar

baz








----------------------------------------------------------------

and with `\!.ns' instead of `.ns'  (nroff -Ttn300 and
groff -Tascii give the same result in this case)

----------------------------------------------------------------

foo







bar
----

baz







----------------------------------------------------------------

> > (Of course it doesn't work in the current version of groff because
> > the code to handle it is not there.  Unix nroff shows interesting
> > behavior: if you remove the `.br' after `bar' in this sample code,
> > it behaves as if the `.ns' were completely ineffective.  Probably
> > because `.sp' generates a break, causing `bar' to be output, which
> > turns no-space mode off, after which `.sp' is allowed to space.  Is
> > this interpretation correct?  Does it make sense to act this way?  I
> > think it would have been nicer if `.sp' caused a break, but threw
> > away its arguments while still in no-space mode.)
> 
> Using `.ns' while a partial line is still there doesn't work.  You
> have to be in `vertical mode' (to use a TeX specific phrase).  And I
> think this makes sense.

Well, it *could* have been implemented as I had suggested,
but it hasn't in the original troff, and since this is what
we're trying to emulate, we'll have to implement this behavior
as well.

> > Also, I think we should have a number register to query no-space
> > mode.  I suggest `.q' (in analogy to `.u') to give `1' in no-space
> > mode and `0' in (default) normal mode.
> 
> Today morning I've checked in this change with `.q' as the
> register name.  Right now I've changed this to `.ns' to avoid
> possible conflicts with two-character register names of Unix
> troff.

Actually, I had purposely chosen `.q' since I thought this might
even be useful in the original troff, and we should allow the
guys at Bell Labs the opportunity to retrofit this into the real
troff.  Or is that a bit too presumptuous?


Cheers,
Tadziu

reply via email to

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