texlive[58814] Master/texmf-dist: expkv-def (10apr21)

commits+karl at tug.org commits+karl at tug.org
Sat Apr 10 23:09:59 CEST 2021


Revision: 58814
          http://tug.org/svn/texlive?view=revision&revision=58814
Author:   karl
Date:     2021-04-10 23:09:57 +0200 (Sat, 10 Apr 2021)
Log Message:
-----------
expkv-def (10apr21)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/expkv-def/README.md
    trunk/Master/texmf-dist/doc/latex/expkv-def/expkv-def.pdf
    trunk/Master/texmf-dist/source/latex/expkv-def/expkv-def.dtx
    trunk/Master/texmf-dist/tex/generic/expkv-def/expkv-def.tex
    trunk/Master/texmf-dist/tex/latex/expkv-def/expkv-def.sty

Modified: trunk/Master/texmf-dist/doc/latex/expkv-def/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/expkv-def/README.md	2021-04-10 13:19:50 UTC (rev 58813)
+++ trunk/Master/texmf-dist/doc/latex/expkv-def/README.md	2021-04-10 21:09:57 UTC (rev 58814)
@@ -1,7 +1,7 @@
 -------------------------------------------------------------------------------
 # expkv-def -- a key-defining frontend for expkv
 
-Version 2020-12-28 v0.7
+Version 2021-04-10 v0.8
 
 Released under the LaTeX Project Public License v1.3c or later
 See http://www.latex-project.org/lppl.txt
@@ -10,7 +10,7 @@
 
 -------------------------------------------------------------------------------
 
-Copyright (C) 2020 Jonathan P. Spratte
+Copyright (C) 2020-2021 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

Modified: trunk/Master/texmf-dist/doc/latex/expkv-def/expkv-def.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/latex/expkv-def/expkv-def.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/expkv-def/expkv-def.dtx	2021-04-10 13:19:50 UTC (rev 58813)
+++ trunk/Master/texmf-dist/source/latex/expkv-def/expkv-def.dtx	2021-04-10 21:09:57 UTC (rev 58814)
@@ -1,6 +1,6 @@
 % \iffalse meta-comment
 %
-% File: expkv-def.dtx Copyright (C) 2020 Jonathan P. Spratte
+% File: expkv-def.dtx Copyright (C) 2020-2021 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
@@ -27,7 +27,7 @@
 See http://www.latex-project.org/lppl.txt
 --------------------------------------------------------------
 
-Copyright (C) 2020 Jonathan P. Spratte
+Copyright (C) 2020-2021 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
@@ -600,6 +600,64 @@
 %   you can refer to the choice which was passed in with |#1|.
 % \end{function}
 %
+% \begin{function}{unknown code}
+%   \begin{syntax}
+%     unknown code = \marg{definition} \prefixes2322
+%   \end{syntax}
+%   By default \expkv\ throws errors when it encounters unknown keys in a set.
+%   With the |unknown| prefix you can define handlers that deal with undefined
+%   keys, instead of a \key\ name you have to specify a subtype for this prefix,
+%   here the subtype is |code|.\par
+%   With |unknown code| the \meta{definition} is used for unknown keys which
+%   were provided a value (so corresponds to |\ekvdefunknown|), you can access
+%   the key name with |#1| and the value with |#2|.\footnotemark
+% \end{function}
+% \footnotetext
+%   {^^A
+%     There is some trickery involved to get this more intuitive argument order
+%     without any performance hit if you compare this to
+%     \cs[no-index]{ekvdefunknown} directly.^^A
+%   }
+%
+% \begin{function}{unknown noval}
+%   \begin{syntax}
+%     unknown noval = \marg{definition} \prefixes2323
+%   \end{syntax}
+%   This is like |unknown code| but uses \meta{definition} for unknown keys to
+%   which no value was passed (so corresponds to |\ekvdefunknownNoVal|). You can
+%   access the key name with |#1|.
+% \end{function}
+%
+% \begin{function}{unknown redirect-code}
+%   \begin{syntax}
+%     unknown redirect-code = \marg{set-list} \prefixes2331
+%   \end{syntax}
+%   This uses a predefined action for |unknown code|. Instead of throwing an
+%   error, it is tried to find the \key\ in each \set\ in the comma separated
+%   \meta{set-list}. The first found match will be used and the remaining
+%   options from the list discarded. If the \key\ isn't found in any \set\ an
+%   expandable error will be thrown eventually. Internally \expkv's
+%   |\ekvredirectunknown| will be used.
+% \end{function}
+%
+% \begin{function}{unknown redirect-noval}
+%   \begin{syntax}
+%     unknown redirect-noval = \marg{set-list} \prefixes2333
+%   \end{syntax}
+%   This behaves just like |unknown redirect-code| but will set up means to
+%   forward keys for |unknown noval|. Internally \expkv's
+%   |\ekvredirectunknownNoVal| will be used.
+% \end{function}
+%
+% \begin{function}{unknown redirect}
+%   \begin{syntax}
+%     unknown redirect = \marg{set-list} \prefixes2333
+%   \end{syntax}
+%   This is a short cut to apply both, |unknown redirect-code| and
+%   |unknown redirect-noval|, as a result you might get doubled error messages,
+%   one from each.
+% \end{function}
+%
 % \subsection{Bugs}
 % I don't think there are any (but every developer says that), if you find some
 % please let me know, either via the email address on the first page or on
@@ -766,8 +824,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{0.7}
-\def\ekvdDate{2020-12-28}
+\def\ekvdVersion{0.8}
+\def\ekvdDate{2021-04-10}
 %    \end{macrocode}
 % \end{macro}
 %
@@ -1543,12 +1601,7 @@
 %    \begin{macrocode}
 \protected\long\expandafter\def\csname ekvd at t@unknown-choice\endcsname#1#2%
   {%
-    \ifx\ekvd at ifnew\ekvd at assert@new
-      \ekv at fi@firstoftwo
-    \fi
-    \@secondoftwo
-      {\ekv at ifdefined{\ekvd at unknown@choice at name\ekvd at set{#1}}\ekvd at err@not at new}%
-      \@firstofone
+    \ekvd at assert@new at for@name{\ekvd at unknown@choice at name\ekvd at set{#1}}%
       {%
         \ekvd at assert@arg
           {%
@@ -1562,6 +1615,103 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}[internal]
+%   {\ekvd at t@unknown,\ekvd at type@unknown at code,\ekvd at type@unknown at noval}
+%   The |unknown| type has different subtypes which would be the key names for
+%   other types. It is first checked whether that subtype is defined, if it
+%   isn't throw an error, else use that subtype.
+%    \begin{macrocode}
+\protected\long\def\ekvd at t@unknown#1#2%
+  {%
+    \ekv at ifdefined{ekvd at type@unknown@\detokenize{#1}}%
+      {\csname ekvd at type@unknown@\detokenize{#1}\endcsname{#2}}%
+      \ekvd at err@misused at unknown
+  }
+%    \end{macrocode}
+%   The |unknown noval| type can use |\ekvdefunknownNoVal| directly (after
+%   asserting some prefixes).
+%    \begin{macrocode}
+\protected\long\def\ekvd at type@unknown at noval#1%
+  {%
+    \ekvd at assert@new at for@name{\ekv at name\ekvd at set{}uN}%
+      {%
+        \ekvd at assert@arg
+          {%
+            \ekvd at assert@not at also
+            \ekvd at assert@not at long
+            \ekvd at prot\ekvdefunknownNoVal\ekvd at set{#1}%
+          }%
+      }%
+  }
+%    \end{macrocode}
+%   The |unknown code| type uses some trickery during the definition in order to
+%   swap out |#1| and |#2| in the user supplied definition. This is done via a
+%   temporary macro that stores the definition but gets the parameter numbers
+%   reversed while the real definition is done.
+%    \begin{macrocode}
+\protected\long\def\ekvd at type@unknown at code#1%
+  {%
+    \ekvd at assert@new at for@name{\ekv at name\ekvd at set{}u}%
+      {%
+        \ekvd at assert@arg
+          {%
+            \ekvd at assert@not at also
+            \begingroup
+              \def\ekvd at tmp##1##2{#1}%
+              \ekv at exparg
+              {%
+                \endgroup
+                \ekvd at prot\ekvd at long\ekvdefunknown\ekvd at set
+              }%
+              {\ekvd at tmp{##2}{##1}}%
+          }%
+      }%
+  }
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]
+%   {
+%     \ekvd at type@unknown at redirect,
+%     \ekvd at type@unknown at redirect-code,
+%     \ekvd at type@unknown at redirect-noval
+%   }
+%   The |unknown redirect| types also just forward to |\ekvredirectunknown|
+%   after asserting some prefixes.
+%    \begin{macrocode}
+\protected\edef\ekvd at type@unknown at redirect#1%
+  {%
+    \expandafter\noexpand\csname ekvd at type@unknown at redirect-code\endcsname{#1}%
+    \expandafter\noexpand\csname ekvd at type@unknown at redirect-noval\endcsname{#1}%
+  }
+\protected\expandafter\def\csname ekvd at type@unknown at redirect-code\endcsname#1%
+  {%
+    \ekvd at assert@new at for@name{\ekv at name\ekvd at set{}u}%
+      {%
+        \ekvd at assert@arg
+          {%
+            \ekvd at assert@not at also
+            \ekvd at assert@not at protected
+            \expandafter\ekvredirectunknown\expandafter{\ekvd at set}{#1}%
+          }%
+      }%
+  }
+\protected\expandafter\def\csname ekvd at type@unknown at redirect-noval\endcsname#1%
+  {%
+    \ekvd at assert@new at for@name{\ekv at name\ekvd at set{}uN}%
+      {%
+        \ekvd at assert@arg
+          {%
+            \ekvd at assert@not at also
+            \ekvd at assert@not at protected
+            \ekvd at assert@not at long
+            \expandafter\ekvredirectunknownNoVal\expandafter{\ekvd at set}{#1}%
+          }%
+      }%
+  }
+%    \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
@@ -1819,6 +1969,15 @@
   {\csname ekvifdefined#1\endcsname\ekvd at set{#2}{\ekvd at err@not at new}}
 \def\ekvd at assert@not at new
   {\ifx\ekvd at ifnew\ekvd at assert@new\ekvd at err@no at prefix{new}\fi}
+\def\ekvd at assert@new at for@name#1%
+  {%
+    \ifx\ekvd at ifnew\ekvd at assert@new
+      \ekv at fi@firstoftwo
+    \fi
+    \@secondoftwo
+      {\ekv at ifdefined{#1}\ekvd at err@not at new}%
+      \@firstofone
+  }
 %    \end{macrocode}
 % \end{macro}
 %
@@ -1917,6 +2076,8 @@
   }
 \protected\def\ekvd at err@not at new
   {\ekvd at errm{The key for `\ekvd at cur' is already defined}} 
+\protected\long\def\ekvd at err@misused at unknown
+  {\ekvd at errm{Misuse of the unknown type found while processing `\ekvd at cur'}}
 %    \end{macrocode}
 % \end{macro}
 %
@@ -1923,11 +2084,8 @@
 % \begin{macro}[internal]
 %   {
 %     \ekvd at err@choice at invalid,\ekvd at err@choice at invalid@,\ekvd at choice@name,
-%     \ekvd at unknown@choice at name,\ekvd at err
+%     \ekvd at unknown@choice at name
 %   }
-% The expandable error messages use |\ekvd at err|, which is just like |\ekv at err|
-% from \expkv\ or the way \pkg{expl3} throws expandable error messages. It uses
-% an undefined control sequence to start the error message.
 % |\ekvd at err@choice at invalid| will have to use this mechanism to throw its
 % message. Also we have to retrieve the name parts of the choice in an easy way,
 % so we use parentheses of catcode 8 here, which should suffice in most cases to
@@ -1956,18 +2114,20 @@
       {\ekvd at err{invalid choice `#3' (`#2', set `#1')}}%
   }
 }
-\begingroup
-\edef\ekvd at err
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[internal]{\ekvd at err}
+% The expandable error messages use |\ekvd at err|, which is just like |\ekv at err|
+% from \expkv\ or the way \pkg{expl3} throws expandable error messages. It uses
+% an undefined control sequence to start the error message.
+%    \begin{macrocode}
+\def\ekvd at err#1%
   {%
-    \endgroup
-    \unexpanded{\long\def\ekvd at err}##1%
-      {%
-        \unexpanded{\expandafter\ekv at err@\@firstofone}%
-        {\unexpanded\expandafter{\csname ! expkv-def Error:\endcsname}##1.}%
-        \unexpanded{\ekv at stop}%
-      }%
+    \long\def\ekvd at err##1{\expandafter\ekv at err@\@firstofone{#1##1.}\ekv at stop}%
   }
-\ekvd at err
+\begingroup\expandafter\endgroup
+\expandafter\ekvd at err\csname ! expkv-def Error:\endcsname
 %    \end{macrocode}
 % \end{macro}
 %

Modified: trunk/Master/texmf-dist/tex/generic/expkv-def/expkv-def.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/expkv-def/expkv-def.tex	2021-04-10 13:19:50 UTC (rev 58813)
+++ trunk/Master/texmf-dist/tex/generic/expkv-def/expkv-def.tex	2021-04-10 21:09:57 UTC (rev 58814)
@@ -13,7 +13,7 @@
 %% See http://www.latex-project.org/lppl.txt
 %% --------------------------------------------------------------
 %% 
-%% Copyright (C) 2020 Jonathan P. Spratte
+%% Copyright (C) 2020-2021 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
@@ -35,8 +35,8 @@
 \else
   \expandafter\endinput
 \fi
-\def\ekvdVersion{0.7}
-\def\ekvdDate{2020-12-28}
+\def\ekvdVersion{0.8}
+\def\ekvdDate{2021-04-10}
 \csname ekvd at tmp\endcsname
 \expandafter\chardef\csname ekvd at tmp\endcsname=\catcode`\@
 \catcode`\@=11
@@ -557,12 +557,7 @@
   }
 \protected\long\expandafter\def\csname ekvd at t@unknown-choice\endcsname#1#2%
   {%
-    \ifx\ekvd at ifnew\ekvd at assert@new
-      \ekv at fi@firstoftwo
-    \fi
-    \@secondoftwo
-      {\ekv at ifdefined{\ekvd at unknown@choice at name\ekvd at set{#1}}\ekvd at err@not at new}%
-      \@firstofone
+    \ekvd at assert@new at for@name{\ekvd at unknown@choice at name\ekvd at set{#1}}%
       {%
         \ekvd at assert@arg
           {%
@@ -573,6 +568,72 @@
           }%
       }%
   }
+\protected\long\def\ekvd at t@unknown#1#2%
+  {%
+    \ekv at ifdefined{ekvd at type@unknown@\detokenize{#1}}%
+      {\csname ekvd at type@unknown@\detokenize{#1}\endcsname{#2}}%
+      \ekvd at err@misused at unknown
+  }
+\protected\long\def\ekvd at type@unknown at noval#1%
+  {%
+    \ekvd at assert@new at for@name{\ekv at name\ekvd at set{}uN}%
+      {%
+        \ekvd at assert@arg
+          {%
+            \ekvd at assert@not at also
+            \ekvd at assert@not at long
+            \ekvd at prot\ekvdefunknownNoVal\ekvd at set{#1}%
+          }%
+      }%
+  }
+\protected\long\def\ekvd at type@unknown at code#1%
+  {%
+    \ekvd at assert@new at for@name{\ekv at name\ekvd at set{}u}%
+      {%
+        \ekvd at assert@arg
+          {%
+            \ekvd at assert@not at also
+            \begingroup
+              \def\ekvd at tmp##1##2{#1}%
+              \ekv at exparg
+              {%
+                \endgroup
+                \ekvd at prot\ekvd at long\ekvdefunknown\ekvd at set
+              }%
+              {\ekvd at tmp{##2}{##1}}%
+          }%
+      }%
+  }
+\protected\edef\ekvd at type@unknown at redirect#1%
+  {%
+    \expandafter\noexpand\csname ekvd at type@unknown at redirect-code\endcsname{#1}%
+    \expandafter\noexpand\csname ekvd at type@unknown at redirect-noval\endcsname{#1}%
+  }
+\protected\expandafter\def\csname ekvd at type@unknown at redirect-code\endcsname#1%
+  {%
+    \ekvd at assert@new at for@name{\ekv at name\ekvd at set{}u}%
+      {%
+        \ekvd at assert@arg
+          {%
+            \ekvd at assert@not at also
+            \ekvd at assert@not at protected
+            \expandafter\ekvredirectunknown\expandafter{\ekvd at set}{#1}%
+          }%
+      }%
+  }
+\protected\expandafter\def\csname ekvd at type@unknown at redirect-noval\endcsname#1%
+  {%
+    \ekvd at assert@new at for@name{\ekv at name\ekvd at set{}uN}%
+      {%
+        \ekvd at assert@arg
+          {%
+            \ekvd at assert@not at also
+            \ekvd at assert@not at protected
+            \ekvd at assert@not at long
+            \expandafter\ekvredirectunknownNoVal\expandafter{\ekvd at set}{#1}%
+          }%
+      }%
+  }
 \def\ekvd at h@choice#1%
   {%
     \expandafter\ekvd at h@choice@
@@ -733,6 +794,15 @@
   {\csname ekvifdefined#1\endcsname\ekvd at set{#2}{\ekvd at err@not at new}}
 \def\ekvd at assert@not at new
   {\ifx\ekvd at ifnew\ekvd at assert@new\ekvd at err@no at prefix{new}\fi}
+\def\ekvd at assert@new at for@name#1%
+  {%
+    \ifx\ekvd at ifnew\ekvd at assert@new
+      \ekv at fi@firstoftwo
+    \fi
+    \@secondoftwo
+      {\ekv at ifdefined{#1}\ekvd at err@not at new}%
+      \@firstofone
+  }
 \protected\def\ekvd at if@not at already@choice#1%
   {%
     \expandafter\ekvd at if@not at already@choice at a
@@ -794,6 +864,8 @@
   }
 \protected\def\ekvd at err@not at new
   {\ekvd at errm{The key for `\ekvd at cur' is already defined}}
+\protected\long\def\ekvd at err@misused at unknown
+  {\ekvd at errm{Misuse of the unknown type found while processing `\ekvd at cur'}}
 \def\ekvd at err@choice at invalid#1%
   {%
     \ekvd at err@choice at invalid@#1\ekv at stop
@@ -817,18 +889,12 @@
       {\ekvd at err{invalid choice `#3' (`#2', set `#1')}}%
   }
 }
-\begingroup
-\edef\ekvd at err
+\def\ekvd at err#1%
   {%
-    \endgroup
-    \unexpanded{\long\def\ekvd at err}##1%
-      {%
-        \unexpanded{\expandafter\ekv at err@\@firstofone}%
-        {\unexpanded\expandafter{\csname ! expkv-def Error:\endcsname}##1.}%
-        \unexpanded{\ekv at stop}%
-      }%
+    \long\def\ekvd at err##1{\expandafter\ekv at err@\@firstofone{#1##1.}\ekv at stop}%
   }
-\ekvd at err
+\begingroup\expandafter\endgroup
+\expandafter\ekvd at err\csname ! expkv-def Error:\endcsname
 \catcode`\@=\ekvd at tmp
 %% 
 %%

Modified: trunk/Master/texmf-dist/tex/latex/expkv-def/expkv-def.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/expkv-def/expkv-def.sty	2021-04-10 13:19:50 UTC (rev 58813)
+++ trunk/Master/texmf-dist/tex/latex/expkv-def/expkv-def.sty	2021-04-10 21:09:57 UTC (rev 58814)
@@ -13,7 +13,7 @@
 %% See http://www.latex-project.org/lppl.txt
 %% --------------------------------------------------------------
 %% 
-%% Copyright (C) 2020 Jonathan P. Spratte
+%% Copyright (C) 2020-2021 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



More information about the tex-live-commits mailing list.