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: Wed, 13 Sep 2000 01:56:50 +0200 (CEST)

> >   .ecs xx      Save current escape character.
> >   .ecr xx      Restore escape character saved with .ecs
> 
> Can't \e be used instead?
> 
>     .ds x \e
>     .ds y @
>     .ec \*[y]
>     escape char is @e
>     .ec \*[x]
>     escape char is \e

This works only if you know the new escape character in advance.

> Why the special commands?  Are you worried about not knowing the
> current escape character when you want to save it?  If so, isn't
> just a convention that it is always backslash when source macro
> packages, etc.  If you change it locally you should change it back
> before using others code.

As mentioned in another mail, it is most convenient to define macros
without having an escape character to avoid the doubling of
backslashes.  Now consider tmac.trace.  This macro packages redefines
the `.de' request to trace macros.  It must be called just before the
macro package to be traced.

----------------------------------------------------------------------
.\" Load this before a macro package that you want to trace.
.eo
.rn de !!de
.
.!!de de
.  !!de \$1
.  tm *** trace enter \$1: \\$0 \\$@
.  nop \\*[!!\$1]\\
.  tm *** trace exit \$1: \\$0 \\$@
\..
.
.  !!de !!\$1 \$2
..
.ec
----------------------------------------------------------------------

As you can see, I've used .eo and .ec.

Now consider another macro package, say tmac.zzz:

----------------------------------------------------------------------
.eo
.
.de xxx
.  nop test
.  yyy a b
.  nop test
..
.
.
.de yyy
.  nop \$1 \$2
..
.
.ec
----------------------------------------------------------------------

The idea is to say

  groff -mtrace -mzzz ...

but this will fail!  I've tried hard to find a solution with the
current groff to implement tmac.trace so that it works regardless of
the used escape character (resp. if the escape character is suppressed
with `.eo'), but it is impossible.  With my planned extensions, tmac
trace will look like this, and it will be independent on the escape
character:

----------------------------------------------------------------------
.\" Load this before a macro package that you want to trace.
.eo
.rn de !!de
.
.!!de de
.  ecs
.  ec
.
.  !!de \$1
.  tm *** trace enter \$1: \\$0 \\$@
.  nop \\*[!!\$1]\\
.  tm *** trace exit \$1: \\$0 \\$@
\..
.
.  ds !!de-arg1 !!\$1
.  ds !!de-arg2 \$2
.
.  ecr
.  dei !!de-arg1 !!de-arg2
..
.ec
----------------------------------------------------------------------


    Werner

reply via email to

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