[latex3-commits] [git/LaTeX3-latex3-latex3] main: Better support for \text_case_switch:nnnn expansion (0fb21d2a6)

Joseph Wright joseph.wright at morningstar2.co.uk
Thu Jul 14 11:06:25 CEST 2022


Repository : https://github.com/latex3/latex3
On branch  : main
Link       : https://github.com/latex3/latex3/commit/0fb21d2a6051ae16ac99696110da62469b6e13fd

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

commit 0fb21d2a6051ae16ac99696110da62469b6e13fd
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Thu Jul 14 10:06:25 2022 +0100

    Better support for \text_case_switch:nnnn expansion


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

0fb21d2a6051ae16ac99696110da62469b6e13fd
 l3kernel/CHANGELOG.md |  3 +++
 l3kernel/l3text.dtx   | 22 ++++++++++++++++------
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index dd76907ac..90d0a84bb 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -7,6 +7,9 @@ this project uses date-based 'snapshot' version identifiers.
 
 ## [Unreleased]
 
+### Changed
+- Improved approach to `\text_case_switch:nnnn` expansion
+
 ## [2022-07-04]
 
 ### Added
diff --git a/l3kernel/l3text.dtx b/l3kernel/l3text.dtx
index 45ed617bd..f46a42d5d 100644
--- a/l3kernel/l3text.dtx
+++ b/l3kernel/l3text.dtx
@@ -701,6 +701,7 @@
 %     \@@_expand_explicit:N ,
 %     \@@_expand_exclude:N
 %   }
+% \begin{macro}[EXP]{\@@_expand_exclude_switch:Nnnnn}
 % \begin{macro}[EXP]{\@@_expand_exclude:nN}
 % \begin{macro}[EXP]{\@@_expand_exclude:NN}
 % \begin{macro}[EXP]{\@@_expand_exclude:Nw}
@@ -960,17 +961,26 @@
   }
 %    \end{macrocode}
 %   Next we exclude math commands: this is mainly as there \emph{might} be an
-%   \cs{ensuremath}.
+%   \cs{ensuremath}. The switching command for case needs special handling
+%   as it has to work by meaning.
 %    \begin{macrocode}
 \cs_new:Npn \@@_expand_exclude:N #1
   {
-    \exp_args:Ne \@@_expand_exclude:nN
+    \cs_if_eq:NNTF #1 \text_case_switch:nnnn
+      { \@@_expand_exclude_switch:Nnnnn #1 }
       {
-        \exp_not:V \l_text_math_arg_tl
-        \exp_not:V \l_text_expand_exclude_tl
-        \exp_not:N \text_case_switch:nnnn
+        \exp_args:Ne \@@_expand_exclude:nN
+          {
+            \exp_not:V \l_text_math_arg_tl
+            \exp_not:V \l_text_expand_exclude_tl
+          }
+        #1
       }
-    #1
+  }
+\cs_new:Npn \@@_expand_exclude_switch:Nnnnn #1#2#3#4#5
+  {
+    \@@_expand_store:n { #1 {#2} {#3} {#4} {#5} }
+    \@@_expand_loop:w
   }
 \cs_new:Npn \@@_expand_exclude:nN #1#2
   {





More information about the latex3-commits mailing list.