diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/expkv-bundle/expkv-def.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/expkv-bundle/expkv-def.dtx | 125 |
1 files changed, 115 insertions, 10 deletions
diff --git a/Master/texmf-dist/source/latex/expkv-bundle/expkv-def.dtx b/Master/texmf-dist/source/latex/expkv-bundle/expkv-def.dtx index 33933425e6b..6fc3c54b149 100644 --- a/Master/texmf-dist/source/latex/expkv-bundle/expkv-def.dtx +++ b/Master/texmf-dist/source/latex/expkv-bundle/expkv-def.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -% File: expkv-def.dtx Copyright (C) 2020-2023 Jonathan P. Spratte +% File: expkv-def.dtx Copyright (C) 2020-2024 Jonathan P. Spratte % % This work may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this license or @@ -85,8 +85,8 @@ % \begin{macro}{\ekvdVersion,\ekvdDate} % We're on our first input, so lets store the version and date in a macro. % \begin{macrocode} -\def\ekvdVersion{1.0} -\def\ekvdDate{2023-01-23} +\def\ekvdVersion{1.1} +\def\ekvdDate{2024-12-16} % \end{macrocode} % \end{macro} % @@ -696,6 +696,38 @@ % \end{macro} % \end{macro} % +% \begin{macro}{alias} +% A few more or less standard tests and then copy over the definitions. +% \begin{macrocode} +\ekvd@def@type{alias} + {% + \ekvd@assert@arg + \ekvd@assert@not@protected + \ekvd@assert@not@long + \ekvd@assert@not@also +% \end{macrocode} +% In order to do nothing if |new| should be checked and the error condition +% for either the |Val|- or |NoVal|-key is met we need to check for the defined +% keys without actually copying here (the alternative would be using an +% auxiliary variable which we would then need to check anyway). +% \begin{macrocode} + \ekvifdefined\ekvd@set{#3}{\ekvd@do@new{}{#1}}{}% + \ekvifdefinedNoVal\ekvd@set{#3}{\ekvd@do@new{NoVal}{#1}}{}% +% \end{macrocode} +% Assert that at least one of |Val|- or |NoVal|-keys exist. +% \begin{macrocode} + \ekvpAssertTF + {\ekvifdefined\ekvd@set{#3}\@firstoftwo{\ekvifdefinedNoVal\ekvd@set{#3}}}% + {undefined key `#3'}% +% \end{macrocode} +% Copy the definitions. +% \begin{macrocode} + \ekvifdefined\ekvd@set{#3}{\ekvletkv\ekvd@set{#1}\ekvd@set{#3}}{}% + \ekvifdefinedNoVal\ekvd@set{#3}{\ekvletkvNoVal\ekvd@set{#1}\ekvd@set{#3}}{}% + } +% \end{macrocode} +% \end{macro} +% % \begin{macro}{choice} % \begin{macro}[internal]{\ekvd@type@choice,\ekvd@populate@choice} % The real key definition of a |choice| type is pretty simple, the heavy @@ -838,6 +870,51 @@ % \end{macro} % \end{macro} % +% \begin{macro}{choice-aliases} +% \begin{macro}[internal]{\ekvd@t@choicealias} +% Choice alias shall copy over separate choices to new names for the same key. +% The code is pretty straight forward, we just make sure no disallowed +% prefixes were used, the key exists, is already a choice key, and then we +% loop through the list of aliases. +% \begin{macrocode} +\ekvd@def@type{choice-aliases} + {% + \ekvd@assert@arg + \ekvd@assert@not@protected + \ekvd@assert@not@long + \ekvd@assert@not@also + \ekvd@assert@already@choice{#1}% + \ekvparse\ekvd@err@missing@value{\ekvd@t@choicealias{#1}}{#3}% + } +% \end{macrocode} +% The copying of the definitions is rather straight forward, check if choice +% of that name exists, and if so copy it. The |new| prefix will apply for each +% individual new choice, so we need to check this here. +% \begin{macrocode} +\protected\long\def\ekvd@t@choicealias#1#2#3% + {% + \ifx\ekvd@do@new\ekvd@assert@new + \ekv@fi@firstofone + \fi + \@gobble + {% + \ekv@ifdefined{\ekvd@choice@name\ekvd@set{#1}{#2}}% + {\ekvd@err@not@new@choice{#2}\ekv@gobbleto@stop}% + {}% + }% + \ekv@ifdefined{\ekvd@choice@name\ekvd@set{#1}{#3}}% + {% + \expandafter\let + \csname\ekvd@choice@name\ekvd@set{#1}{#2}\expandafter\endcsname + \csname\ekvd@choice@name\ekvd@set{#1}{#3}\endcsname + }% + {\ekvd@err@undefined@choice{#1}{#3}}% + \@gobble\ekv@stop + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% % \begin{macro}{unknown-choice} % \begin{macrocode} \ekvd@def@type{unknown-choice} @@ -1220,9 +1297,14 @@ % \begin{macrocode} \protected\def\ekvd@if@not@already@choice#1% {% - \expandafter\ekvd@if@not@already@choice@a - \csname\ekv@name\ekvd@set{#1}\endcsname - {}\ekvd@h@choice\ekvd@stop + \ekvifdefined\ekvd@set{#1}% + {% + \expandafter + \ekvd@if@not@already@choice@a + \csname\ekv@name\ekvd@set{#1}\endcsname + {}\ekvd@h@choice\ekvd@stop + }% + {\@firstofone}% } \protected\def\ekvd@if@not@already@choice@a {% @@ -1235,6 +1317,15 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}[internal]{\ekvd@assert@already@choice} +% A small assertion that a key is defined as a choice key. With the test +% |\ekvd@if@not@already@choice| this becomes pretty easy. +% \begin{macrocode} +\long\def\ekvd@assert@already@choice#1% + {\ekvd@if@not@already@choice{#1}{\ekvd@err@not@choice\ekvpGobbleT}} +% \end{macrocode} +% \end{macro} +% % \begin{macro}[internal]{\ekvd@ifspace,\ekvd@ifspace@} % Yet another test which can be reduced to an if-empty, this time by gobbling % everything up to the first space. @@ -1259,10 +1350,13 @@ % \begin{macro}[internal] % { % \ekvd@errm,\ekvd@err@missing@definition, -% \ekvd@err@missing@type,\ekvd@err@undefined@prefix,\ekvd@err@undefined@key, +% \ekvd@err@missing@type, +% \ekvd@err@undefined@prefix,\ekvd@err@undefined@key, +% \ekvd@err@undefined@noval,\ekvd@err@undefined@choice, % \ekvd@err@no@prefix,\ekvd@err@no@prefix@also, % \ekvd@err@add@val@on@noval,\ekvd@err@add@noval@on@val, -% \ekvd@err@unsupported@arg,\ekvd@err@not@new +% \ekvd@err@unsupported@arg,\ekvd@err@not@new,\ekvd@err@not@new@choice, +% \ekvd@err@not@choice,\ekvd@err@missing@value % } % The non-expandable error messages are boring, so here they are: % \begin{macrocode} @@ -1288,7 +1382,7 @@ {% \ekvd@errm {% - Undefined noval key `\ekv@unexpanded{#1}' found while processing + Undefined NoVal key `\ekv@unexpanded{#1}' found while processing `\ekvd@cur'% }% } @@ -1310,8 +1404,19 @@ } \protected\def\ekvd@err@not@new {\ekvd@errm{The key for `\ekvd@cur' is already defined}} -\protected\long\def\ekvd@err@misused@unknown +\protected\def\ekvd@err@not@new@choice#1% + {\ekvd@errm{The choice `\detokenize{#1}' is already defined for `\ekvd@cur'}} +\protected\def\ekvd@err@misused@unknown {\ekvd@errm{Misuse of the unknown type found while processing `\ekvd@cur'}} +\protected\long\def\ekvd@err@not@choice + {\ekvd@errm{The key for `\ekvd@cur' is not an existing choice key}} +\protected\long\def\ekvd@err@missing@value#1% + {\ekvd@errm{Missing value for `#1' in `\ekvd@cur'}} +\protected\long\def\ekvd@err@undefined@choice#1#2% + {% + \ekvd@errm + {Undefined choice `#2' for key `#1' found while processing `\ekvd@cur'}% + } % \end{macrocode} % \end{macro} % |