Skip to content

Commit

Permalink
use tl_map_tokens:nn for ProcessList (#1649)
Browse files Browse the repository at this point in the history
* use tl_map_tokens:nn

* add unit tests

* fix hand-generated test log...
  • Loading branch information
Skillmon authored Feb 10, 2025
1 parent 7ac9030 commit d205f0e
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 7 deletions.
6 changes: 6 additions & 0 deletions base/changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ not part of the distribution.
Document more prominently that using a hook with \UseHook or similar
commands requires that the hook to be declared first (gh/1519)

2025-02-01 Jonathan P. Spratte

* ltcmd.dtx (subsection{User functions}):
Generalise \ProcessList by using \tl_map_tokens:nn instead of
\tl_map_function:nN.

2025-01-31 Frank Mittelbach <[email protected]>

* latexrelease.dtx (subsection{Ignoring \texttt{\string_new} errors when rolling back}):
Expand Down
14 changes: 10 additions & 4 deletions base/doc/usrguide.tex
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
\texttt{usrguide.tex} for full details.}%
}

\date{2025-01-24}
\date{2025-02-01}

\NewDocumentCommand\cs{m}{\texttt{\textbackslash\detokenize{#1}}}
\NewDocumentCommand\marg{m}{\arg{#1}}
Expand Down Expand Up @@ -668,15 +668,21 @@ \subsection{Argument processors}
\end{verbatim}

\begin{decl}
|\ProcessList| \arg{list} \arg{cmd}
|\ProcessList| \arg{list} \arg{tokens}
\end{decl}
To support \cs{SplitList}, the function \cs{ProcessList} is available
to apply a \meta{cmd} to every entry in a \meta{list}. The
\meta{cmd} should absorb one argument: the list entry. For example
to apply \meta{tokens} to every entry in a \meta{list}. The
\meta{tokens} can be arbitrary contents that should expect one argument
after it: the list entry. For example
\begin{verbatim}
\NewDocumentCommand \foo {>{\SplitList{;}} m}
{\ProcessList{#1}{\SomeDocumentCommand}}
\end{verbatim}
or
\begin{verbatim}
\NewDocumentCommand \foo {>{\SplitList{;}} m}
{\ProcessList{#1}{Abc \SomeDocumentCommand}}
\end{verbatim}

\begin{decl}
|\ReverseBoolean|
Expand Down
8 changes: 5 additions & 3 deletions base/ltcmd.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
%%% From File: ltcmd.dtx
%
% \begin{macrocode}
\def\ltcmdversion{v1.3a}
\def\ltcmddate{2025-01-24}
\def\ltcmdversion{v1.3b}
\def\ltcmddate{2025-02-01}
% \end{macrocode}
%
%<*driver>
Expand Down Expand Up @@ -5706,8 +5706,10 @@
%
% \begin{macro}{\ProcessList}
% To support \cs{SplitList}.
% \changes{v1.3b}{2025-02-01}
% {Use \cs{tl_map_tokens:nn} instead of \cs{tl_map_function:nN}}
% \begin{macrocode}
\cs_new_eq:NN \ProcessList \tl_map_function:nN
\cs_new_eq:NN \ProcessList \tl_map_tokens:nn
% \end{macrocode}
% \end{macro}
%
Expand Down
10 changes: 10 additions & 0 deletions base/testfiles-ltcmd/ltcmd004.luatex.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -609,3 +609,13 @@ TEST 31: Processor depending on other argument
|{a}{bcd;e}|1|
|{a,bcd}{e}|1|
============================================================
============================================================
TEST 32: ProcessList
============================================================
a
b,c
|a|ARG|
||ARG|
|b,c|ARG|
|\empty |ARG|
============================================================
11 changes: 11 additions & 0 deletions base/testfiles-ltcmd/ltcmd004.lvt
Original file line number Diff line number Diff line change
Expand Up @@ -518,4 +518,15 @@
\foo { a , bcd ; e } [;]
}
\TEST { ProcessList }
{
\DeclareDocumentCommand \foo { >{\SplitList{,}}m }
{ \ProcessList{#1}{\TYPE} }
\foo{a,,{b,c}}
\NewDocumentCommand \fooAux { m m } { \TYPE { \tl_to_str:n { |#2|#1| } } }
\DeclareDocumentCommand \foo { >{\SplitList{,}}m m }
{ \ProcessList{#1}{\fooAux{#2}} }
\foo{a,,{b,c},\empty}{ARG}
}
\END
10 changes: 10 additions & 0 deletions base/testfiles-ltcmd/ltcmd004.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -609,3 +609,13 @@ TEST 31: Processor depending on other argument
|{a}{bcd;e}|1|
|{a,bcd}{e}|1|
============================================================
============================================================
TEST 32: ProcessList
============================================================
a
b,c
|a|ARG|
||ARG|
|b,c|ARG|
|\empty |ARG|
============================================================

0 comments on commit d205f0e

Please sign in to comment.