groff
[Top][All Lists]
Advanced

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

Re: [Groff] odd interaction between .bl and .(c in -me macros


From: Tadziu Hoffmann
Subject: Re: [Groff] odd interaction between .bl and .(c in -me macros
Date: Sun, 1 Jan 2012 16:34:04 +0100
User-agent: Mutt/1.5.21 (2010-09-15)


> I would say this part /is/ a bug, since the whole point of
> using the .bl macro, instead of .sp, is that .bl should work
> even when no-space mode is active.
> More specifically, while .bl's documentation doesn't
> explicitly claim to override no-space mode, it does say that
> it works at the top of a page,

If you take a look at how "bl" is defined,

  .de bl
  .br
  .ne \\$1
  .rs
  .sp \\$1
  ..

you can see that it does: the "ne" checks whether the requested
amount of space is still available on the current page.  If it
isn't, this triggers a new page, and the "rs" restores spacing,
to guard against the case that the page header macro has turned
spacing off.  Then the requested amount of space is output.

> which is precisely what it is failing to do here.  And it
> seems to me that altering .bl to ignore no-space mode in
> other contexts wouldn't violate its documented behavior.

As you see above, "bl" already does what you are wanting it
to do.  The problem in your example is that you are using
"bl" inside a diversion (in "(c"), and once "(c" has processed
your text, the "bl" is gone, and there's not much "bl" can do
about that.  Only the space itself remains in the diversion,
and that will be ignored if no-space mode is in effect at
the time the diversion is output.


> [...]
> This can be transformed into an example that doesn't work
> by removing both lines of the magical sentence (leaving
> only "Here is text" in the second paragraph).

This behavior is, unfortunately, due to perhaps the biggest
design weakness in troff: a trap is sprung *after* stuff is
output that reaches beyond the trap position, not before.
So what happens is that the space *is* output (at the bottom
of the page, only you don't see it because it is empty),
which springs the page-bottom trap, and output continues on
the next page with "center me".  Nothing actually gets lost,
although the result may not be what you intended.
(In your working example, it's the "magic" text which springs
the page-bottom trap, so output continues on the next page
with the space.)

Fortunately, you can fix the problem in the same way as before:

  .bl 49
  .pp
  Here is text.
  .pp
  Here is text.
  .(c
  \!.ne 20
  \!.rs
  .bl 20
  center me
  .bl 20
  .)c
  .pp
  Here is text.

You could instead patch "bl" to do this itself, then the
guard against the page header macro's no-space mode will
survive one level of diversion:

  .de bl
  .br
  .ne \\$1
  \!.ne \\$1
  .rs
  \!.rs
  .sp \\$1
  ..

If you're planning to use "bl" inside more deeply
nested diversions, you might think of using a recursive
request-embedding mechanism.





reply via email to

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