groff
[Top][All Lists]
Advanced

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

Re: macro returning a value?


From: Thomas Dupond
Subject: Re: macro returning a value?
Date: Sun, 14 Nov 2021 13:31:26 +0000

Ulrich Lauther <ulrich.lauther@t-online.de> wrote:

> >   .de Pos
> >   \R'foo (\\n[.d]-\\n[.v]*254+1)/72000'\\n[foo]mm/10
> >   ..
> >
> > which allows you to enter
> >
> >   position: \n[.d] units, \*[Pos].
> >
>
> Wow! Works nicely.
>
> But why is "R" escaped only once? \\R works too.
> And I had to add a line ".sp -1v" at the end of the  macro; otherwise I get a
> blank line after position: ...
>
>         ulrich
>

Hi Ulrich,

I think I know why, if I'm mistaken, please correct me.

To be executed, macros are effectively executed twice by groff.  Once to
be defined and once more at execution.  Backslashes are needed to
distinguish between definition and execution.

\\n[.d] is escaped twice because we need the number register .d at the
time of execution not at the time of definition.  As for \R foo, it is
equivalent to .nr foo so it is OK if it is executed at the time of
definition.

--
Regards,
Thomas




reply via email to

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