Here's a patch to fix the problem, but I'm not entirely
happy with it since it feels like it is usurping ms's chain
of command.  On the other hand, I'm not sure a clean solution
exists short of rewriting a large part of ms's internals.

The problem is that we have to delay evaluating IP's argument
until the font size has been reset, which I've attempted to
do by simply passing the argument unevaluated down the call
hierarchy, instead of saving it in a number register right
away, as appears customary in this ms implementation.[*]

However, par@reset is called from a great number of places,
and these usually set the indent registers beforehand.
I've left this as it is, so now two ways of setting the
indents exist: via register and optionally via argument.

What my patch does is:

  In IP: pass argument unevaluated to par*start.
  In other paragraph macros: pass arguments from registers
    to par*start with explicit "u" scaling indicator.

  In par*start and par@finish: don't set registers,
    but instead pass arguments to par@reset.

  In par@reset: move font-size setting stuff before
    indent-setting stuff; set registers from optional
    arguments with default "n" scaling indicator
    before setting indents.

Please test!



[*] What I do in my own macros in these cases is to save the
argument in a string instead of a number register, thus
allowing it to be stored literally and later interpreted when
necessary in the appropriate context, but doing this here
would have also required widespread modifications to the ms
source code to remain internally consistent.


--- /usr/share/groff/current/tmac/s.tmac        2017-06-25 22:19:44.000000000 
+0200
+++ s.tmac      2018-08-17 20:02:01.000000000 +0200
@@ -1162,15 +1162,6 @@
 .rj 0
 .ul 0
 .fi
-.ie \\n[pg@ncols]>1 \{\
-.      ll (u;\\n[\\n[.ev]:MCLL]-\\n[\\n[.ev]:ri]-\\n[\\n[.ev]:pri])
-.      lt \\n[\\n[.ev]:MCLT]u
-.\}
-.el \{\
-.      ll (u;\\n[\\n[.ev]:LL]-\\n[\\n[.ev]:ri]-\\n[\\n[.ev]:pri])
-.      lt \\n[\\n[.ev]:LT]u
-.\}
-.in (u;\\n[\\n[.ev]:li]+\\n[\\n[.ev]:pli])
 .ft 1
 .fam \\*[FAM]
 .ie (\\n[\\n[.ev]:PS] >= 1000) \
@@ -1182,13 +1173,22 @@
 .el \
 .      par*vs \\n[\\n[.ev]:VS]
 .ls 1
+.if !'\\$1'' .nr \\n[.ev]:pli (n;\\$1)
+.if !'\\$2'' .nr \\n[.ev]:pri (n;\\$2)
+.ie \\n[pg@ncols]>1 \{\
+.      ll (u;\\n[\\n[.ev]:MCLL]-\\n[\\n[.ev]:ri]-\\n[\\n[.ev]:pri])
+.      lt \\n[\\n[.ev]:MCLT]u
+.\}
+.el \{\
+.      ll (u;\\n[\\n[.ev]:LL]-\\n[\\n[.ev]:ri]-\\n[\\n[.ev]:pri])
+.      lt \\n[\\n[.ev]:LT]u
+.\}
+.in (u;\\n[\\n[.ev]:li]+\\n[\\n[.ev]:pli])
 .TA
 .hy \\n[HY]
 ..
 .de @RT
-.nr \\n[.ev]:pli 0
-.nr \\n[.ev]:pri 0
-.par@reset
+.par@reset 0 0
 ..
 .\" This can be redefined by the user.
 .de TA
@@ -1201,16 +1201,12 @@
 .
 .de par*start
 .ds@auto-end
-.nr \\n[.ev]:pli \\$1
-.nr \\n[.ev]:pri \\$2
-.par@reset
+.par@reset \\$1 \\$2
 .sp \\n[\\n[.ev]:PD]u
 .ne \\n[PORPHANS]v+\\n(.Vu
 ..
 .de par@finish
-.nr \\n[.ev]:pli 0
-.nr \\n[.ev]:pri 0
-.par@reset
+.par@reset 0 0
 ..
 .\" normal LP
 .de @LP
@@ -1224,15 +1220,18 @@
 ..
 .de @QP
 .nr \\n[.ev]:ai \\n[\\n[.ev]:PI]
-.par*start \\n[QI] \\n[QI]
+.par*start \\n[QI]u \\n[QI]u
 ..
 .de @XP
-.par*start \\n[\\n[.ev]:PI] 0
+.par*start \\n[\\n[.ev]:PI]u 0
 .ti -\\n[\\n[.ev]:PI]u
 ..
 .de @IP
-.if \\n[.$]>1 .nr \\n[.ev]:ai (n;\\$2)
-.par*start \\n[\\n[.ev]:ai] 0
+.ie \\n[.$]>1 \{\
+.par*start \\$2 0
+.nr \\n[.ev]:ai \\n[\\n[.ev]:pli]
+.\}
+.el .par*start \\n[\\n[.ev]:ai]u 0
 .if !'\\$1'' \{\
 .      \" Divert the label so as to freeze any spaces.
 .      di par*label

Reply via email to