diff options
author | Karl Berry <karl@freefriends.org> | 2020-07-04 20:48:00 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-07-04 20:48:00 +0000 |
commit | af82aa955d92ac23a716670104c7da69f69db008 (patch) | |
tree | 4f363411d5bf873d4c25b144a0570cfddb91ff90 /Master | |
parent | ef8b8c9fa5ed2344cfd1e9d744ee6db897f4b377 (diff) |
expkv-def (4jul20)
git-svn-id: svn://tug.org/texlive/trunk@55749 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/expkv-def/README.md | 2 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/expkv-def/expkv-def.pdf | bin | 303450 -> 305480 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/expkv-def/expkv-def.dtx | 83 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/expkv-def/expkv-def.tex | 35 |
4 files changed, 81 insertions, 39 deletions
diff --git a/Master/texmf-dist/doc/latex/expkv-def/README.md b/Master/texmf-dist/doc/latex/expkv-def/README.md index 554b5a6dcf9..444d887336e 100644 --- a/Master/texmf-dist/doc/latex/expkv-def/README.md +++ b/Master/texmf-dist/doc/latex/expkv-def/README.md @@ -1,7 +1,7 @@ ------------------------------------------------------------------------------- # expkv-def -- a key-defining frontend for expkv -Version 2020-04-29 v0.3 +Version 2020-07-04 v0.4 Released under the LaTeX Project Public License v1.3c or later See http://www.latex-project.org/lppl.txt diff --git a/Master/texmf-dist/doc/latex/expkv-def/expkv-def.pdf b/Master/texmf-dist/doc/latex/expkv-def/expkv-def.pdf Binary files differindex ec3bf9fac91..f051a5fe6a7 100644 --- a/Master/texmf-dist/doc/latex/expkv-def/expkv-def.pdf +++ b/Master/texmf-dist/doc/latex/expkv-def/expkv-def.pdf diff --git a/Master/texmf-dist/source/latex/expkv-def/expkv-def.dtx b/Master/texmf-dist/source/latex/expkv-def/expkv-def.dtx index 437c296d147..3dfff1f80f9 100644 --- a/Master/texmf-dist/source/latex/expkv-def/expkv-def.dtx +++ b/Master/texmf-dist/source/latex/expkv-def/expkv-def.dtx @@ -354,7 +354,9 @@ and the derived files expkv-def.pdf % commands which execute the |true| or |false| choice will be, so the usage % should be safe in an expansion context (\emph{e.g.}, you can use % \texttt{edefault \key\ = false} without an issue to change the default -% behaviour to execute the |false| choice). +% behaviour to execute the |false| choice). Internally a |bool| \key\ is the +% same as a |choice| key which is set up to handle |true| and |false| as +% choices. % \end{function} % % \begin{function}{store,estore,gstore,xstore} @@ -501,7 +503,20 @@ and the derived files expkv-def.pdf % \meta{definition} will be left in the input stream. You can make % individual values |protected| inside the \val=\meta{definition} list. By % default a |choice| key is expandable, an undefined \val\ will throw an error -% in an expandable way. +% in an expandable way (but see the |unknown-choice| prefix). You can add +% additional choices after the \key\ was created by using |choice| again for +% the same \key, redefining choices is possible the same way, but there is no +% interface to remove certain choices. +% \end{function} +% +% \begin{function}{unknown-choice} +% \begin{syntax} +% unknown-choice \key\ = \marg{definition} \prefixes23 +% \end{syntax} +% By default an unknown \val\ passed to a |choice| key will throw an error. +% However, with this prefix you can define an alternative action which should +% be executed if \key\ received an unknown choice. In \meta{definition} you +% can refer to the choice which was passed in with |#1|. % \end{function} % % \subsection{Bugs} @@ -669,8 +684,8 @@ and the derived files expkv-def.pdf % \begin{macro}{\ekvdVersion,\ekvdDate} % We're on our first input, so lets store the version and date in a macro. % \begin{macrocode} -\def\ekvdVersion{0.3} -\def\ekvdDate{2020-04-29} +\def\ekvdVersion{0.4} +\def\ekvdDate{2020-07-04} % \end{macrocode} % \end{macro} % @@ -1280,6 +1295,20 @@ and the derived files expkv-def.pdf % \end{macrocode} % \end{macro} % +% \begin{macro}[internal]{\ekvd@t@unknown-choice} +% \begin{macrocode} +\protected\long\expandafter\def\csname ekvd@t@unknown-choice\endcsname#1#2% + {% + \ekvd@assert@arg{unknown-choice #1}{#2}% + {% + \ekvd@assert@not@long{unknown-choice #1}% + \ekvd@prot\expandafter + \def\csname\ekvd@unknown@choice@name\ekvd@set{#1}\endcsname##1{#2}% + }% + } +% \end{macrocode} +% \end{macro} +% % \subsubsection{Key Type Helpers} % There are some keys that might need helpers during their execution (not during % their definition, which are gathered as |@type@| macros). These helpers are @@ -1309,23 +1338,6 @@ and the derived files expkv-def.pdf % % \subsubsection{Tests} % -% \begin{macro}[internal]{\ekvd@noarg@mark} -% This macro serves as a flag for the case that no \val\ was specified for a -% key. As such it is not a test, but exists only for some tests. -% \begin{macrocode} -\def\ekvd@noarg@mark{\ekvd@noarg@mark} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}[internal]{\ekvd@fi@firstoftwo} -% While we can reuse many of the internals of \expkv\ the specific case for this -% branch wasn't needed by \expkv\ and hence isn't defined. We'll need it, so we -% define it. -% \begin{macrocode} -\long\def\ekvd@fi@firstoftwo\fi\@secondoftwo#1#2{\fi#1} -% \end{macrocode} -% \end{macro} -% % \begin{macro}[internal]{\ekvd@newlet,\ekvd@newreg} % These macros test whether a control sequence is defined, if it isn't they % define it, either via |\let| or via the correct \cs[no-index]{new\meta{reg}}. @@ -1362,8 +1374,11 @@ and the derived files expkv-def.pdf % \end{macrocode} % \end{macro} % -% \begin{macro}[internal]{\ekvd@assert@arg,\ekvd@ifnoarg} -% The test for an argument is just an |\ifx| comparison with our |noarg@mark|. +% \begin{macro}[internal] +% {\ekvd@assert@arg,\ekvd@ifnoarg,\ekvd@ifnoarg@,\ekvd@ifnoarg@} +% An |\ifx| comparison would fail if the first token of the user input is a +% \TeX-if primitive or the user input contains unbalanced \TeX-if constructs, so +% the test is done using \TeX's argument grabbing logic. % \begin{macrocode} \long\def\ekvd@assert@arg#1#2% {% @@ -1372,10 +1387,14 @@ and the derived files expkv-def.pdf } \long\def\ekvd@ifnoarg#1% {% - \ifx\ekvd@noarg@mark#1% - \ekvd@fi@firstoftwo - \fi - \@secondoftwo + \ekvd@ifnoarg@\ekvd@ifnoarg@mark#1\ekvd@ifnoarg@mark\ekvd@ifnoarg@t + \ekvd@ifnoarg@mark\ekvd@noarg@mark\ekvd@ifnoarg@mark\@secondoftwo + } +\long\def\ekvd@ifnoarg@#1\ekvd@ifnoarg@mark\ekvd@noarg@mark\ekvd@ifnoarg@mark{} +\long\def\ekvd@ifnoarg@t + \ekvd@ifnoarg@mark\ekvd@noarg@mark\ekvd@ifnoarg@mark\@secondoftwo#1#2% + {% + #1% } % \end{macrocode} % \end{macro} @@ -1465,7 +1484,7 @@ and the derived files expkv-def.pdf % \begin{macro}[internal] % { % \ekvd@err@choice@invalid,\ekvd@err@choice@invalid@,\ekvd@choice@name, -% \ekvd@err +% \ekvd@unknown@choice@name,\ekvd@err % } % The expandable error messages use |\ekvd@err|, which is just like |\ekv@err| % from \expkv\ or the way \pkg{expl3} throws expandable error messages. It uses @@ -1487,9 +1506,15 @@ and the derived files expkv-def.pdf {% ekvd#1(#2)#3% } +\def\ekvd@unknown@choice@name#1#2% + {% + ekvd:u:#1(#2)% + } \def\ekvd@err@choice@invalid@ ekvd#1(#2)#3\ekv@stop% {% - \ekvd@err{invalid choice `#3' (`#2', set `#1')}% + \ekv@ifdefined{\ekvd@unknown@choice@name{#1}{#2}}% + {\csname\ekvd@unknown@choice@name{#1}{#2}\endcsname{#3}}% + {\ekvd@err{invalid choice `#3' (`#2', set `#1')}}% } } \begingroup diff --git a/Master/texmf-dist/tex/generic/expkv-def/expkv-def.tex b/Master/texmf-dist/tex/generic/expkv-def/expkv-def.tex index 6237d0803f8..d0f61214e56 100644 --- a/Master/texmf-dist/tex/generic/expkv-def/expkv-def.tex +++ b/Master/texmf-dist/tex/generic/expkv-def/expkv-def.tex @@ -35,8 +35,8 @@ \else \expandafter\endinput \fi -\def\ekvdVersion{0.3} -\def\ekvdDate{2020-04-29} +\def\ekvdVersion{0.4} +\def\ekvdDate{2020-07-04} \csname ekvd@tmp\endcsname \expandafter\chardef\csname ekvd@tmp\endcsname=\catcode`\@ \catcode`\@=11 @@ -410,6 +410,15 @@ \ekvd@populate@choice{#2}% }% } +\protected\long\expandafter\def\csname ekvd@t@unknown-choice\endcsname#1#2% + {% + \ekvd@assert@arg{unknown-choice #1}{#2}% + {% + \ekvd@assert@not@long{unknown-choice #1}% + \ekvd@prot\expandafter + \def\csname\ekvd@unknown@choice@name\ekvd@set{#1}\endcsname##1{#2}% + }% + } \def\ekvd@h@choice#1% {% \expandafter\ekvd@h@choice@ @@ -424,8 +433,6 @@ \fi #1% } -\def\ekvd@noarg@mark{\ekvd@noarg@mark} -\long\def\ekvd@fi@firstoftwo\fi\@secondoftwo#1#2{\fi#1} \protected\def\ekvd@newlet#1#2% {% \unless\ifdefined#1\let#1#2\fi @@ -452,10 +459,14 @@ } \long\def\ekvd@ifnoarg#1% {% - \ifx\ekvd@noarg@mark#1% - \ekvd@fi@firstoftwo - \fi - \@secondoftwo + \ekvd@ifnoarg@\ekvd@ifnoarg@mark#1\ekvd@ifnoarg@mark\ekvd@ifnoarg@t + \ekvd@ifnoarg@mark\ekvd@noarg@mark\ekvd@ifnoarg@mark\@secondoftwo + } +\long\def\ekvd@ifnoarg@#1\ekvd@ifnoarg@mark\ekvd@noarg@mark\ekvd@ifnoarg@mark{} +\long\def\ekvd@ifnoarg@t + \ekvd@ifnoarg@mark\ekvd@noarg@mark\ekvd@ifnoarg@mark\@secondoftwo#1#2% + {% + #1% } \long\def\ekvd@assert@filledarg#1#2% {% @@ -515,9 +526,15 @@ {% ekvd#1(#2)#3% } +\def\ekvd@unknown@choice@name#1#2% + {% + ekvd:u:#1(#2)% + } \def\ekvd@err@choice@invalid@ ekvd#1(#2)#3\ekv@stop% {% - \ekvd@err{invalid choice `#3' (`#2', set `#1')}% + \ekv@ifdefined{\ekvd@unknown@choice@name{#1}{#2}}% + {\csname\ekvd@unknown@choice@name{#1}{#2}\endcsname{#3}}% + {\ekvd@err{invalid choice `#3' (`#2', set `#1')}}% } } \begingroup |