summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Master/texmf-dist/doc/generic/collargs/CHANGELOG.md10
-rw-r--r--Master/texmf-dist/doc/generic/collargs/README.md8
-rw-r--r--Master/texmf-dist/source/generic/collargs/collargs.edtx211
-rw-r--r--Master/texmf-dist/tex/context/third/collargs/t-collargs.tex133
-rw-r--r--Master/texmf-dist/tex/latex/collargs/collargs.sty131
-rw-r--r--Master/texmf-dist/tex/plain/collargs/collargs.tex129
6 files changed, 305 insertions, 317 deletions
diff --git a/Master/texmf-dist/doc/generic/collargs/CHANGELOG.md b/Master/texmf-dist/doc/generic/collargs/CHANGELOG.md
index e3e1204b2d6..d79205db9a4 100644
--- a/Master/texmf-dist/doc/generic/collargs/CHANGELOG.md
+++ b/Master/texmf-dist/doc/generic/collargs/CHANGELOG.md
@@ -14,6 +14,16 @@ those cases, please see [Memoize's GitHub
repository](https://github.com/sasozivanovic/memoize) for the recent
development history.
+## 2024/03/15 v1.2.0
+* Argument processors:
+ * They now work without a formal argument, taking token register
+ `\collargsArg` as input. The processors taking a formal argument were
+ impossible (or at least too hard for me) to define.
+ * Remove `append/prepend pre/postwrap`, as they become useless with the above
+ change.
+* Implement keys `clear args` and `return`, and expose `\collargsArgs`.
+* Implement key `alias`.
+
## 2024/01/02 v1.1.0
* Implement `brace collected`.
diff --git a/Master/texmf-dist/doc/generic/collargs/README.md b/Master/texmf-dist/doc/generic/collargs/README.md
index 235225f08a9..35ec0dd7be2 100644
--- a/Master/texmf-dist/doc/generic/collargs/README.md
+++ b/Master/texmf-dist/doc/generic/collargs/README.md
@@ -1,6 +1,6 @@
Package CollArgs provides a command which can determine the argument scope of
-any command whose argument structure conforms to
-[xparse](https://ctan.org/pkg/xparse)'s argument specification.
+any command whose argument structure conforms to
+[LaTeX3 argument specification](https://www.latex-project.org/help/documentation/usrguide.pdf).
This package was developed as an auxiliary package of
[Memoize](https://ctan.org/pkg/memoize). This is why it is, somewhat
@@ -15,5 +15,5 @@ any later version. The latest version of this license is in
https://www.latex-project.org/lppl.txt and version 1.3c or later is part of all
distributions of LaTeX version 2008 or later.
-This work has the LPPL maintenance status `maintained'. The Current Maintainer
-of this work is Sašo Živanović (saso.zivanovic@guest.arnes.si).
+This work has the LPPL maintenance status `maintained`. The Current Maintainer
+of this work is Sašo Živanović (`saso.zivanovic@guest.arnes.si`).
diff --git a/Master/texmf-dist/source/generic/collargs/collargs.edtx b/Master/texmf-dist/source/generic/collargs/collargs.edtx
index 6cd39ad4cac..3df03eabfb8 100644
--- a/Master/texmf-dist/source/generic/collargs/collargs.edtx
+++ b/Master/texmf-dist/source/generic/collargs/collargs.edtx
@@ -46,14 +46,14 @@
%
%
% \paragraph{Identification}
-%<latex>\ProvidesPackage{collargs}[2024/01/02 v1.1.0 Collect arguments of any command]
+%<latex>\ProvidesPackage{collargs}[2024/03/15 v1.2.0 Collect arguments of any command]
%<context>%D \module[
%<context>%D file=t-collargs.tex,
-%<context>%D version=1.1.0,
+%<context>%D version=1.2.0,
%<context>%D title=CollArgs,
%<context>%D subtitle=Collect arguments of any command,
%<context>%D author=Saso Zivanovic,
-%<context>%D date=2024-01-02,
+%<context>%D date=2024-03-15,
%<context>%D copyright=Saso Zivanovic,
%<context>%D license=LPPL,
%<context>%D ]
@@ -105,15 +105,14 @@
% \end{macro}
%
% \begin{macro}{\CollectArguments,\CollectArgumentsRaw}
-% These are the only public commands provided by the
-% package. |\CollectArguments| takes three arguments: the optional |#1| is
-% the option list, processed by |pgfkeys| (given the grouping structure,
-% these options will apply to all arguments); the mandatory |#2| is the
-% |xparse|-style argument specification; the mandatory |#3| is the ``next''
-% command (or a sequence of commands). The argument list is expected to
-% start immediately after the final argument; |\CollectArguments| parses it,
-% effectively figuring out its extent, and then passes the entire argument
-% list to the ``next'' command (as a single argument).
+% |\CollectArguments| takes three arguments: the optional |#1| is the option
+% list, processed by |pgfkeys| (given the grouping structure, these options
+% will apply to all arguments); the mandatory |#2| is the |xparse|-style
+% argument specification; the mandatory |#3| is the ``next'' command (or a
+% sequence of commands). The argument list is expected to start immediately
+% after the final argument; |\CollectArguments| parses it, effectively
+% figuring out its extent, and then passes the entire argument list to the
+% ``next'' command (as a single argument).
%
% |\CollectArgumentsRaw| differs only in how it takes and processes the
% options. For one, these should be given as a mandatory argument.
@@ -145,7 +144,9 @@
% Remember the code to execute after collection.
\def\collargs@next{#3}%
% Initialize the token register holding the collected arguments.
- \global\collargs@toks{}%
+ \ifcollargsClearArgs
+ \global\collargsArgs{}%
+ \fi
% Execute the central loop macro, which expects the argument specification
% |#2| to be delimited from the following argument tokens by a dot.
\collargs@#2.%
@@ -162,7 +163,6 @@
\def\collargsSet#1{\pgfqkeys{/collargs}{#1}}
% \end{macro}
%
-%
% \subsubsection{The keys}
% \label{sec:code:collargs:keys}
%
@@ -409,24 +409,10 @@
append postprocessor/.code={\collargsAppendPostprocessor{#1}},
prepend postprocessor/.code={\collargsPrependPostprocessor{#1}},
}
-\def\collargsAppendPreprocessor{%
- \collargs@addprocessor\appto\collargs@preprocess@arg}
-\def\collargsPrependPreprocessor{%
- \collargs@addprocessor\preto\collargs@preprocess@arg}
-\def\collargsAppendPostprocessor{%
- \collargs@addprocessor\appto\collargs@postprocess@arg}
-\def\collargsPrependPostprocessor{%
- \collargs@addprocessor\preto\collargs@postprocess@arg}
-% Here, |#1| will be either |\appto| or |\preto|, and |#2| will be either
-% |\collargs@preprocess@arg| or |\collargs@postprocess@arg|. |#3| is the
-% processor code.
-\def\collargs@addprocessor#1#2#3{%
- #1#2{%
- \expanded{%
- \unexpanded{#3}{\the\collargsArg}%
- }%
- }%
-}
+\def\collargsAppendPreprocessor#1{\appto\collargs@preprocess@arg{#1}}
+\def\collargsPrependPreprocessor#1{\preto\collargs@preprocess@arg{#1}}
+\def\collargsAppendPostprocessor#1{\appto\collargs@postprocess@arg{#1}}
+\def\collargsPrependPostprocessor#1{\preto\collargs@postprocess@arg{#1}}
% \end{macro}
% \end{collargskey}
% \end{macro}
@@ -451,71 +437,38 @@
% \end{collargskey}
% \end{macro}
% \end{collargskey}
-%
+%
% \begin{collargskey}[noindex]{(append/prepend) expandable (pre/post)processor}
% \begin{macro}[noindex]{\collargs(Append/Prepend)Expandable(Pre/Post)processor}
% \begin{collargskey}[noprint]{append expandable preprocessor, prepend expandable preprocessor, append expandable postprocessor, prepend expandable postprocessor}
% \begin{macro}[noprint]{\collargsAppendExpandablePreprocessor,\collargsPrependExpandablePreprocessor,\collargsAppendExpandablePostprocessor,\collargsPrependExpandablePostprocessor}
-% These keys
-% and macros simplify the definition of fully expandable processors. Note
-% that expandable processors are added to the same list as non-expandable
-% processors.
+% These keys and macros simplify the definition of expandable
+% processors. Note that expandable processors are added to the same
+% list as non-expandable processors.
\collargsSet{
- append expandable preprocessor/.code={%
- \collargsAppendExpandablePreprocessor{#1}},
- prepend expandable preprocessor/.code={%
- \collargsPrependExpandablePreprocessor{#1}},
- append expandable postprocessor/.code={%
- \collargsAppendExpandablePostprocessor{#1}},
- prepend expandable postprocessor/.code={%
- \collargsPrependExpandablePostprocessor{#1}},
-}
-\def\collargsAppendExpandablePreprocessor{%
- \collargs@addeprocessor\appto\collargs@preprocess@arg}
-\def\collargsPrependExpandablePreprocessor{%
- \collargs@addeprocessor\preto\collargs@preprocess@arg}
-\def\collargsAppendExpandablePostprocessor{%
- \collargs@addeprocessor\appto\collargs@postprocess@arg}
-\def\collargsPrependExpandablePostprocessor{%
- \collargs@addeprocessor\preto\collargs@postprocess@arg}
-\def\collargs@addeprocessor#1#2#3{%
- #1#2{%
- \expanded{%
- \edef\noexpand\collargs@temp{\unexpanded{#3}{\the\collargsArg}}%
- \unexpanded{\expandafter\collargsArg\expandafter{\collargs@temp}}%
- }%
+ append expandable preprocessor/.code={\collargsAppendExpandablePreprocessor{#1}},
+ prepend expandable preprocessor/.code={\collargsPrependExpandablePreprocessor{#1}},
+ append expandable postprocessor/.code={\collargsAppendExpandablePostprocessor{#1}},
+ prepend expandable postprocessor/.code={\collargsPrependExpandablePostprocessor{#1}},
+}
+\def\collargsAppendExpandablePreprocessor#1{%
+ \appto\collargs@preprocess@arg{%
+ \collargsArg\expandafter{\expanded{#1}}%
}%
}
-% \end{macro}
-% \end{collargskey}
-% \end{macro}
-% \end{collargskey}
-%
-% \begin{collargskey}[noindex]{(append/prepend) (pre/post)wrap}
-% \begin{macro}[noindex]{\collargs(Append/Prepend)(Pre/Post)wrap}
-% \begin{collargskey}[noprint]{append prewrap, prepend prewrap, append postwrap, prepend postwrap}
-% \begin{macro}[noprint]{\collargsAppendPrewrap,\collargsPrependPrewrap,\collargsAppendPostwrap,\collargsPrependPostwrap}
-% These keys and macros
-% simplify the definition of processors which yield the result after a
-% single expansion. Again, they are added to the same list as other
-% processors.
-\collargsSet{
- append prewrap/.code={\collargsAppendPrewrap{#1}},
- prepend prewrap/.code={\collargsPrependPrewrap{#1}},
- append postwrap/.code={\collargsAppendPostwrap{#1}},
- prepend postwrap/.code={\collargsPrependPostwrap{#1}},
-}
-\def\collargsAppendPrewrap{\collargs@addwrap\appto\collargs@preprocess@arg}
-\def\collargsPrependPrewrap{\collargs@addwrap\preto\collargs@preprocess@arg}
-\def\collargsAppendPostwrap{\collargs@addwrap\appto\collargs@postprocess@arg}
-\def\collargsPrependPostwrap{\collargs@addwrap\preto\collargs@postprocess@arg}
-\def\collargs@addwrap#1#2#3{%
- #1#2{%
- \long\def\collargs@temp##1{#3}%
- \expandafter\expandafter\expandafter\collargsArg
- \expandafter\expandafter\expandafter{%
- \expandafter\collargs@temp\expandafter{\the\collargsArg}%
- }%
+\def\collargsPrependExpandablePreprocessor#1{%
+ \preto\collargs@preprocess@arg{%
+ \collargsArg\expandafter{\expanded{#1}}%
+ }%
+}
+\def\collargsAppendExpandablePostprocessor#1{%
+ \appto\collargs@postprocess@arg{%
+ \collargsArg\expandafter{\expanded{#1}}%
+ }%
+}
+\def\collargsPrependExpandablePostprocessor#1{%
+ \preto\collargs@postprocess@arg{%
+ \collargsArg\expandafter{\expanded{#1}}%
}%
}
% \end{macro}
@@ -535,19 +488,51 @@
\newif\ifcollargsNoDelimiters
% \end{macro}
% \end{collargskey}
-
-% \begin{collargskey}{brace collected}
-% \begin{macro}{\ifcollargsBraceCollected}
-% When this conditional is set to false, the collected arguments are not
-% enclosed in braces when passed on to \meta{next-code}.
+%
+% \begin{collargskey}{clear args}
+% \begin{macro}{\ifcollargsClearArgs}
+% When this conditional is set to |false|, the global token register
+% |\collargsArgs| receiving the collected arguments is not cleared prior
+% to argument collection.
+\collargsSet{%
+ clear args/.is if=collargsClearArgs,
+}
+\newif\ifcollargsClearArgs
+\collargsClearArgstrue
+% \end{macro}
+% \end{collargskey}
+%
+% \begin{collargskey}{return}
+% \begin{macro}{\collargsReturn}
+% Exiting |\CollectArguments|, should the next-command be followed by the
+% braced collected arguments, collected arguments as they are, or nothing?
+\collargsSet{%
+ return/.is choice,
+ return/braced/.code=\collargsReturnBraced,
+ return/plain/.code=\collargsReturnPlain,
+ return/no/.code=\collargsReturnNo,
+}
+\def\collargsReturnBraced{\def\collargsReturn{0}}
+\def\collargsReturnPlain{\def\collargsReturn{1}}
+\def\collargsReturnNo{\def\collargsReturn{2}}
+\collargsReturnBraced
+% \end{macro}
+% \end{collargskey}
+%
+% \begin{collargskey}{alias}
+% \begin{macro}{\collargsAlias}
+%
\collargsSet{%
- brace collected/.is if=collargsBraceCollected,
+ alias/.code 2 args=\collargsAlias{#1}{#2}%
+}
+\def\collargsAlias#1#2{%
+ \csdef{collargs@#1}{\collargs@@@#2}%
}
-\newif\ifcollargsBraceCollected
-\collargsBraceCollectedtrue
% \end{macro}
% \end{collargskey}
%
+%
+%
% \subsubsection{The central loop}
% \label{sec:code:collargs:central-loop}
%
@@ -677,11 +662,11 @@
}
% \end{macro}
%
-% \begin{macro}{\collargs@toks}
+% \begin{macro}{\collargsArgs}
% This token register is where we store the collected argument tokens. All
% assignments to this register are global, because it needs to survive the
% groups opened for individual arguments.
-\newtoks\collargs@toks
+\newtoks\collargsArgs
% \end{macro}
%
% \begin{macro}{\collargsArg}
@@ -705,10 +690,10 @@
\endgroup
\noexpand\collargs@fix{%
\expandonce\collargs@next
- \ifcollargsBraceCollected
- {\the\collargs@toks}%
- \else
- \the\collargs@toks
+ \ifcase\collargsReturn\space
+ {\the\collargsArgs}%
+ \or
+ \the\collargsArgs
\fi
\collargs@spaces
}%
@@ -722,7 +707,7 @@
% \begin{macro}{\collargs@appendarg}
% This macro is used by the argument type
% handlers to append the collected argument to the storage
-% (|\collargs@toks|).
+% (|\collargsArgs|).
\long\def\collargs@appendarg#1{%
% Temporarily store the collected argument into a token register. The
% processors will manipulate the contents of this register.
@@ -744,7 +729,7 @@
\collargs@postprocess@arg
% Append the processed argument, preceded by any grabbed spaces (in the
% correct mode), to the storage.
- \xtoksapp\collargs@toks{\collargs@grabbed@spaces\the\collargsArg}%
+ \xtoksapp\collargsArgs{\collargs@grabbed@spaces\the\collargsArg}%
% Initialize the space-grabber.
\collargs@init@grabspaces
% Once the argument was appended to the list, we can close its group, opened
@@ -761,7 +746,15 @@
% defined by the argument type handler. Note that this macro \emph{appends}
% a wrapper, so multiple wrappers are allowed --- this is used by type |e|
% handler.
-\def\collargs@wrap{\collargs@addwrap\appto\collargs@process@arg}
+\def\collargs@wrap#1{%
+ \appto\collargs@process@arg{%
+ \long\def\collargs@temp##1{#1}%
+ \expandafter\expandafter\expandafter\collargsArg
+ \expandafter\expandafter\expandafter{%
+ \expandafter\collargs@temp\expandafter{\the\collargsArg}%
+ }%
+ }%
+}
\def\collargs@process@arg{}
% \end{macro}
%
@@ -1046,7 +1039,7 @@
% which will put everything up to the first opening brace into the first
% argument, looks funky, but that's all.
\collargs@defusecollector##1##{%
- % We append the collected argument, |##1|, to |\collargs@toks|, the token
+ % We append the collected argument, |##1|, to |\collargsArgs|, the token
% register holding the collected argument tokens.
\collargs@appendarg{##1}%
% Back to the central loop, with the rest of the argument specification
@@ -1448,7 +1441,7 @@
\collargs@readContent
}
% This macro appends the result given by the heavy machinery, waiting for us in
-% macro |\collargsArg|, to |\collargs@toks|, but not before dressing
+% macro |\collargsArg|, to |\collargsArgs|, but not before dressing
% it up (via |\collargs@wrap|) in a pair of verbatim braces.
\def\collargs@m@verb@group@i{%
\edef\collargs@temp{%
diff --git a/Master/texmf-dist/tex/context/third/collargs/t-collargs.tex b/Master/texmf-dist/tex/context/third/collargs/t-collargs.tex
index 157882a2eaa..2c1d292c584 100644
--- a/Master/texmf-dist/tex/context/third/collargs/t-collargs.tex
+++ b/Master/texmf-dist/tex/context/third/collargs/t-collargs.tex
@@ -28,11 +28,11 @@
%% (<texmf>/doc/generic/collargs/)FILES.
%D \module[
%D file=t-collargs.tex,
-%D version=1.1.0,
+%D version=1.2.0,
%D title=CollArgs,
%D subtitle=Collect arguments of any command,
%D author=Saso Zivanovic,
-%D date=2024-01-02,
+%D date=2024-03-15,
%D copyright=Saso Zivanovic,
%D license=LPPL,
%D ]
@@ -72,7 +72,9 @@
\collargs@verbatim@wrap{#1}%
\collargs@init@grabspaces
\def\collargs@next{#3}%
- \global\collargs@toks{}%
+ \ifcollargsClearArgs
+ \global\collargsArgs{}%
+ \fi
\collargs@#2.%
}
\def\collargsSet#1{\pgfqkeys{/collargs}{#1}}
@@ -187,21 +189,10 @@
append postprocessor/.code={\collargsAppendPostprocessor{#1}},
prepend postprocessor/.code={\collargsPrependPostprocessor{#1}},
}
-\def\collargsAppendPreprocessor{%
- \collargs@addprocessor\appto\collargs@preprocess@arg}
-\def\collargsPrependPreprocessor{%
- \collargs@addprocessor\preto\collargs@preprocess@arg}
-\def\collargsAppendPostprocessor{%
- \collargs@addprocessor\appto\collargs@postprocess@arg}
-\def\collargsPrependPostprocessor{%
- \collargs@addprocessor\preto\collargs@postprocess@arg}
-\def\collargs@addprocessor#1#2#3{%
- #1#2{%
- \normalexpanded{%
- \normalunexpanded{#3}{\the\collargsArg}%
- }%
- }%
-}
+\def\collargsAppendPreprocessor#1{\appto\collargs@preprocess@arg{#1}}
+\def\collargsPrependPreprocessor#1{\preto\collargs@preprocess@arg{#1}}
+\def\collargsAppendPostprocessor#1{\appto\collargs@postprocess@arg{#1}}
+\def\collargsPrependPostprocessor#1{\preto\collargs@postprocess@arg{#1}}
\def\collargs@preprocess@arg{}
\def\collargs@postprocess@arg{}
\collargsSet{
@@ -211,60 +202,56 @@
\def\collargsClearPreprocessors{\def\collargs@preprocess@arg{}}%
\def\collargsClearPostprocessors{\def\collargs@postprocess@arg{}}%
\collargsSet{
- append expandable preprocessor/.code={%
- \collargsAppendExpandablePreprocessor{#1}},
- prepend expandable preprocessor/.code={%
- \collargsPrependExpandablePreprocessor{#1}},
- append expandable postprocessor/.code={%
- \collargsAppendExpandablePostprocessor{#1}},
- prepend expandable postprocessor/.code={%
- \collargsPrependExpandablePostprocessor{#1}},
-}
-\def\collargsAppendExpandablePreprocessor{%
- \collargs@addeprocessor\appto\collargs@preprocess@arg}
-\def\collargsPrependExpandablePreprocessor{%
- \collargs@addeprocessor\preto\collargs@preprocess@arg}
-\def\collargsAppendExpandablePostprocessor{%
- \collargs@addeprocessor\appto\collargs@postprocess@arg}
-\def\collargsPrependExpandablePostprocessor{%
- \collargs@addeprocessor\preto\collargs@postprocess@arg}
-\def\collargs@addeprocessor#1#2#3{%
- #1#2{%
- \normalexpanded{%
- \edef\noexpand\collargs@temp{\normalunexpanded{#3}{\the\collargsArg}}%
- \normalunexpanded{\expandafter\collargsArg\expandafter{\collargs@temp}}%
- }%
+ append expandable preprocessor/.code={\collargsAppendExpandablePreprocessor{#1}},
+ prepend expandable preprocessor/.code={\collargsPrependExpandablePreprocessor{#1}},
+ append expandable postprocessor/.code={\collargsAppendExpandablePostprocessor{#1}},
+ prepend expandable postprocessor/.code={\collargsPrependExpandablePostprocessor{#1}},
+}
+\def\collargsAppendExpandablePreprocessor#1{%
+ \appto\collargs@preprocess@arg{%
+ \collargsArg\expandafter{\normalexpanded{#1}}%
}%
}
-\collargsSet{
- append prewrap/.code={\collargsAppendPrewrap{#1}},
- prepend prewrap/.code={\collargsPrependPrewrap{#1}},
- append postwrap/.code={\collargsAppendPostwrap{#1}},
- prepend postwrap/.code={\collargsPrependPostwrap{#1}},
-}
-\def\collargsAppendPrewrap{\collargs@addwrap\appto\collargs@preprocess@arg}
-\def\collargsPrependPrewrap{\collargs@addwrap\preto\collargs@preprocess@arg}
-\def\collargsAppendPostwrap{\collargs@addwrap\appto\collargs@postprocess@arg}
-\def\collargsPrependPostwrap{\collargs@addwrap\preto\collargs@postprocess@arg}
-\def\collargs@addwrap#1#2#3{%
- #1#2{%
- \long\def\collargs@temp##1{#3}%
- \expandafter\expandafter\expandafter\collargsArg
- \expandafter\expandafter\expandafter{%
- \expandafter\collargs@temp\expandafter{\the\collargsArg}%
- }%
+\def\collargsPrependExpandablePreprocessor#1{%
+ \preto\collargs@preprocess@arg{%
+ \collargsArg\expandafter{\normalexpanded{#1}}%
+ }%
+}
+\def\collargsAppendExpandablePostprocessor#1{%
+ \appto\collargs@postprocess@arg{%
+ \collargsArg\expandafter{\normalexpanded{#1}}%
+ }%
+}
+\def\collargsPrependExpandablePostprocessor#1{%
+ \preto\collargs@postprocess@arg{%
+ \collargsArg\expandafter{\normalexpanded{#1}}%
}%
}
\collargsSet{%
no delimiters/.is if=collargsNoDelimiters,
}
\newif\ifcollargsNoDelimiters
-
\collargsSet{%
- brace collected/.is if=collargsBraceCollected,
+ clear args/.is if=collargsClearArgs,
+}
+\newif\ifcollargsClearArgs
+\collargsClearArgstrue
+\collargsSet{%
+ return/.is choice,
+ return/braced/.code=\collargsReturnBraced,
+ return/plain/.code=\collargsReturnPlain,
+ return/no/.code=\collargsReturnNo,
+}
+\def\collargsReturnBraced{\def\collargsReturn{0}}
+\def\collargsReturnPlain{\def\collargsReturn{1}}
+\def\collargsReturnNo{\def\collargsReturn{2}}
+\collargsReturnBraced
+\collargsSet{%
+ alias/.code 2 args=\collargsAlias{#1}{#2}%
+}
+\def\collargsAlias#1#2{%
+ \csdef{collargs@#1}{\collargs@@@#2}%
}
-\newif\ifcollargsBraceCollected
-\collargsBraceCollectedtrue
\def\collargs@{%
\begingroup
\collargs@@@
@@ -327,7 +314,7 @@
\collargs@grabspacesfalse
\collargs@@@
}
-\newtoks\collargs@toks
+\newtoks\collargsArgs
\newtoks\collargsArg
\csdef{collargs@.}{%
\endgroup
@@ -335,10 +322,10 @@
\endgroup
\noexpand\collargs@fix{%
\expandonce\collargs@next
- \ifcollargsBraceCollected
- {\the\collargs@toks}%
- \else
- \the\collargs@toks
+ \ifcase\collargsReturn\space
+ {\the\collargsArgs}%
+ \or
+ \the\collargsArgs
\fi
\collargs@spaces
}%
@@ -355,11 +342,19 @@
\collargs@process@arg
\fi
\collargs@postprocess@arg
- \xtoksapp\collargs@toks{\collargs@grabbed@spaces\the\collargsArg}%
+ \xtoksapp\collargsArgs{\collargs@grabbed@spaces\the\collargsArg}%
\collargs@init@grabspaces
\endgroup
}
-\def\collargs@wrap{\collargs@addwrap\appto\collargs@process@arg}
+\def\collargs@wrap#1{%
+ \appto\collargs@process@arg{%
+ \long\def\collargs@temp##1{#1}%
+ \expandafter\expandafter\expandafter\collargsArg
+ \expandafter\expandafter\expandafter{%
+ \expandafter\collargs@temp\expandafter{\the\collargsArg}%
+ }%
+ }%
+}
\def\collargs@process@arg{}
\def\collargs@defcollector#1#{%
\ifcollargs@long\long\fi
diff --git a/Master/texmf-dist/tex/latex/collargs/collargs.sty b/Master/texmf-dist/tex/latex/collargs/collargs.sty
index 2db86e8540b..9b51ad697cd 100644
--- a/Master/texmf-dist/tex/latex/collargs/collargs.sty
+++ b/Master/texmf-dist/tex/latex/collargs/collargs.sty
@@ -26,7 +26,7 @@
%%
%% The files belonging to this work and covered by LPPL are listed in
%% (<texmf>/doc/generic/collargs/)FILES.
-\ProvidesPackage{collargs}[2024/01/02 v1.1.0 Collect arguments of any command]
+\ProvidesPackage{collargs}[2024/03/15 v1.2.0 Collect arguments of any command]
\RequirePackage{pgfkeys}
\RequirePackage{etoolbox}
\ifdefined\luatexversion
@@ -60,7 +60,9 @@
\collargs@verbatim@wrap{#1}%
\collargs@init@grabspaces
\def\collargs@next{#3}%
- \global\collargs@toks{}%
+ \ifcollargsClearArgs
+ \global\collargsArgs{}%
+ \fi
\collargs@#2.%
}
\def\collargsSet#1{\pgfqkeys{/collargs}{#1}}
@@ -176,21 +178,10 @@
append postprocessor/.code={\collargsAppendPostprocessor{#1}},
prepend postprocessor/.code={\collargsPrependPostprocessor{#1}},
}
-\def\collargsAppendPreprocessor{%
- \collargs@addprocessor\appto\collargs@preprocess@arg}
-\def\collargsPrependPreprocessor{%
- \collargs@addprocessor\preto\collargs@preprocess@arg}
-\def\collargsAppendPostprocessor{%
- \collargs@addprocessor\appto\collargs@postprocess@arg}
-\def\collargsPrependPostprocessor{%
- \collargs@addprocessor\preto\collargs@postprocess@arg}
-\def\collargs@addprocessor#1#2#3{%
- #1#2{%
- \expanded{%
- \unexpanded{#3}{\the\collargsArg}%
- }%
- }%
-}
+\def\collargsAppendPreprocessor#1{\appto\collargs@preprocess@arg{#1}}
+\def\collargsPrependPreprocessor#1{\preto\collargs@preprocess@arg{#1}}
+\def\collargsAppendPostprocessor#1{\appto\collargs@postprocess@arg{#1}}
+\def\collargsPrependPostprocessor#1{\preto\collargs@postprocess@arg{#1}}
\def\collargs@preprocess@arg{}
\def\collargs@postprocess@arg{}
\collargsSet{
@@ -200,60 +191,56 @@
\def\collargsClearPreprocessors{\def\collargs@preprocess@arg{}}%
\def\collargsClearPostprocessors{\def\collargs@postprocess@arg{}}%
\collargsSet{
- append expandable preprocessor/.code={%
- \collargsAppendExpandablePreprocessor{#1}},
- prepend expandable preprocessor/.code={%
- \collargsPrependExpandablePreprocessor{#1}},
- append expandable postprocessor/.code={%
- \collargsAppendExpandablePostprocessor{#1}},
- prepend expandable postprocessor/.code={%
- \collargsPrependExpandablePostprocessor{#1}},
-}
-\def\collargsAppendExpandablePreprocessor{%
- \collargs@addeprocessor\appto\collargs@preprocess@arg}
-\def\collargsPrependExpandablePreprocessor{%
- \collargs@addeprocessor\preto\collargs@preprocess@arg}
-\def\collargsAppendExpandablePostprocessor{%
- \collargs@addeprocessor\appto\collargs@postprocess@arg}
-\def\collargsPrependExpandablePostprocessor{%
- \collargs@addeprocessor\preto\collargs@postprocess@arg}
-\def\collargs@addeprocessor#1#2#3{%
- #1#2{%
- \expanded{%
- \edef\noexpand\collargs@temp{\unexpanded{#3}{\the\collargsArg}}%
- \unexpanded{\expandafter\collargsArg\expandafter{\collargs@temp}}%
- }%
+ append expandable preprocessor/.code={\collargsAppendExpandablePreprocessor{#1}},
+ prepend expandable preprocessor/.code={\collargsPrependExpandablePreprocessor{#1}},
+ append expandable postprocessor/.code={\collargsAppendExpandablePostprocessor{#1}},
+ prepend expandable postprocessor/.code={\collargsPrependExpandablePostprocessor{#1}},
+}
+\def\collargsAppendExpandablePreprocessor#1{%
+ \appto\collargs@preprocess@arg{%
+ \collargsArg\expandafter{\expanded{#1}}%
}%
}
-\collargsSet{
- append prewrap/.code={\collargsAppendPrewrap{#1}},
- prepend prewrap/.code={\collargsPrependPrewrap{#1}},
- append postwrap/.code={\collargsAppendPostwrap{#1}},
- prepend postwrap/.code={\collargsPrependPostwrap{#1}},
-}
-\def\collargsAppendPrewrap{\collargs@addwrap\appto\collargs@preprocess@arg}
-\def\collargsPrependPrewrap{\collargs@addwrap\preto\collargs@preprocess@arg}
-\def\collargsAppendPostwrap{\collargs@addwrap\appto\collargs@postprocess@arg}
-\def\collargsPrependPostwrap{\collargs@addwrap\preto\collargs@postprocess@arg}
-\def\collargs@addwrap#1#2#3{%
- #1#2{%
- \long\def\collargs@temp##1{#3}%
- \expandafter\expandafter\expandafter\collargsArg
- \expandafter\expandafter\expandafter{%
- \expandafter\collargs@temp\expandafter{\the\collargsArg}%
- }%
+\def\collargsPrependExpandablePreprocessor#1{%
+ \preto\collargs@preprocess@arg{%
+ \collargsArg\expandafter{\expanded{#1}}%
+ }%
+}
+\def\collargsAppendExpandablePostprocessor#1{%
+ \appto\collargs@postprocess@arg{%
+ \collargsArg\expandafter{\expanded{#1}}%
+ }%
+}
+\def\collargsPrependExpandablePostprocessor#1{%
+ \preto\collargs@postprocess@arg{%
+ \collargsArg\expandafter{\expanded{#1}}%
}%
}
\collargsSet{%
no delimiters/.is if=collargsNoDelimiters,
}
\newif\ifcollargsNoDelimiters
-
\collargsSet{%
- brace collected/.is if=collargsBraceCollected,
+ clear args/.is if=collargsClearArgs,
+}
+\newif\ifcollargsClearArgs
+\collargsClearArgstrue
+\collargsSet{%
+ return/.is choice,
+ return/braced/.code=\collargsReturnBraced,
+ return/plain/.code=\collargsReturnPlain,
+ return/no/.code=\collargsReturnNo,
+}
+\def\collargsReturnBraced{\def\collargsReturn{0}}
+\def\collargsReturnPlain{\def\collargsReturn{1}}
+\def\collargsReturnNo{\def\collargsReturn{2}}
+\collargsReturnBraced
+\collargsSet{%
+ alias/.code 2 args=\collargsAlias{#1}{#2}%
+}
+\def\collargsAlias#1#2{%
+ \csdef{collargs@#1}{\collargs@@@#2}%
}
-\newif\ifcollargsBraceCollected
-\collargsBraceCollectedtrue
\def\collargs@{%
\begingroup
\collargs@@@
@@ -316,7 +303,7 @@
\collargs@grabspacesfalse
\collargs@@@
}
-\newtoks\collargs@toks
+\newtoks\collargsArgs
\newtoks\collargsArg
\csdef{collargs@.}{%
\endgroup
@@ -324,10 +311,10 @@
\endgroup
\noexpand\collargs@fix{%
\expandonce\collargs@next
- \ifcollargsBraceCollected
- {\the\collargs@toks}%
- \else
- \the\collargs@toks
+ \ifcase\collargsReturn\space
+ {\the\collargsArgs}%
+ \or
+ \the\collargsArgs
\fi
\collargs@spaces
}%
@@ -344,11 +331,19 @@
\collargs@process@arg
\fi
\collargs@postprocess@arg
- \xtoksapp\collargs@toks{\collargs@grabbed@spaces\the\collargsArg}%
+ \xtoksapp\collargsArgs{\collargs@grabbed@spaces\the\collargsArg}%
\collargs@init@grabspaces
\endgroup
}
-\def\collargs@wrap{\collargs@addwrap\appto\collargs@process@arg}
+\def\collargs@wrap#1{%
+ \appto\collargs@process@arg{%
+ \long\def\collargs@temp##1{#1}%
+ \expandafter\expandafter\expandafter\collargsArg
+ \expandafter\expandafter\expandafter{%
+ \expandafter\collargs@temp\expandafter{\the\collargsArg}%
+ }%
+ }%
+}
\def\collargs@process@arg{}
\def\collargs@defcollector#1#{%
\ifcollargs@long\long\fi
diff --git a/Master/texmf-dist/tex/plain/collargs/collargs.tex b/Master/texmf-dist/tex/plain/collargs/collargs.tex
index e67c3633b4b..f9773063f02 100644
--- a/Master/texmf-dist/tex/plain/collargs/collargs.tex
+++ b/Master/texmf-dist/tex/plain/collargs/collargs.tex
@@ -61,7 +61,9 @@
\collargs@verbatim@wrap{#1}%
\collargs@init@grabspaces
\def\collargs@next{#3}%
- \global\collargs@toks{}%
+ \ifcollargsClearArgs
+ \global\collargsArgs{}%
+ \fi
\collargs@#2.%
}
\def\collargsSet#1{\pgfqkeys{/collargs}{#1}}
@@ -175,21 +177,10 @@
append postprocessor/.code={\collargsAppendPostprocessor{#1}},
prepend postprocessor/.code={\collargsPrependPostprocessor{#1}},
}
-\def\collargsAppendPreprocessor{%
- \collargs@addprocessor\appto\collargs@preprocess@arg}
-\def\collargsPrependPreprocessor{%
- \collargs@addprocessor\preto\collargs@preprocess@arg}
-\def\collargsAppendPostprocessor{%
- \collargs@addprocessor\appto\collargs@postprocess@arg}
-\def\collargsPrependPostprocessor{%
- \collargs@addprocessor\preto\collargs@postprocess@arg}
-\def\collargs@addprocessor#1#2#3{%
- #1#2{%
- \expanded{%
- \unexpanded{#3}{\the\collargsArg}%
- }%
- }%
-}
+\def\collargsAppendPreprocessor#1{\appto\collargs@preprocess@arg{#1}}
+\def\collargsPrependPreprocessor#1{\preto\collargs@preprocess@arg{#1}}
+\def\collargsAppendPostprocessor#1{\appto\collargs@postprocess@arg{#1}}
+\def\collargsPrependPostprocessor#1{\preto\collargs@postprocess@arg{#1}}
\def\collargs@preprocess@arg{}
\def\collargs@postprocess@arg{}
\collargsSet{
@@ -199,60 +190,56 @@
\def\collargsClearPreprocessors{\def\collargs@preprocess@arg{}}%
\def\collargsClearPostprocessors{\def\collargs@postprocess@arg{}}%
\collargsSet{
- append expandable preprocessor/.code={%
- \collargsAppendExpandablePreprocessor{#1}},
- prepend expandable preprocessor/.code={%
- \collargsPrependExpandablePreprocessor{#1}},
- append expandable postprocessor/.code={%
- \collargsAppendExpandablePostprocessor{#1}},
- prepend expandable postprocessor/.code={%
- \collargsPrependExpandablePostprocessor{#1}},
-}
-\def\collargsAppendExpandablePreprocessor{%
- \collargs@addeprocessor\appto\collargs@preprocess@arg}
-\def\collargsPrependExpandablePreprocessor{%
- \collargs@addeprocessor\preto\collargs@preprocess@arg}
-\def\collargsAppendExpandablePostprocessor{%
- \collargs@addeprocessor\appto\collargs@postprocess@arg}
-\def\collargsPrependExpandablePostprocessor{%
- \collargs@addeprocessor\preto\collargs@postprocess@arg}
-\def\collargs@addeprocessor#1#2#3{%
- #1#2{%
- \expanded{%
- \edef\noexpand\collargs@temp{\unexpanded{#3}{\the\collargsArg}}%
- \unexpanded{\expandafter\collargsArg\expandafter{\collargs@temp}}%
- }%
+ append expandable preprocessor/.code={\collargsAppendExpandablePreprocessor{#1}},
+ prepend expandable preprocessor/.code={\collargsPrependExpandablePreprocessor{#1}},
+ append expandable postprocessor/.code={\collargsAppendExpandablePostprocessor{#1}},
+ prepend expandable postprocessor/.code={\collargsPrependExpandablePostprocessor{#1}},
+}
+\def\collargsAppendExpandablePreprocessor#1{%
+ \appto\collargs@preprocess@arg{%
+ \collargsArg\expandafter{\expanded{#1}}%
}%
}
-\collargsSet{
- append prewrap/.code={\collargsAppendPrewrap{#1}},
- prepend prewrap/.code={\collargsPrependPrewrap{#1}},
- append postwrap/.code={\collargsAppendPostwrap{#1}},
- prepend postwrap/.code={\collargsPrependPostwrap{#1}},
-}
-\def\collargsAppendPrewrap{\collargs@addwrap\appto\collargs@preprocess@arg}
-\def\collargsPrependPrewrap{\collargs@addwrap\preto\collargs@preprocess@arg}
-\def\collargsAppendPostwrap{\collargs@addwrap\appto\collargs@postprocess@arg}
-\def\collargsPrependPostwrap{\collargs@addwrap\preto\collargs@postprocess@arg}
-\def\collargs@addwrap#1#2#3{%
- #1#2{%
- \long\def\collargs@temp##1{#3}%
- \expandafter\expandafter\expandafter\collargsArg
- \expandafter\expandafter\expandafter{%
- \expandafter\collargs@temp\expandafter{\the\collargsArg}%
- }%
+\def\collargsPrependExpandablePreprocessor#1{%
+ \preto\collargs@preprocess@arg{%
+ \collargsArg\expandafter{\expanded{#1}}%
+ }%
+}
+\def\collargsAppendExpandablePostprocessor#1{%
+ \appto\collargs@postprocess@arg{%
+ \collargsArg\expandafter{\expanded{#1}}%
+ }%
+}
+\def\collargsPrependExpandablePostprocessor#1{%
+ \preto\collargs@postprocess@arg{%
+ \collargsArg\expandafter{\expanded{#1}}%
}%
}
\collargsSet{%
no delimiters/.is if=collargsNoDelimiters,
}
\newif\ifcollargsNoDelimiters
-
\collargsSet{%
- brace collected/.is if=collargsBraceCollected,
+ clear args/.is if=collargsClearArgs,
+}
+\newif\ifcollargsClearArgs
+\collargsClearArgstrue
+\collargsSet{%
+ return/.is choice,
+ return/braced/.code=\collargsReturnBraced,
+ return/plain/.code=\collargsReturnPlain,
+ return/no/.code=\collargsReturnNo,
+}
+\def\collargsReturnBraced{\def\collargsReturn{0}}
+\def\collargsReturnPlain{\def\collargsReturn{1}}
+\def\collargsReturnNo{\def\collargsReturn{2}}
+\collargsReturnBraced
+\collargsSet{%
+ alias/.code 2 args=\collargsAlias{#1}{#2}%
+}
+\def\collargsAlias#1#2{%
+ \csdef{collargs@#1}{\collargs@@@#2}%
}
-\newif\ifcollargsBraceCollected
-\collargsBraceCollectedtrue
\def\collargs@{%
\begingroup
\collargs@@@
@@ -315,7 +302,7 @@
\collargs@grabspacesfalse
\collargs@@@
}
-\newtoks\collargs@toks
+\newtoks\collargsArgs
\newtoks\collargsArg
\csdef{collargs@.}{%
\endgroup
@@ -323,10 +310,10 @@
\endgroup
\noexpand\collargs@fix{%
\expandonce\collargs@next
- \ifcollargsBraceCollected
- {\the\collargs@toks}%
- \else
- \the\collargs@toks
+ \ifcase\collargsReturn\space
+ {\the\collargsArgs}%
+ \or
+ \the\collargsArgs
\fi
\collargs@spaces
}%
@@ -343,11 +330,19 @@
\collargs@process@arg
\fi
\collargs@postprocess@arg
- \xtoksapp\collargs@toks{\collargs@grabbed@spaces\the\collargsArg}%
+ \xtoksapp\collargsArgs{\collargs@grabbed@spaces\the\collargsArg}%
\collargs@init@grabspaces
\endgroup
}
-\def\collargs@wrap{\collargs@addwrap\appto\collargs@process@arg}
+\def\collargs@wrap#1{%
+ \appto\collargs@process@arg{%
+ \long\def\collargs@temp##1{#1}%
+ \expandafter\expandafter\expandafter\collargsArg
+ \expandafter\expandafter\expandafter{%
+ \expandafter\collargs@temp\expandafter{\the\collargsArg}%
+ }%
+ }%
+}
\def\collargs@process@arg{}
\def\collargs@defcollector#1#{%
\ifcollargs@long\long\fi