Hello Hans and developers,
I have been trying to convert some two- and three-step macros (as shown below) to single-step macros using the LMTX syntax given in the low-level macros manual. I have succeeded in many cases, but failed when the macro follows one particular group of patterns.
The group of patterns is similar to this macro to process
\MyMacro[optional]{Required}{Required}{Optional}
In this the number of arguments can be 2, 3, or 4.
A three-step solution might be as follows, which I use for a list of persons:
\defineregister[Bindex]
\setupregister [Bindex][n=1,
balance=no,
method=default, % or New follows Newton!
compress=no, % yes if not note number+q
expansion=yes,
pagecommand=\gobbleoneargument
]\starttexdefinition unexpanded Bi
\dosingleempty\doBindex
\stoptexdefinition
\starttexdefinition unexpanded doBindex [#SORTAS]#INDEXED
\def\SortAs{#SORTAS}%
\def\Indexed{#INDEXED}%
\dodoublegroupempty\doBindexFull
\stoptexdefinition
\starttexdefinition doBindexFull #BD#MORE
\doifemptyelse{#MORE}
{\Bindex[\SortAs]{\Indexed\ #BD}}
{\Bindex[\SortAs]{\Indexed\ #BD\\ #MORE}}
\stoptexdefinition
with input like:
\Bi{Rumble, Walker}{1938|–|}%
\Bi{Runia, David Theunis}{1951|–|}{Classicist}%
\Bi{Rutherford, Ernest (Baron Rutherford of Nelson)}{1871|–|1937}{Physicist}%
\Bi{Saenger, Paul}{1945|–|}%
\Bi{Saldarini, Anthony J.}{1941|–|2001}%
\Bi{Salter, William M.}{1853|–|1931}%
\Bi[Saint-Exupery]{de Saint-Exupéry, Antoine}{1900|–|1944}%
\Bi{Santayana, George}{1863|–|1952}%
\Bi{Sapir, Edward}{1884|–|1939}{Linguist}%
\Bi[Schrodinger]{Schrödinger, Erwin}{1887|–|1961}{Physicist}%
\Bi[Spinoza]{de Spinoza, Baruch (Benedict de Spinoza, Bento de Espinosa)}{1632|–|1677}%
The best I can get with the newer syntax is a two-step:
\starttexdefinition unexpanded Bi
\dosingleempty\doBindex
\stoptexdefinition
\tolerant\def\doBindex [#1]#=#=#=%
{\doifemptyelse{#4}
{\Bindex[#1]{#2\ #3}}%
{\Bindex[#1]{#2\ #3\\ #4}}%
}
In the low-level macros manual, near the end of chapter 2, it says that some day there may be a use for #?, #!, #<, or #>. If I am not missing something in the manual about how to provide that first optional argument as an empty value, I think I have one. Could [#?] always return a value (perhaps empty)? That would allow something like:
\tolerant\def\doBindex [#?]#=#=#=%
{\doifemptyelse{#4}
{\Bindex[#1]{#2\ #3}}%
{\Bindex[#1]{#2\ #3\\ #4}}%
}
--
Rik