summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/third
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2024-03-18 19:59:31 +0000
committerKarl Berry <karl@freefriends.org>2024-03-18 19:59:31 +0000
commit5e8d8cae840358328c7e78b0dbde730a00729679 (patch)
treec83813d0e581c90002dcdc31328158f7759e07f4 /Master/texmf-dist/tex/context/third
parentb834bf013732494b8dd4c8b2004c3eaf5f81b11f (diff)
collargs (18mar24)
git-svn-id: svn://tug.org/texlive/trunk@70689 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/third')
-rw-r--r--Master/texmf-dist/tex/context/third/collargs/t-collargs.tex133
1 files changed, 64 insertions, 69 deletions
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