groff
[Top][All Lists]
Advanced

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

Re: [Groff] Extending .tm to allow for file handles


From: Ted Harding
Subject: Re: [Groff] Extending .tm to allow for file handles
Date: Tue, 16 Feb 2010 10:19:31 -0000 (GMT)

On 16-Feb-10 09:34:58, Tadziu Hoffmann wrote:
> 
>> I was wondering if their is any possibility having .tm write
>> to anything other than STDOUT ? It would make managing forward
>> references (when used with 2 groff passes) much easier.
> 
> Instead of .tm you should use ".write <stream> <stuff>",
> which does exactly what you want.  (A stream is like a
> filehandle, use ".open <stream> <filename>" to connect
> the stream to a file first.)

Tadziu has pointed out the essence of the matter! What I was
writing before (when I got cut off) was essentially:

>From the form of your question, it would seem that you want
to save the information in \*[reference-info] to an external
file, to be read back in on the second pass. There is a family
of groff requests for this kind of thing. In 'info groff' see
the requests:

 - Request: .open stream file
 - Request: .opena stream file
 - Request: .write stream data
 - Request: .writec stream data
 - Request: .writem stream xx
 - Request: .close stream

(perhaps especially .writem -- see below); and also look at the
example given just below ".close" which illustrates how to write
an index entry to an external file.

Something like

.open refstream reffile.txt
.writem refstream reference-info
.close refstream

will probably do what you want. In the above, the parameter
"stream" is an arbitrary name (I have used "refstream") serving
to identify an output stream which has been opened; this name
is then released when ".close" is executed. "file" is the name
of the file which you attach to "stream" for writing. "xx" is the
name of a groff macro or string (in your case \*[reference-info],
so xx = reference-info).

You will need to run groff in "unsafe" mode (option -U) for
these to work. Use ".opena" to append to an existing file
(since ".open" would cause an existing file to be over-written).

Hoping this helps,
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 094 0861
Date: 16-Feb-10                                       Time: 10:19:26
------------------------------ XFMail ------------------------------




reply via email to

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