[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Groff] Copy register value to another register?
From: |
Steve Izma |
Subject: |
Re: [Groff] Copy register value to another register? |
Date: |
Sun, 30 May 2010 23:03:27 -0400 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
On Sun, May 30, 2010 at 05:41:51PM -0600, Clarke Echols wrote:
> Subject: [Groff] Copy register value to another register?
>
> I'm attempting to capture the current value of the vertical position
> register ( \n[nl] ) and set another register to that value so I can
> use it to return to the current location for further output.
>
> If I have inline code like this:
>
> > .nr returnlocation \n[nl]
> >
> > <do some stuff here>
> >
> > .sp |\n[returnlocation]u
>
> it works as expected.
>
> But I prefer to use a macro like this:
>
> .de macro
> .nr returnlocation \n[nl]u \"Preserve location to return to.
> <other code>
>
> But when I do that, the register [returnlocation] is assigned a value
> of -1 when I call the macro.
You need to double the backslashes when setting the register from
within a macro. If you don't, you get the current position at the
time that the macro is being defined, which is likely to be before
any output has occurred. The current position on a page before
any output or any breaks is always -1, i.e., a value less than
zero. The position 0 is the top of the page, but only after
output is triggered.
-- Steve
--
Steve Izma
-
Home: 35 Locust St., Kitchener N2H 1W6 p:519-745-1313 FAX:519-579-9872
Work: Wilfrid Laurier University Press p:519-884-0710 ext. 6125
E-mail: address@hidden or address@hidden
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?
<http://en.wikipedia.org/wiki/Posting_style>