groff
[Top][All Lists]
Advanced

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

Re: [Groff] nop request


From: Werner LEMBERG
Subject: Re: [Groff] nop request
Date: Sat, 09 Sep 2000 14:06:00 +0200 (CEST)

> I think the .nop request is essentially parallel to the print
> command in many other scripting languages. It's interesting that
> troff/gtroff has no ".print" command, as if it would seem redundant
> relative to the overall purpose of the program; but in this case I
> think it might be appropriate because we would only use such a
> command to actually output text strings. Alternatively, I like the
> idea of ".text" or ".output"

`.print' seems to be an excellent name!

Just to introduce another alternative: What do you think about the
name `.id', based on the idea of an `identity' mapping?

> > .eo
> 
> > .\" The function `xxx'
> > .de xxx
> >   .do-something \$1 \$2 \$3
> > ..
> 
> > .ec
>
> > I strongly believe that you get better code to understand if you
> > can avoid the doubling of the backslash.

BTW, to support this better I will introduce three new commands:

  .ecs xx      Save current escape character.
  .ecr xx      Restore escape character saved with .ecs

  .dei xx yy   Define indirect.  This is equivalent to

               .ds xx ...
               .ds yy ...
               .de \*[xx] \*[yy]

The reason for the first two commands is rather obvious.  It gives
macro packages a chance to restore the previous escape character:


.ecs
.ec
Here you can use the backslash escape character as usual.
.ecr


A natural choice would be to provide a read-only register containing
the current escape character, but this fails if the escape mechanism
is completely disabled -- you can't save a register to another without
using an escape.

The second command is very special and basically needed for the
implementation of tmac.trace only.  The current code relies on having
`\' as the escape character.  Using .dei, you can implement tmac.trace
even if there is no escape character at all.  I've implemented this
already in my private groff version, and it works.

> > Related to this: What about a mechanism to make all escapes
> > available as a request?  Something like
> 
> >   .er w'...'        =>      \w'...'
> >   .er A'...'        =>      \A'...'
> 
> > `er' stands for `escape request'.
> 
> How would you get the values from the escape function?

After some thinking I believe this wasn't a good idea...  Using the
proposed .ecs/.ecr commands it is always possible to locally restore
an escape character within a macro.

> It would be even more programmatically useful to have a return
> request so that:
> 
> .de test
> .ie '\\$1'1' .return one
> .el \{.ie '\\$1'2' .return two
> .el .return three
> .\}
> ..
> .de something
> .ds page \\*[test] \\n%
> ..

I like this idea, but I think that it is rather hard to implement
since groff doesn't `intern' the macros.  You can easily mimick this
behaviour with a temporary register or string:

.de test
.  ds @temp
.
.  ie '\\$1'1' .ds @temp one
.  el \{.ie '\\$1'2' .ds @temp two
.  el .ds @temp three
.  \}
.
.  nop address@hidden
.  rm @temp
..


    Werner

reply via email to

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