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: Tadziu Hoffmann
Subject: Re: Why does simply creating a diversion produce output?
Date: Tue, 5 May 2020 01:04:56 +0200
User-agent: Mutt/1.11.4 (2019-03-13)

> At present, the Texinfo manual simply says, "The current
> partially filled line is included in the diversion."

I *think* that's wrong.  Diversions contain output, but
the partially filled line has not been output, so it's in
no-mans-land, belonging neither to the just-started diversion
nor to the top-level diversion.

It does, however, belong to an *environment*.  You can also
suppress the output page by having the partially filled line
exist in a different environment:

  .di b
  .ev 1
  foo
  .di
  .ev

At the end of this, a partially filled line still exists in
environment 1, but because this is not the current environment
when the document finishes (since we switched back to the
previous environment with ".ev"), no page is output.

However, even this explanation does not capture all the
intricacies, because the following

  .ev 1
  foo
  .ev

*does* cause a page to be begun.  The Troff User's Manual
explains:

  A pseudo-page transition onto the first page occurs either
  when the first break occurs or when the first non-diverted
  text processing occurs.

so maybe a more correct description for when groff outputs
the page is that

  1) the initial pseudo-page transition occurs, or
  2) a partially filled line exists in the current environment
     when input ends.

(But all these explanations are only based on a certain mental
model of the behavior, and are not verified by means of the
source code.  They might be completely wrong.)


> 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 partially filled line springs into existence with the line
"foo".  This is as yet independent of the diversion, at least
until output happens into the diversion.


> A break happens in the diversion context, so the diversion "happens",

No, the diversion "happens" the moment it is begun with ".di b".
It just remains empty until something is output into it.

(Well, if we're really careful with our terminology here
we might distinguish between "diversion" meaning the troff
data structure which is created by ".di b", and "diversion"
in the sense of "output is being diverted", which actually
"happens" when the ".br" is executed.)





reply via email to

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