[latex3-commits] [latex3/latex3] conditional-forms: Auto-generate variants for all forms of conditionals (6fed29286)

github at latex-project.org github at latex-project.org
Mon Nov 25 09:54:39 CET 2024


Repository : https://github.com/latex3/latex3
On branch  : conditional-forms
Link       : https://github.com/latex3/latex3/commit/6fed29286be8e0bb73a189cc8241a0ae5d729372

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

commit 6fed29286be8e0bb73a189cc8241a0ae5d729372
Author: Joseph Wright <joseph at texdev.net>
Date:   Wed Nov 20 09:02:13 2024 +0000

    Auto-generate variants for all forms of conditionals


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

6fed29286be8e0bb73a189cc8241a0ae5d729372
 l3kernel/l3expan.dtx | 16 ++++++++++++----
 l3kernel/l3prg.dtx   |  9 +++++----
 2 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/l3kernel/l3expan.dtx b/l3kernel/l3expan.dtx
index 3ca2c517b..b0b8ca1e3 100644
--- a/l3kernel/l3expan.dtx
+++ b/l3kernel/l3expan.dtx
@@ -2197,6 +2197,7 @@
 %   {
 %     \prg_generate_conditional_variant:Nnn,
 %     \@@_generate_variant:nnNnn,
+%     \@@_generate_variant:nnnNn,
 %     \@@_generate_variant:w,
 %     \@@_generate_variant:n,
 %     \@@_generate_variant_p_form:nnn,
@@ -2215,14 +2216,21 @@
   }
 \cs_new_protected:Npn \@@_generate_variant:nnNnn #1#2#3#4#5
   {
-    \if_meaning:w \c_false_bool #3
+    \cs_if_exist:cTF { #1 _p : #2 }
+      { \@@_generate_variant:nnnNn { T , F , TF , p } }
+      { \@@_generate_variant:nnnNn { T , F , TF } }
+       {#1} {#2} #3 {#4}
+  }
+\cs_new_protected:Npn \@@_generate_variant:nnnNn #1#2#3#4#5
+  {
+    \if_meaning:w \c_false_bool #4
       \msg_error:nne { kernel } { missing-colon }
-        { \token_to_str:c {#1} }
+        { \token_to_str:c {#2} }
       \@@_use_i_delimit_by_s_stop:nw
     \fi:
     \exp_after:wN \@@_generate_variant:w
-    \tl_to_str:n {#5} , \scan_stop: , \q_@@_recursion_stop
-    \@@_use_none_delimit_by_s_stop:w \s_@@_mark {#1} {#2} {#4} \s_@@_stop
+    \tl_to_str:n {#1} , \scan_stop: , \q_@@_recursion_stop
+    \@@_use_none_delimit_by_s_stop:w \s_@@_mark {#2} {#3} {#5} \s_@@_stop
   }
 \cs_new_protected:Npn \@@_generate_variant:w
     #1 , #2 \s_@@_mark #3#4#5
diff --git a/l3kernel/l3prg.dtx b/l3kernel/l3prg.dtx
index eb1da372f..4887764ca 100644
--- a/l3kernel/l3prg.dtx
+++ b/l3kernel/l3prg.dtx
@@ -210,17 +210,18 @@
 %   the expansion of the conditional code. This includes other instances of either of these functions.
 % \end{function}
 %
-% \begin{function}[added = 2017-12-12]{\prg_generate_conditional_variant:Nnn}
+% \begin{function}[added = 2024-11-20]{\prg_generate_conditional_variant:Nnn}
 %   \begin{syntax}
 %     \cs{prg_generate_conditional_variant:Nnn} \cs[no-index]{\meta{name}:\meta{arg spec}} \Arg{variant argument specifiers} \Arg{condition specifiers}
 %   \end{syntax}
 %   Defines argument-specifier variants of conditionals.  This is
 %   equivalent to running \cs{cs_generate_variant:Nn} \meta{conditional}
-%   \Arg{variant argument specifiers} on each \meta{conditional}
-%   described by the \meta{condition specifiers}.  These base-form
+%   \Arg{variant argument specifiers} on each \meta{conditional}:
+%   |T|, |F|, |TF| and if appropriate |p|.  These base-form
 %   \meta{conditionals} are obtained from the \meta{name} and \meta{arg
 %   spec} as described for \cs{prg_new_conditional:Npnn}, and they
-%   should be defined.
+%   should be defined. The \meta{conditions} argument is purely a
+%   reminder to the programmer.
 % \end{function}
 %
 % \section{The boolean data type}





More information about the latex3-commits mailing list.