groff
[Top][All Lists]
Advanced

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

Re: [Groff] Macro arguments question


From: Clarke Echols
Subject: Re: [Groff] Macro arguments question
Date: Sun, 13 Nov 2005 16:06:53 -0700
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)

Ted,

DUH! :-)

Thanks.

I tried my idea after I posted my thinking, and found what you did:
Escaping end-of-line with quotes around the entire thing does work
as intended, but I have to pay attention to breaks, and using \{-\}
pairs keeps the quotes.  However, your suggested method works as I
intended for the most part.  I was having trouble with part of the
last line not being output because I switched environments for the
macro and when I added the .ev on exit, it dumped the last of the
text.  A .br request fixed that part.

I'm now having trouble with switching environments (something I've
never properly understood).  I supposed that if you define a new
environment, it would "inherit" the old environment except for
re-defined variables, and when you switch back, it restores the
old environment values (like a Unix shell would do).  Thus, if you
have a .ps 12 and .vs 14 before entering the new environment, it
should maintain that size and leading.  However, in practice it seems
to use a smaller (default?) size instead, unless
I redefine the point size inside the new environment ("info groff"
in my Cygwin on Windows 98 doesn't make that very clear).  On the
other hand, if I redefine the .po and .ll values, the .po seems to
work, but groff was running the text on the right to the end of
the sheet before starting the next line.  However, that seems to
all be cleared up now.  [If this is confusing, it's because I'm
a bit confused.]  But what I am seeing is that if I switch to
.ev 1 and redefine ".po 3i" instead of ".po 1i", when I go back
to the original environment, the page offset remains at 3i instead
of going back to the old value while the line length seems to go
back to its old value, running the text to the right side of the
sheet(.po and .ll without arguments before the ".ev" request fixes
the problem but doesn't look "clean".  So it looks like the new
questions are:

  1. Does the .ev change not include page offset as a variable to
     be processed by the alternate environent (i.e., it's a global
     value that is independent of the environment?

  2. Does a new environment inherit system default values instead
     of existing values in effect immediately before the environment
     is redefined?

The way I see it now, it seems that before switching the
environment, I seem to need to make a .br request at the start
of the macro definition or make sure a .sp or something causes a
break, then switch environments, do what I need to do, issue
another .br, then switch the environment back.

I thought I had found a lengthy book-like file once (part of Cygwin
groff package) explaining all of the groff stuff in depth, but I
haven't since re-discovered where it's hidden.

Thanks for your help.

(Ted Harding) wrote:
On 13-Nov-05 Clarke Echols wrote:

One thing I *really* like about groff vs troff/ditroff is the
expansion of macro and other entity names beyond two characters.
Nice job!

I am considering using macros to solve a problem that would be better
if handled in a database, but I don't want to write the software to
do it.  However, it would be nice if I could string some multi-line
text together as a single argument to a macro.  However, it is not
obvious to me that it can or cannot be done the way I'm thinking.  I
have been considering something on this order:

.macro \{
"text line 1, blah blah blah
text line 2, blah blah blah
text line 3, more here"\}

I would like to have the text processed as a single argument to
the macro just as groff would handle:

.macro "argument number one"

and then wrapped and adjusted as with normal text from a
typical input file.


Hi Clarke,
Maybe I'm missing something, but would the following be something
you do not want to do, for some reason?

.macro \
"text line 1, blah blah blah \
text line 2, blah blah blah \
text line 3, more here"




   1.  Will this work?


Your example above perhaps does not work as (seems to be) intended,
i.e. if I define

.de temp
\\$1
..
.temp \{
"text line 1, blah blah blah
text line 2, blah blah blah
text line 3, more here"\}

then I get

"text line 1, blah blah blah text line 2, ... line 3, more here"

as one line (presumably as intended), but with the quotes as well,
which I suspect you don't want. But this is a consequence of
wrapping it in \{...\}, so if you just remove the quotes from
your argument it comes out right.


   2.  If not, is there a different, quick-and-easy/dirty way
       to do it?

Any opinions out there?>


Maybe see above ... ?

Best wishes,
Ted.


--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 094 0861
Date: 13-Nov-05                                       Time: 22:34:02
------------------------------ XFMail ------------------------------





reply via email to

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