Ulrich --

On Sun, Nov 26, 2017, Ulrich Lauther wrote:
> 2) if ROMAN or roman is used without a trailing number, e.g., ROMAN instead 
> of ROMAN7,
>    the command ".tm1 "[mom]: You must append a number to the \\$1 argument to 
> \\$0."
>    should be invoced, but is not.
> 
> The small patch appended introduces
>    LIST VARIABLE <width of largest enunerator>
> and
>    ITEM <enumerator>

Entering the widest glyph literally rather than its width, which
would have to be calculated, makes things simpler.  Furthermore, if
the glyph is in double-quotes, users can add space to or subtract
it from the gutter between the enumerators and the text with \*[FWD dist].
 
> The patch fixes also issue 2.

  .       if !\B'\\*[$LAST_CHAR]' \{\
- .          if !'\\$1'ROMAN' \{\
- .             LIST OFF
- .             return
- .          \}
- .          if !'\\$1'roman' \{\
- .             LIST OFF
- .             return
- .          \}
  .          tm1 "[mom]: You must append a number to the \\$1 argument to \\$0.
  .          tm1 "       The number should be the total number of items in this 
list.
  .          tm1 "       See the documentation.

If you remove the two 'if' clauses,

  .LIST RETURN

spits out

  [mom]: You must append a number to the RETURN argument to LIST.

because an initial letter R is checked for in order to process
ROMAN<n> and roman<n> lists.

Apply the attached, revised patch and test.  Variable enumerator
lists are entered with, for example,

  .LIST VARIABLE \[en]

Mom calculates the width of the en-dash and adds the same
unbreakable and unpaddable space used as a gutter for all other
enumerator types.

-- 
Peter Schaffter
http://www.schaffter.ca
--- mom-2.2-a/om.tmac	2017-11-26 14:46:58.055910878 -0500
+++ om.tmac	2017-11-26 14:46:15.119234406 -0500
@@ -15662,18 +15662,17 @@
 .    if !'\\*[$1ST_LETTER]'' .substring $1ST_LETTER 0 0
 .    if '\\*[$1ST_LETTER]'r' .ds $1ST_LETTER R
 .    ie '\\*[$1ST_LETTER]'R' \{\
+.       if r #ROMAN_LIST .rr #ROMAN_LIST
+.       if '\\$1'ROMAN'  .nr #ROMAN_LIST 1
+.       if '\\$1'roman'  .nr #ROMAN_LIST 1
 .       ds $LAST_CHAR \\$1
 .       substring $LAST_CHAR -1
 .       if !\B'\\*[$LAST_CHAR]' \{\
-.          if !'\\$1'ROMAN' \{\
+.          if !r #ROMAN_LIST \{\
 .             LIST OFF
 .             return
 .          \}
-.          if !'\\$1'roman' \{\
-.             LIST OFF
-.             return
-.          \}
-.          tm1 "[mom]: You must append a number to the \\$1 argument to \\$0.
+.          tm1 "[mom]: You must append a number to the '\\$1' argument to \\$0.
 .          tm1 "       The number should be the total number of items in this list.
 .          tm1 "       See the documentation.
 .          ab   [mom]: Aborting '\\n[.F]' at \\$0, line \\n[.c].
@@ -15807,6 +15806,19 @@
 .          ds $SEPARATOR\\n[#DEPTH]
 .          ds $PREFIX\\n[#DEPTH]
 .       \}
+.       if '\\*[$LIST_ARG_1]'VARIABLE' \{\
+.          if \\n[#NUM_ARGS]<2 \{\
+.             tm1 "[mom]: You must follow the \\$1 argument to \\$0 with the widest
+.             tm1 "       enumerator to be used.  See the documentation.
+.             ab   [mom]: Aborting '\\n[.F]' at \\$0, line \\n[.c].
+.          \}
+.          nr #ARGS_TO_LIST 1
+.          ds $ENUMERATOR\\n+[#DEPTH]
+.          ds $ENUMERATOR_TYPE\\n[#DEPTH] variable
+.          ds $ENUMERATOR_WIDTH\\n[#DEPTH] \w'\\$2\ '
+.          ds $SEPARATOR\\n[#DEPTH]
+.          ds $PREFIX\\n[#DEPTH]
+.       \}
 .       if '\\*[$LIST_ARG_1]'PLAIN' \{\
 .          nr #ARGS_TO_LIST 1
 .          ds $ENUMERATOR\\n+[#DEPTH]
@@ -15848,6 +15860,8 @@
 .       GET_ROMAN_INDENT
 .    if '\\*[$ENUMERATOR_TYPE\\n[#DEPTH]]'other' \
 .       nr #LIST_INDENT\\n[#DEPTH] \w'\\*[$ENUMERATOR\\n[#DEPTH]]\ '
+.    if '\\*[$ENUMERATOR_TYPE\\n[#DEPTH]]'variable' \
+.       nr #LIST_INDENT\\n[#DEPTH] \\*[$ENUMERATOR_WIDTH\\n[#DEPTH]]
 .    ll \\n[#CURRENT_L_LENGTH]u
 .    ie \\n[#DEPTH]=1 \{\
 .       ie \\n[#INDENT_ACTIVE]=1 \{\
@@ -16007,6 +16021,8 @@
 .       \}
 .       if '\\*[$ENUMERATOR_TYPE\\n[#DEPTH]]'other' \
 .          PRINT \\*[$ENUMERATOR\\n[#DEPTH]]\\*[$SEPARATOR\\n[#DEPTH]]
+.       if '\\*[$ENUMERATOR_TYPE\\n[#DEPTH]]'variable' \
+.          PRINT  \\$1
 .    \}
 .    rr #SEP_TYPE
 .    EOL

Reply via email to