texlive[55749] Master/texmf-dist: expkv-def (4jul20)

commits+karl at tug.org commits+karl at tug.org
Sat Jul 4 22:48:01 CEST 2020


Revision: 55749
          http://tug.org/svn/texlive?view=revision&revision=55749
Author:   karl
Date:     2020-07-04 22:48:00 +0200 (Sat, 04 Jul 2020)
Log Message:
-----------
expkv-def (4jul20)

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

Modified: trunk/Master/texmf-dist/doc/latex/expkv-def/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/expkv-def/README.md	2020-07-04 13:14:25 UTC (rev 55748)
+++ trunk/Master/texmf-dist/doc/latex/expkv-def/README.md	2020-07-04 20:48:00 UTC (rev 55749)
@@ -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

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	2020-07-04 13:14:25 UTC (rev 55748)
+++ trunk/Master/texmf-dist/source/latex/expkv-def/expkv-def.dtx	2020-07-04 20:48:00 UTC (rev 55749)
@@ -354,7 +354,9 @@
 %   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,9 +503,22 @@
 %   \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}
 % 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
@@ -669,8 +684,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.3}
-\def\ekvdDate{2020-04-29}
+\def\ekvdVersion{0.4}
+\def\ekvdDate{2020-07-04}
 %    \end{macrocode}
 % \end{macro}
 %
@@ -1280,6 +1295,20 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}[internal]{\ekvd at t@unknown-choice}
+%    \begin{macrocode}
+\protected\long\expandafter\def\csname ekvd at t@unknown-choice\endcsname#1#2%
+  {%
+    \ekvd at assert@arg{unknown-choice #1}{#2}%
+      {%
+        \ekvd at assert@not at long{unknown-choice #1}%
+        \ekvd at prot\expandafter
+        \def\csname\ekvd at unknown@choice at name\ekvd at 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 @@
 %
 % \subsubsection{Tests}
 %
-% \begin{macro}[internal]{\ekvd at 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 at noarg@mark{\ekvd at noarg@mark}
-%    \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}[internal]{\ekvd at 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 at fi@firstoftwo\fi\@secondoftwo#1#2{\fi#1}
-%    \end{macrocode}
-% \end{macro}
-%
 % \begin{macro}[internal]{\ekvd at newlet,\ekvd at 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 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}[internal]{\ekvd at assert@arg,\ekvd at ifnoarg}
-% The test for an argument is just an |\ifx| comparison with our |noarg at mark|.
+% \begin{macro}[internal]
+%   {\ekvd at assert@arg,\ekvd at ifnoarg,\ekvd at ifnoarg@,\ekvd at 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 at assert@arg#1#2%
   {%
@@ -1372,11 +1387,15 @@
   }
 \long\def\ekvd at ifnoarg#1%
   {%
-    \ifx\ekvd at noarg@mark#1%
-      \ekvd at fi@firstoftwo
-    \fi
-    \@secondoftwo
+    \ekvd at ifnoarg@\ekvd at ifnoarg@mark#1\ekvd at ifnoarg@mark\ekvd at ifnoarg@t
+      \ekvd at ifnoarg@mark\ekvd at noarg@mark\ekvd at ifnoarg@mark\@secondoftwo
   }
+\long\def\ekvd at ifnoarg@#1\ekvd at ifnoarg@mark\ekvd at noarg@mark\ekvd at ifnoarg@mark{}
+\long\def\ekvd at ifnoarg@t
+    \ekvd at ifnoarg@mark\ekvd at noarg@mark\ekvd at ifnoarg@mark\@secondoftwo#1#2%
+  {%
+    #1%
+  }
 %    \end{macrocode}
 % \end{macro}
 %
@@ -1465,7 +1484,7 @@
 % \begin{macro}[internal]
 %   {
 %     \ekvd at err@choice at invalid,\ekvd at err@choice at invalid@,\ekvd at choice@name,
-%     \ekvd at err
+%     \ekvd at unknown@choice at name,\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
@@ -1487,9 +1506,15 @@
   {%
     ekvd#1(#2)#3%
   }
+\def\ekvd at unknown@choice at name#1#2%
+  {%
+    ekvd:u:#1(#2)%
+  }
 \def\ekvd at err@choice at invalid@ ekvd#1(#2)#3\ekv at stop%
   {%
-    \ekvd at err{invalid choice `#3' (`#2', set `#1')}%
+    \ekv at ifdefined{\ekvd at unknown@choice at name{#1}{#2}}%
+      {\csname\ekvd at unknown@choice at name{#1}{#2}\endcsname{#3}}%
+      {\ekvd at err{invalid choice `#3' (`#2', set `#1')}}%
   }
 }
 \begingroup

Modified: trunk/Master/texmf-dist/tex/generic/expkv-def/expkv-def.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/expkv-def/expkv-def.tex	2020-07-04 13:14:25 UTC (rev 55748)
+++ trunk/Master/texmf-dist/tex/generic/expkv-def/expkv-def.tex	2020-07-04 20:48:00 UTC (rev 55749)
@@ -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 at tmp\endcsname
 \expandafter\chardef\csname ekvd at tmp\endcsname=\catcode`\@
 \catcode`\@=11
@@ -410,6 +410,15 @@
         \ekvd at populate@choice{#2}%
       }%
   }
+\protected\long\expandafter\def\csname ekvd at t@unknown-choice\endcsname#1#2%
+  {%
+    \ekvd at assert@arg{unknown-choice #1}{#2}%
+      {%
+        \ekvd at assert@not at long{unknown-choice #1}%
+        \ekvd at prot\expandafter
+        \def\csname\ekvd at unknown@choice at name\ekvd at set{#1}\endcsname##1{#2}%
+      }%
+  }
 \def\ekvd at h@choice#1%
   {%
     \expandafter\ekvd at h@choice@
@@ -424,8 +433,6 @@
     \fi
     #1%
   }
-\def\ekvd at noarg@mark{\ekvd at noarg@mark}
-\long\def\ekvd at fi@firstoftwo\fi\@secondoftwo#1#2{\fi#1}
 \protected\def\ekvd at newlet#1#2%
   {%
     \unless\ifdefined#1\let#1#2\fi
@@ -452,11 +459,15 @@
   }
 \long\def\ekvd at ifnoarg#1%
   {%
-    \ifx\ekvd at noarg@mark#1%
-      \ekvd at fi@firstoftwo
-    \fi
-    \@secondoftwo
+    \ekvd at ifnoarg@\ekvd at ifnoarg@mark#1\ekvd at ifnoarg@mark\ekvd at ifnoarg@t
+      \ekvd at ifnoarg@mark\ekvd at noarg@mark\ekvd at ifnoarg@mark\@secondoftwo
   }
+\long\def\ekvd at ifnoarg@#1\ekvd at ifnoarg@mark\ekvd at noarg@mark\ekvd at ifnoarg@mark{}
+\long\def\ekvd at ifnoarg@t
+    \ekvd at ifnoarg@mark\ekvd at noarg@mark\ekvd at ifnoarg@mark\@secondoftwo#1#2%
+  {%
+    #1%
+  }
 \long\def\ekvd at assert@filledarg#1#2%
   {%
     \ekvd at ifnoarg@or at empty{#2}%
@@ -515,9 +526,15 @@
   {%
     ekvd#1(#2)#3%
   }
+\def\ekvd at unknown@choice at name#1#2%
+  {%
+    ekvd:u:#1(#2)%
+  }
 \def\ekvd at err@choice at invalid@ ekvd#1(#2)#3\ekv at stop%
   {%
-    \ekvd at err{invalid choice `#3' (`#2', set `#1')}%
+    \ekv at ifdefined{\ekvd at unknown@choice at name{#1}{#2}}%
+      {\csname\ekvd at unknown@choice at name{#1}{#2}\endcsname{#3}}%
+      {\ekvd at err{invalid choice `#3' (`#2', set `#1')}}%
   }
 }
 \begingroup



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