groff
[Top][All Lists]
Advanced

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

Re: Why does simply creating a diversion produce output?


From: G. Branden Robinson
Subject: Re: Why does simply creating a diversion produce output?
Date: Tue, 5 May 2020 07:59:45 +1000
User-agent: NeoMutt/20180716

Hi Tadziu--thanks for the ultra-fast reply!

At 2020-05-04T22:48:35+0200, Tadziu Hoffmann wrote:
> 
> > .di d
> > foo
> > .di
> > .rm d
> 
> Output is only sent to the diversion when a break occurs, either
> explicitly with .br, or when enough text has been collected to fill a
> line, or in no-fill mode.  Otherwise, the diversion remains empty, but
> a partially collected line exists when the end of input is
> encountered.

I think I'd like to add that first sentence to the Texinfo manual and
groff(7).  At present, the Texinfo manual simply says, "The current
partially filled line is included in the diversion."

What I suppose happens here is that the "current partially filled line"
in the above example springs into existence with the diversion body, the
line "foo".  The document is then no longer null.

The diversion is then closed and deleted with no break ever having
occurred, so "foo" never appears, but there's still an output node for
the (empty) partially-collected line.

I note that deleting ".rm d" from our examples makes no difference to
groff.

> This causes a page to be begun, but since the partially collected line
> is not forced out, the page remains empty.

Okay.  This is a candle flame for me.  It may turn into a light bulb. :)

> Try the following variations
> 
>   .di d
>   foo
>   .br
>   .di
>   .rm d

This results in no output at all, which is what I expected from my
original example above.

A break happens in the diversion context, so the diversion "happens",
the text is discarded, and there is no partially-collected output line
to be emitted to stdout.

My mental model is at peace with this, given your explanation that it's
a break that causes the diversion to, in some sense, actually happen.

> and
> 
>   .di d
>   foo
>   .di
>   .rm d
>   .br
> 
> to see this.

And in this case, diversion never actually happened, but with the
explicit break, we force the partially-collected output line, containing
"foo", to be written out.

Thanks for stepping me through this.  :)

Regards,
Branden

Attachment: signature.asc
Description: PGP signature


reply via email to

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