gbranden pushed a commit to branch master
in repository groff.

commit 01c47a6ca8aaad09805821ddd51ab955f4495c25
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sat May 16 18:15:12 2026 -0500

    [man]: Implement `LS`/`LE` indentation management.
    
    * tmac/an.tmac (TP, IP, HP): If macro called in a list context (the
      "list depth" is greater than zero), and an indentation for the current
      list depth is defined, set the prevailing indent to that indentation.
      (We still, and subsequently, override the prevailing indent with the
      indentation argument to these macros, if present.)
    
    * tmac/groff_man.7.man.in (List enclosure macros): Document it.
    
    * tmac/tests/an_LS-and-LE-work.sh: Unit-test effect of list indentation
      on `HP` macro behavior.  Update test expecations of `TP` behavior now
      that indentation is inherited.  Apply a tab-to-space-translating tr(1)
      command on the test output, fearing inconsistencies among Unices in
      how nl(1) prefixes the lines it filters.
    
    Continues fixing <https://savannah.gnu.org/bugs/?68335>.
---
 ChangeLog                       | 22 ++++++++++++++
 tmac/an.tmac                    | 31 +++++++++++++------
 tmac/groff_man.7.man.in         |  9 +++---
 tmac/tests/an_LS-and-LE-work.sh | 67 ++++++++++++++++++++++++++++++++---------
 4 files changed, 99 insertions(+), 30 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 22336046c..8c1f56ac7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2026-05-16  G. Branden Robinson <[email protected]>
+
+       [man]: Implement `LS`/`LE` indentation management.
+
+       * tmac/an.tmac (TP, IP, HP): If macro called in a list context
+       {the "list depth" is greater than zero}, and an indentation for
+       the current list depth is defined, set the prevailing indent to
+       that indentation.  {We still, and subsequently, override the
+       prevailing indent with the indentation argument to these macros,
+       if present.}
+
+       * tmac/groff_man.7.man.in (List enclosure macros): Document it.
+
+       * tmac/tests/an_LS-and-LE-work.sh: Unit-test effect of list
+       indentation on `HP` macro behavior.  Update test expecations of
+       `TP` behavior now that indentation is inherited.  Apply a
+       tab-to-space-translating tr(1) command on the test output,
+       fearing inconsistencies among Unices in how nl(1) prefixes the
+       lines it filters.
+
+       Continues fixing <https://savannah.gnu.org/bugs/?68335>.
+
 2026-05-16  G. Branden Robinson <[email protected]>
 
        * src/devices/grotty/tty.cpp: Preprocessor-include
diff --git a/tmac/an.tmac b/tmac/an.tmac
index e2f595195..e419878b9 100644
--- a/tmac/an.tmac
+++ b/tmac/an.tmac
@@ -911,12 +911,14 @@ contains unsupported escape sequence
 .  if \\n[.it] .an-warn cannot call .\\$0 while an input trap is pending
 .  if \\n[DEBUG] .tm GBR: mark VALID07: \\$0
 .  an*break-paragraph 1
+.  if (\\n[an*list-depth] > 0) \{\
+.    if \\n[DEBUG] .tm GBR: mark VALID15: \\$0
+.    if !'\?\\*[an*list-indent!\\n[an*list-depth]]\?'\?\?' \{\
+.      if \\n[DEBUG] .tm GBR: mark VALID16: \\$0
+.      nr an*prevailing-indent \\*[an*list-indent!\\n[an*list-depth]]
+.    \}
+.  \}
 .  if \\n[.$] .nr an*prevailing-indent (n;\\$1)
-.\"el \{\
-.\"  if (\\n[an*list-depth] > 0)
-.\"  if !'\?\\*[an*list-indent!\\n[an*list-depth]]\?'\?\?' \
-.\"    nr an*prevailing-indent \\*[an*list-indent!\\n[an*list-depth]]
-.\"\}
 .  if '\\n[.z]'an*paragraph-tag' \{\
 .    an-warn cannot nest .\\$0 or .TQ inside .\\$0; supply a tag
 .    return
@@ -938,6 +940,13 @@ contains unsupported escape sequence
 .    if \\n[DEBUG] .tm GBR: mark VALID08: \\$0
 .    an*break-paragraph 1
 .    ne (1v + 1u)
+.    if (\\n[an*list-depth] > 0) \{\
+.      if \\n[DEBUG] .tm GBR: mark VALID17: \\$0
+.      if !'\?\\*[an*list-indent!\\n[an*list-depth]]\?'\?\?' \{\
+.        if \\n[DEBUG] .tm GBR: mark VALID18: \\$0
+.        nr an*prevailing-indent \\*[an*list-indent!\\n[an*list-depth]]
+.      \}
+.    \}
 .    in (\\n[an*margin]u + \\n[an*prevailing-indent]u)
 .  \}
 .  el \{\
@@ -954,12 +963,14 @@ contains unsupported escape sequence
 .  an*break-paragraph 1
 .  ll \\n[LL]u
 .  ne (1v + 1u)
+.  if (\\n[an*list-depth] > 0) \{\
+.     if \\n[DEBUG] .tm GBR: mark VALID19: \\$0
+.    if !'\?\\*[an*list-indent!\\n[an*list-depth]]\?'\?\?' \{\
+.      if \\n[DEBUG] .tm GBR: mark VALID20: \\$0
+.      nr an*prevailing-indent \\*[an*list-indent!\\n[an*list-depth]]
+.    \}
+.  \}
 .  if \\n[.$] .nr an*prevailing-indent (n;\\$1)
-.\"el \{\
-.\"  if (\\n[an*list-depth] > 0)
-.\"  if !'\?\\*[an*list-indent!\\n[an*list-depth]]\?'\?\?' \
-.\"    nr an*prevailing-indent \\*[an*list-indent!\\n[an*list-depth]]
-.\"\}
 .  in (\\n[an*margin]u + \\n[an*prevailing-indent]u)
 .  ti \\n[an*margin]u
 .  DEVTAG-COL 1
diff --git a/tmac/groff_man.7.man.in b/tmac/groff_man.7.man.in
index 5202508a3..a55ab4a25 100644
--- a/tmac/groff_man.7.man.in
+++ b/tmac/groff_man.7.man.in
@@ -1102,8 +1102,7 @@ These macros are GNU extensions.
 .
 .TP
 .BI .LS\~ type\~\c
-.RI [ compactness ]
-.\"RI [ compactness \~[ indentation ]
+.RI [ compactness \~[ indentation ]
 .IR (since\~ groff \~1.25) \" TODO: remove note once novelty dies down
 Start
 (or open)
@@ -1120,9 +1119,9 @@ or
 is a Boolean value directing suppression of inter-paragraph spacing
 between list items.
 .
-.\".I indentation
-.\"specifies an indentation amount for the body of each list item;
-.\"it is then unnecessary to specify this argument to the list item macros.
+.I indentation
+specifies an indentation amount for the body of each list item;
+it is then unnecessary to specify this argument to the list item macros.
 .
 Use
 .B IP
diff --git a/tmac/tests/an_LS-and-LE-work.sh b/tmac/tests/an_LS-and-LE-work.sh
index 7c43083b1..12668c885 100755
--- a/tmac/tests/an_LS-and-LE-work.sh
+++ b/tmac/tests/an_LS-and-LE-work.sh
@@ -76,10 +76,29 @@ the Z80:
 .IP 4.
 the 8086:
 .B LOOPZ
+.LE
+.LS definition 0 5n \" maybe a poor fit for HP, but oh well
+.HP
+Let\[cq]s hang,
+bro.
+Ut enim ad minima veniam,
+quis nostrum exercitationem ullam corporis suscipitlaboriosam,
+nisi ut aliquid ex ea commodi consequatur?
+.HP 10n
+I can hang longer than you.
+Quis autem vel eum iure reprehenderit,
+qui inea voluptate velit esse,
+quam nihil molestiae consequatur,
+vel illum,
+qui dolorem eum fugiat,
+quo voluptas nulla pariatur?
+.LE
 .'
 
 output=$(printf "%s\n" "$input" \
-    | "$groff" -r LL=65n -m an -T ascii -P -cbou | nl -ba)
+    | "$groff" -rDEBUG=1 -r LL=65n -m an -T ascii -P -cbou \
+    | nl -ba | tr '\t' ' ')
+
 echo "$output"
 
 # Expected output:
@@ -89,22 +108,22 @@ echo "$output"
 #      4       foo - frobnicate a bar
 #      5
 #      6  Description
-#      7       *      alpha
-#      8       *      beta
-#      9       *      gamma
+#      7       *   alpha
+#      8       *   beta
+#      9       *   gamma
 #     10
-#     11                 charlie
-#     12                        Sed ut perspiciatis.
-#     13
-#     14                 delta  Unde omnis iste natus error sit voluptatem.
+#     11                 charlie     Sed ut perspiciatis.
+#     12
+#     13                 delta       Unde omnis iste natus error sit volup-
+#     14                             tatem.
 #     15
-#     16                        Totam  rem aperiam eaque ipsa, quae ab illo
-#     17                        inventore  veritatis  et  quasi  architecto
-#     18                        beatae vitae dicta sunt.
+#     16                             Totam  rem aperiam eaque ipsa, quae ab
+#     17                             illo inventore veritatis et quasi  ar-
+#     18                             chitecto beatae vitae dicta sunt.
 #     19
-#     20                 echo   Accusantium doloremque laudantium.
+#     20                 echo        Accusantium doloremque laudantium.
 #     21
-#     22       *      delta
+#     22       *   delta
 #     23
 #     24     Assembly language
 #     25       Several  computer  architectures satisfy Turing-completeness
@@ -115,16 +134,34 @@ echo "$output"
 #     30       3.     the Z80: DJNZ
 #     31       4.     the 8086: LOOPZ
 #     32
-#     33  groff test suite            2026-05-10                     foo(1)
+#     33       Let's hang, bro.  Ut enim ad minima veniam, quis nostrum ex-
+#     34            ercitationem ullam corporis suscipitlaboriosam, nisi ut
+#     35            aliquid ex ea commodi consequatur?
+#     36
+#     37       I can hang longer than you.  Quis autem vel eum iure  repre-
+#     38                 henderit,  qui inea voluptate velit esse, quam ni-
+#     39                 hil molestiae consequatur, vel illum, qui  dolorem
+#     40                 eum fugiat, quo voluptas nulla pariatur?
+#     41
+#     42  groff test suite            2026-05-10                     foo(1)
 
 echo "checking that list compactness is applied" >&2
 echo "$output" | grep -Eqx '[[:space:]]+8[[:space:]]+\* +beta' || wail
 echo "checking that nested list indentation accumulates" >&2
-echo "$output" | grep -Eqx '[[:space:]]+11[[:space:]]{16}charlie' \
+echo "$output" \
+    | grep -Eq '^[[:space:]]+11[[:space:]]{16}charlie {5}Sed' \
     || wail
 echo "checking that compactness not applied to continuation pararaphs" \
     >&2
 echo "$output" | grep -Eq '[[:space:]]+16[[:space:]]+Totam' || wail
+echo "checking that hanging paragraph employs indentation of" \
+    "containing list" >&2
+echo "$output" | grep -Eq '[[:space:]]+34[[:space:]]{11}ercitationem' \
+    || wail
+echo "checking that identation argument to hanging paragraph macro" \
+    "overrides list indentation" >&2
+echo "$output" | grep -Eq '[[:space:]]+38[[:space:]]{16}henderit' \
+    || wail
 
 test -z "$fail"
 

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to