Article View: comp.text
Article #2349groff: copy/clone environments
From: Sverre Slotte Jr.
Date: Tue, 10 Nov 1992 08:32
Date: Tue, 10 Nov 1992 08:32
85 lines
4084 bytes
4084 bytes
Hi groff-users (and James Clark specifically)!
I have recently had the need to save many parameters of the current
flow of text, do something else (possibly something long and complicated)
and then return to the original flow. This "something else" could
for instance be creating a list with new values for line lengt, font,
point size, indent, justification etc. "Something else" could also
occur recursively. E.g.
[ex] Text text text text text text text text text text text text
[ex] Text text text text text text text text text text text text
[ex] Text text text text text text text text text text text text
[ex]
[ex] Someting_else_1 something_else_1 something_else_1
[ex] Someting_else_1 something_else_1 something_else_1
[ex]
[ex] Someting_else_2 something_else_2
[ex] Someting_else_2 something_else_2
[ex]
[ex] Someting_else_1 something_else_1 something_else_1
[ex]
[ex] Someting_else_2 something_else_2
[ex]
[ex] Someting_else_1 something_else_1 something_else_1
[ex] Someting_else_1 something_else_1 something_else_1
[ex]
[ex] Text text text text text text text text text text text text
[ex] Text text text text text text text text text text text text
One solution would be to identify the parameters that have to be
saved and somehow push them on/pop them off a stack (as in -mgm).
Partly because I don't know which parameters I need to save, partly
because the idea "feels right" I would like to use environments to
do this. By cloning the current environment and then doing the
necessary ".ll", ".in" etc. commands I could easily create an
environment for "Something_else_1". A simple ".ev" would then give me
back my original environment.
A command ".ev newenvironment" unfortunately creates a new environment
with uninteresting defaults (like a 6.5 inch line lengh, not my
current one). Hence, I need to copy the current environment into the
new one (or copy the old one into the new one).
However, the file groff-1.06/troff/TODO states: "Request to copy an
environment into the current environment." So it can't be done in
groff-1.06.
But I still want it. How do I do it? I'm no C++ man, but I've had a
look at some of the .cc files in the groff-distribution. The file
troff/env.cc contains the constructor (?)
environment::environment(const environment *e)
which, as far as I understand creates a new environment and
initializes it with the values of the previous current environment.
That's exactly the cloning functionality I need. It only has to be
given a groff-command (".clev" for "clone environment"?).
Although I need a new feature I would like to remain mainstream groff.
What do you, dear netfellows, think about "officializing" commands
like:
.cpev env1 env2 -- copy env1 into env2
.rmev env -- remove env
and possibly (it can be constructed from the above):
.clev newenv -- clone current env
.mvev env1 env2 -- rename env1 to env2
Comments welcome (and hints on how to do it). Use news or mail; I'll
summarize.
Sverre
--------------------------------------------------------------------------
Sverre Slotte Jr. Internet: sverre@rc.nokia.fi
Nokia Research Center Phone: + 358 0 4376208
P.O.Box 156, 02101 Esbo, FINLAND Phax: + 358 0 4376227
X.400 mail: G=sverre S=slotte OU=rc O=nokia ADMD=fumail C=fi
--------------------------------------------------------------------------
Wer nich liebt Wein, Weib und Gesang, der bleibt ein Narr sein Leben lang.
Martin Luther
Technical Details
Message-ID:
<1992Nov10.083231.6018@rc.nokia.fi>Path:
arc1-ca.pugleaf.net!sparky!uunet!mcsun!news.funet.fi!funic!nokia.fi!rc.nokia.fi!sverreShow Full Headers
Complete Article Headers
Newsgroups: comp.text Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!news.funet.fi!funic!nokia.fi!rc.nokia.fi!sverre From: sverre@rc.nokia.fi (Sverre Slotte Jr.) Subject: groff: copy/clone environments Message-ID: <1992Nov10.083231.6018@rc.nokia.fi> Organization: Nokia Research Center Date: Tue, 10 Nov 1992 08:32:31 GMT Lines: 85