groff
[Top][All Lists]
Advanced

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

[Groff] Re: groff .cc page trap issue


From: Ian! D. Allen
Subject: [Groff] Re: groff .cc page trap issue
Date: Thu, 31 Jul 2003 18:43:02 -0400
User-agent: Mutt/1.4.1i

On Thu, Jul 31, 2003 at 11:50:50PM +0200, Werner LEMBERG wrote:
> > http://www.ffii.org/archive/mails/groff/2002/Dec/0087.html
> >
> >     > How can one write a macro package whose page trap macros still
> >     > work when the user redefines .cc and/or .ec for some text?
> >
> >     Starting with groff 1.17 there exist the requests `ecs' and
> >     `ecr' to save and restore the current escape character.  Werner
> >
> > How does that help?  If a user does ".cc @" in front of 200 lines of
> > text and then a page trap occurs, the page trap macros don't work
> > (because the trap macros all use dots).
> 
> I was talking about the escape character only.  Well, I could add
> escapes, \j and \J say, to do the same as .ecs and .ecr, respectively,
> but then there is still the limitation of changing both the escape and
> control character.
> 
> Hmm, I could change the .de1 request (and friends) to reset both the
> escape and control characters to the default while executing the
> defined macro.  What do you think?

Adding this to .de1 may break things.  The issue of the escape and
control characters in traps is not related to compatibility mode; don't
mix them together.

When a trap occurs, a macro executes.  The commands in that macro have
no way of knowing what the current control character might be when the
trap triggers.  You can't have ".ecs" or ".cc ." at the start of the
macro; because, "." might not be the control character.  We need some
escape sequence that *always* works as the control character and that
is not affected by users playing with ".cc @".

My suggestion is to use another escape sequence that *always* works as
the control character, even after the control character is redefined
using ".cc @".  At Waterloo, we added \. to the escape set:

    $ ditroff
    .tm hi
    hi
    \.tm hi
    hi
    .cc @
    @tm hi
    hi
    \.tm hi
    hi

We also defined register \n(C. to contain the current control character,
so that it could be saved and restored.  Macros that could trigger in
traps would be written using "\.", or would be written like this:

    .de Footer
    \.ds SaveCC \\n(C.
    \.cc .
    .sp 2v
    .tm 'hi''there'
    .bp
    .......macro continues....
    .cc \\*[SaveCC]
    ..

Of course, the above doesn't take into account a double-trigger of
the same Footer macro, etc.  Troff really needs some push-down stack
registers!

Would this work?  To work well, we also need to be able to save/restore
the secondary control char (') and the escape character.

-- 
-IAN!  Ian! D. Allen   Ottawa, Ontario, Canada
       EMail: address@hidden   WWW: http://www.idallen.com/
       College professor via: http://teaching.idallen.com/
       Board Member, TeleCommunities CANADA  http://www.tc.ca/

reply via email to

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