groff
[Top][All Lists]
Advanced

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

Re: user-defined characters, translation maps, and environment binding


From: G. Branden Robinson
Subject: Re: user-defined characters, translation maps, and environment binding
Date: Mon, 24 Apr 2023 06:27:29 -0500

At 2023-04-24T11:31:10+0100, Ralph Corderoy wrote:
> > >     .char £ pound sterling
> > >     .char $ United States dollar
> > >     .
> > >     The £ and $ are almost at par.
> > >     .
> > >     .tr aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ
> > >     £ crashes overnight!
> > >     .
> > >     .pl \n(nlu
> > >     ^D
> > >     The pound sterling and United States dollar are almost at par.
> > >     POUND STERLING CRASHES OVERNIGHT!
> ...
> > > I'd want to see shouty caps.
> >
> > I think this an excellent example of user-defined character abuse.
> 
> It's a long-standing idiom.  Not abuse.

Can you show me an example from anyone's work but your own?  Can you
show me long-standing work of yours that you didn't produce solely for
discussion of *roff behavior?

I am furthermore skeptical of the level of precedential value you impute
to the `char` request, since it does not appear in the source you cite
in preference to all others: CSTR #54.

> > There's no reason not to use strings here.
> ...
> >     .  de UP
> >     .    tr aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ
> >     .    ds \\$1 \\*[\\$1]
> >     .    tr AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZZ
> >     .  .
> ...
> >     .ds P pound sterling\"
> >     .ds D United States dollar\"
> >     .
> >     The \*P and \*D are almost at par.
> >     .
> >     .ds news \*P crashes overnight!
> >     .UP news
> >     \*[news]
> >     .pl \n(nlu
> 
> Reasons not to use strings here:
> 
> - It avoids having to re-work existing documents.

There are limits to this principle.  In the extreme, you should be using
something with a TRIP test.  Or DWB 3.3 troff, which will never change.

> - The text should be typed with £ and $, not \*P and \*D.

This is the best potential point, but since your example is pretty
contrived in the first place, it's hard to weigh.

So let me get this straight:

You want to use ordinary input characters, read by the formatter in
isolation (i.e., not as arguments to requests or escape sequences), as
abbreviations for arbitrarily long interpolations.  This is not
something that can be done, as far as I know, under a CSTR #54 troff.
Despite the provision of _three_ text interpolation features in CSTR #54
(macros, strings, and diversions), this one you identify as uniquely
indispensable, despite the fact that _all three_ are subject to
translation.

.tr aAbBcC
.ds X a\"
.de Y
b
..
S: \*X
.br
M:
.Y
.br
.di Z
.br
c
.br
.di
D:
.Z
.pl \n(nlu

I invite you to inspect the letter cases of 'a', 'b', and 'c' in the
output.

But maybe your implicitly long-standing example was not such a good one
after all.

$ cat ATTIC/will-a-char-break.groff
.char $ United States dollars
I had some $,
spent some $,
earned some $,
then went to Vegas and lost my $.
.pl \n[nl]u
$ nroff ATTIC/will-a-char-break.groff
I      had     some     United States dollars,     spent     some
United States dollars, earned  some  United States dollars,  then
went to Vegas and lost my United States dollars.

If you use a string, we see that the spaces between the words in your
"character" break, producing a better result.

$ cat ATTIC/will-a-char-break2.groff
.ds $ United States dollars
I had some \*$,
spent some \*$,
earned some \*$,
then went to Vegas and lost my \*$.
.pl \n(nlu
$ nroff ATTIC/will-a-char-break2.groff
I  had  some United States dollars, spent some United States dol‐
lars, earned some United States dollars, then went to  Vegas  and
lost my United States dollars.

It begins to sound like what you want is a system for defining arbitrary
input rewriting rules.

Have you looked at m4?

> - The text to shout now has to be put into a string, a macro called,
>   and the string interpolated.  Before, the text was just written.

But not without cost: the foreclosure of other useful applications.

> It sounds like transliteration local to an environment is a new
> feature, not one worthy of breaking .tr.

`tr` is already breaking page headers and has been since the late 1970s.

I know that speaks _for_ it in some people's eyes, perhaps yours, but
I'm not afraid to fix 30 year old bugs in groff.  I am similarly
nonchalant about fixing 50 year old bugs in troff, if I have the skill
to do so.  (Which, I admit, remains to be seen.)

Regards,
Branden

Attachment: signature.asc
Description: PGP signature


reply via email to

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