n-t-roff / heirloom-doctools

The Heirloom Documentation Tools: troff, nroff, and related utilities
http://n-t-roff.github.io/heirloom/doctools.html
Other
127 stars 23 forks source link

Set ms registers via -r command line flag #111

Closed rnkn closed 2 years ago

rnkn commented 2 years ago

Hello,

I'm not sure if I'm supposed to be able to do this, but I'd like to set some registers on the command line like so:

< test.ms troff -ms -rPS=12p -rLL=5i -rPO=1.5i | dpost > out.ps

While this works with groff, here it seems to have no effect. Or am I doing something wrong?

Thanks in advance for any help.

n-t-roff commented 2 years ago

From a first view in s.in registers PS and LL seem to be overwritten in macro IZ which is evaluated before any text:

.nr PS 10
.nr LL 6i

PO seems to be set from .o:

.nr PO \\n(.o

so using -r.o=1.5i could have effect.

rnkn commented 2 years ago

Ah I see. And groff's ms has to use checks for these set on the command line: https://git.savannah.gnu.org/cgit/groff.git/tree/tmac/s.tmac?h=1.22.4#n1029

Unfortunately -r.o=1.5i has no effect for me.

rnkn commented 2 years ago

Would you accept a patch for setting ms registers vi the -r command line flag, or would that conflict with the original UNIX design?

Alhadis commented 2 years ago

Unfortunately -r.o=1.5i has no effect for me.

That's because .o is a read-only register, and you're supposed to set page-length using the .po request ("page offset").

rnkn commented 2 years ago

you're supposed to set page-length using the .po request ("page offset").

Yep, that's why I'm doing in my first comment, which unfortunately has no effect.

Alhadis commented 2 years ago

In that case, I'd suggest amending s.in to honour a preset \n(PO value, if any. Try this:

diff --git a/troff/troff.d/tmac.d/s.in b/troff/troff.d/tmac.d/s.in
index e5e5860..b1bc36a 100644
--- a/troff/troff.d/tmac.d/s.in
+++ b/troff/troff.d/tmac.d/s.in
@@ -66,7 +66,7 @@
 .nr IR 0
 .nr TB 0
 .nr SJ \\n(.j
-.nr PO \\n(.o
+.if !\\n(PO>0 .nr PO \\n(.o
 .nr LL 6i
 .ll \\n(LLu
 .lt 6i

The other registers (SJ, LL, et al) would also benefit from a similar addition.

n-t-roff commented 2 years ago

@rnkn , @Alhadis you could submit a pull request, if you want.

Alhadis commented 2 years ago

I'll have a crack at it.

EDIT: Done. See #112.