groff
[Top][All Lists]
Advanced

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

Re: [Groff] -me and macroses


From: Werner LEMBERG
Subject: Re: [Groff] -me and macroses
Date: Wed, 05 Dec 2001 01:59:59 +0100 (CET)

> > Yes.  Just say
> >
> >   text text text \*[my_macr] text text text
>
> Ugh!  Don't do this, it'll only cause trouble in the long run.

It doesn't, provided the macro is designed properly.

> For example, if the macro contains control lines, it's likely
> to behave differently than intended.  For example, try this
> and see the difference:
>
> .\" ----------------------------------------------------------------
> .de xx
> .ft B
> maybe
> .ft P
> ..
> yes \*[xx] no
> .br
> yes
> .xx
> no
> .\" ----------------------------------------------------------------
>
> If the macro does not contain control lines, it will work, but
> then the "macro" should preferrably be defined as a string, no?

To make a macro work fully `inline' is not possible currently -- to do
that we need a register which contains information whether a macro has
been called with ".", "'", or "\*" (this is already in the TODO list
of troff).  Here a version which almost works:

  .de xx
  \R'xx \\n[hp]'\c
  .ft B
  maybe\c
  .ft P
  .if !\\n[xx] \(
  ..

The \R escape sets register xx to the value of `hp', the current
position of the input line.  This enables later on to test whether the
last `\c' has to be canceled with `\(' (this is better than `\&').  So

  yes \*[xx] no

and

  yes
  .xx
  no

give identical results, but

  \*[xx] no

and

  .xx
  no

are still different.


    Werner

reply via email to

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