[latex3-commits] [git/LaTeX3-latex3-latex3] main: Template choices always require code to implement (9bba5be5c)

Joseph Wright joseph.wright at morningstar2.co.uk
Mon May 30 15:05:39 CEST 2022


Repository : https://github.com/latex3/latex3
On branch  : main
Link       : https://github.com/latex3/latex3/commit/9bba5be5ca92c9f76da424e3bac8ce68346a345d

>---------------------------------------------------------------

commit 9bba5be5ca92c9f76da424e3bac8ce68346a345d
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Mon May 30 14:05:39 2022 +0100

    Template choices always require code to implement


>---------------------------------------------------------------

9bba5be5ca92c9f76da424e3bac8ce68346a345d
 l3packages/xtemplate/xtemplate.dtx | 31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/l3packages/xtemplate/xtemplate.dtx b/l3packages/xtemplate/xtemplate.dtx
index 503db8acc..9ac968b97 100644
--- a/l3packages/xtemplate/xtemplate.dtx
+++ b/l3packages/xtemplate/xtemplate.dtx
@@ -1707,7 +1707,7 @@
     \prop_put:Non \l_@@_vars_prop \l_@@_key_name_tl { }
     \keys_define:nx { template / #1 } { \l_@@_key_name_tl .choice: }
     \keyval_parse:nnn
-      { \@@_implement_choice_elt:nn {#1} }
+      { \@@_implement_choice_elt:n }
       { \@@_implement_choice_elt:nnn {#1} }
       {#2}
     \prop_get:NoNT \l_@@_values_prop \l_@@_key_name_tl
@@ -1751,19 +1751,20 @@
 % \end{macro}
 % \end{macro}
 %
-% \begin{macro}{\@@_implement_choice_elt:nn}
-% \begin{macro}{\@@_implement_choice_elt:nnn}
+% \begin{macro}{\@@_implement_choice_elt:nnn, \@@_implement_choice_elt_aux:nnn}
+% \begin{macro}{\@@_implement_choice_elt:n}
 %   The actual storage of the implementation of a choice is mainly about
 %   error checking. The code here ensures that all choices have to have
 %   been declared, apart from the special \texttt{unknown} choice, which
 %   must come last. The code for each choice is stored along with the
 %   key name in the variables property list.
 %    \begin{macrocode}
-\cs_new_protected:Npn \@@_implement_choice_elt:nn #1#2
+\cs_new_protected:Npn \@@_implement_choice_elt:nnn #1#2#3
   {
     \clist_if_empty:NTF \l_@@_tmp_clist
       {
-        \str_if_eq:nnF {#2} { unknown }
+        \str_if_eq:nnTF {#2} { unknown }
+          { \@@_implement_choice_elt_aux:nnn {#1} {#2} {#3} }
           {
             \prop_get:NoN \l_@@_keytypes_prop \l_@@_key_name_tl
               \l_@@_tmp_tl
@@ -1775,7 +1776,10 @@
       }
       {
         \clist_if_in:NnTF \l_@@_tmp_clist {#2}
-          { \clist_remove_all:Nn \l_@@_tmp_clist {#2} }
+          {
+            \clist_remove_all:Nn \l_@@_tmp_clist {#2}
+            \@@_implement_choice_elt_aux:nnn {#1} {#2} {#3}
+          }
           {
             \prop_get:NoN \l_@@_keytypes_prop \l_@@_key_name_tl
               \l_@@_tmp_tl
@@ -1786,15 +1790,19 @@
           }
       }
   }
-\cs_new_protected:Npn \@@_implement_choice_elt:nnn #1#2#3
+\cs_new_protected:Npn \@@_implement_choice_elt_aux:nnn #1#2#3
   {
-    \@@_implement_choice_elt:nn {#1} {#2}
     \keys_define:nx { template / #1 }
       { \l_@@_key_name_tl / #2 .code:n = { \exp_not:n {#3} } }
     \tl_set:Nx \l_@@_tmp_tl
       { \l_@@_key_name_tl \c_space_tl #2 }
     \prop_put:Non \l_@@_vars_prop \l_@@_tmp_tl {#3}
   }
+\cs_new_protected:Npn \@@_implement_choice_elt:n #1
+  {
+    \msg_error:nnxxx { xtemplate } { choice-requires-code }
+      { \l_@@_key_name_tl } {#1}
+  }
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
@@ -2629,6 +2637,13 @@
     each~choice~name~must~have~an~associated~implementation.\\
     This~should~be~given~after~a~'='~sign:~LaTeX~did~not~find~one.
   }
+\msg_new:nnnn { xtemplate } { choice-requires-code }
+  { The~choice~'#2'~for~key~'#1'~requires~an~implementation. }
+  {
+    You~should~have~put:\\
+    \ \ #1~:~choice~{~#2 = <code> ~} \\
+    but~LaTeX~did~not~find~any~<code>.
+  }
 \msg_new:nnnn { xtemplate } { duplicate-key-interface }
   { Key~'#1'~appears~twice~in~interface~definition~\msg_line_context:. }
   {





More information about the latex3-commits mailing list.