[Top][All Lists]

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

Re: [Groff] The Nature of .ev

From: Ingo Schwarze
Subject: Re: [Groff] The Nature of .ev
Date: Sun, 1 Feb 2015 03:13:45 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

Hi Yves,

Yves Cloutier wrote on Sat, Jan 31, 2015 at 06:14:59PM -0500:

> I am trying to get to grips with how environments work.
> For example what I'm trying to do is start a new environment,
> apply some formatting, then return to the previous environment:

As far as i understand, environments are not the intended tool for
temporary formatting changes: They deal only half-way with partially
filled lines, saving and discarding them, but providing no support
for printing them.

For your specific purpose, you are better off using a facility
that does not care about partially filled lines at all.
In Heirloom roff, you can use inline environments, but note
those are *not* portable, not even to groff:

  What address@hidden@} he trying to say?

So, to do this more portably, you need to take care of the partially
filled lines.  One way would be to do this fully manually, manually
breaking output lines and manually saving and restoring horizontal
and vertical positions:

  .nr HP \n(.k
  .ev 1
  .ft I
  .ti \n(HPu
  .nr HP +\n(.k
  .ti \n(HPu
  he trying to say?

Using such low-level registers like \n(.k is not fully portable,
either.  For example, Heirloom roff needs ".cp 0" at the top of
the file, or there will be no inter-word spacing before and after
the word "was".

To avoid fully manual control - which indeed kind of defeats the
purpose of a typesetting system, for example ruining filling - you
could encapsulate the environment in a diversion, such that the
environment handles the font change and calling the diversion handles
partially filled lines and filling:

  .box DV
  .ev 1
  .ft I
  he trying to say?

But again, Heirloom roff requires ".cp 0" for this to work,
or ".box" won't be recognized as a request.

The bottom line is that you can use such low-level stuff like
environments when designing a macro set intended to be distributed
with one specific implementation of roff, using the syntax and
semantics that implementation imposes, and accepting that your macro
set will not be portable.  But it's a bad idea to use such low-level
features in end-user documents - or you are likely to end up with
non-portable documents and complaints from your users that your
documents misformats with their version of roff.

In particular, never use any of the above in manual pages...

To control formatting, use the formatting macros of the macro set
you are using, or if you are using none, use .ft and \f without any
additional fuss around it.


reply via email to

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