[comp.unix.questions] nroff -mm macro question

burch@hpcc01.HP.COM (Jeff Burch) (04/04/91)

I am using the MM macro package for nroff and need to know the trick to
escape a back slash for a ".VL" label. For example:

My nroff source looks like:

   .VL 20

   .LI "/test\.[Ch]"
   This regular expression will search for the string "test.C" or
   "test.h".  Note: the "\" is used to escape the ".", otherwise ...

   .LE

I want this to be formatted like:

   /test\.[Ch]    This regulare expression will search for the "test.C" or
                  "test.h". Note: ...

However, the command "nroff -mm <file>" gives:

   /test.[Ch]     This regulare expression will search for the "test.C" or
                  "test.h". Note: ...

I have tried putting "\\" or "\\\" rather than "\" on the ".LI" line
without any luck.

Any clues?

	Thanks,

	Jeff Burch
	Optical Electronics Division, San Jose, CA.
	jeff@hpoemb.hp.com
	telnet 435-4657

For the nroff macro experts, here are the definitions from
/usr/lib/macros/mmn


.deVL
.if\\n(.$<1 .)D "VL:missing arg"
.ie\\n(.$<3 .LB 0\\$1 0\\$2 0 0
.el.LB 0\\$1 0\\$2 0 0 \& 0 1
..



.deLI 
.if!\\n(:g .)D "LI:no lists active" 
.if(\\n(:g<=\\n(Ls)&(\\n(:f>0) .SP
.in\\n(:bu
.if\\n(:F 'in 0
.if(\\n(:f>0)&(\\n(:D<1) .ne2v
.ds}0 \\*(]g
.if\\n(:e .ds }0 \\n+(:a.
.if\\n(:e-1 .ds }0 \\n(:a)
.if\\n(:e-2 .ds }0 (\\n(:a)
.if\\n(:e-3 .ds }0 [\\n(:a]
.if\\n(:e-4 .ds }0 <\\n(:a>
.if\\n(:e-5 .ds }0 {\\n(:a}
.if\\n(.$-1 .ds }0 \\$1\ \\*(}0
.if\\n(.$=1 .ds }0 \\$1
.nr;0 \w\\*(}0
.nr;1 \\n(:c
.if\\n(:d .nr ;1 \\n(:bu-\\n(:du-\\n(;0u
.if!\\n(;1 .nr ;1 0
.nr;0 \\n(:bu-\\n(;1u-\\n(;0u
.ti\\n(;1u
.if!\\n(;0 .nr ;0 \w u
.if\w\\*(}0 \&\\*(}0\h\\n(;0u\&\c
..


.deLE
.if(\\n(:I>1)&(\\n(nl-\\n(:J) .nr :I 0
.if\\n(:I<2 .nr :I 0
.ie\\n(:g<1 .)D "LE:mismatched"
.el.)B
.if(\\n(:g<=\\n(Ls)&(\\n(.$>0) .SP
.nr:J \\n(nl
..


How in the heck does one learn how to read these macros???

smazu@ameris.UUCP (Steven P. Mazurek) (04/09/91)

In article <2570002@hpcc01.HP.COM>, burch@hpcc01.HP.COM (Jeff Burch) writes:
> My nroff source looks like:
>    .VL 20
>    .LI "/test\.[Ch]"
>    This regular expression will search for the string "test.C" or
>    "test.h".  Note: the "\" is used to escape the ".", otherwise ...
>    .LE
> 
> I want this to be formatted like:
>    /test\.[Ch]    This regulare expression will search for the "test.C" or
>                   "test.h". Note: ...

You need to use the "on-the-fly" printable version of the escape
character which in this case happens to be the back-slash. Try replacing
your .LI line with:

		.LI "/test\e.[Ch]"

the "\e" should print the back-slash.

If you have Documentor's Workbench manuals you should be able to locate
this and similar information in the section on Nroff/Troff Escape
sequences - good luck.



-- 
Steven P. Mazurek	 | Email: {...,uunet,bcr,ohumc}!ameris!smazu
Ameritech Services	 | 
Schaumburg, IL USA 60010 | Phone : (708) 605-2858

burch@hpcc01.HP.COM (Jeff Burch) (04/10/91)

I want to thank everyone who replied to my basenote.
I have learned that \e in a macro will ALWAYS output a single \

Also, when nroff/troff read anything, a \\ will be converted to a \
In otherwords, the number of backslashes gets reduced by two.
The tricky part is "how many times will nroff/troff read a macro?"
It turns out that the .LI macro gets read 4 times. Therefore, eight
back slashes will be reduced by 4*2 into a single back slash.

So,

	.LI test\e.dat

	.LI test\\\\\\\\.dat

both give

	test.dat

for output!

Thanks again!

woods@eci386.uucp (Greg A. Woods) (04/11/91)

In article <2570002@hpcc01.HP.COM> burch@hpcc01.HP.COM (Jeff Burch) writes:
> I am using the MM macro package for nroff and need to know the trick to
> escape a back slash for a ".VL" label. For example:
>[....]
> I have tried putting "\\" or "\\\" rather than "\" on the ".LI" line
> without any luck.

Since the '\' is the escape character, and since troff can sometimes
interpret text several times (eg. in diversions), use of '\' must be
sort of recursive (i.e.  one get's stripped off each time the text is
read), one either has to change the escape charater to something else,
or use the special character "escape", which prints the equivalent of
the current escape character ("\e").  It is in The Fine Manual!  :-)

> How in the heck does one learn how to read these macros???

One doesn't.... these are the "compacted" versions, with what little
comments and indendation from the sources removed.... at least not
without going slightly insane!

I usually re-indent them if I must try to read them.

There's also macref from DWB that will do cross-reference listings.
-- 
							Greg A. Woods
woods@{eci386,gate,robohack,ontmoh,tmsoft}.UUCP		ECI and UniForum Canada
+1-416-443-1734 [h]  +1-416-595-5425 [w]  VE3TCP	Toronto, Ontario CANADA
Political speech and writing are largely the defense of the indefensible-ORWELL