[latex3-commits] [git/LaTeX3-latex3-latex3] main: Simplify handling of \protect (44104cf92)

Joseph Wright joseph.wright at morningstar2.co.uk
Fri Apr 8 10:53:23 CEST 2022


Repository : https://github.com/latex3/latex3
On branch  : main
Link       : https://github.com/latex3/latex3/commit/44104cf9269ca30c955ea8f1d4decded97e0a46b

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

commit 44104cf9269ca30c955ea8f1d4decded97e0a46b
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Fri Apr 8 09:53:23 2022 +0100

    Simplify handling of \protect
    
    As we always want to keep it, and as \protect\foo is likely
    OK, we simply store it in all cases.


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

44104cf9269ca30c955ea8f1d4decded97e0a46b
 l3kernel/l3text.dtx | 51 ++++++---------------------------------------------
 1 file changed, 6 insertions(+), 45 deletions(-)

diff --git a/l3kernel/l3text.dtx b/l3kernel/l3text.dtx
index 56c42562c..962021bce 100644
--- a/l3kernel/l3text.dtx
+++ b/l3kernel/l3text.dtx
@@ -634,9 +634,6 @@
 % \begin{macro}[EXP]{\@@_expand_letterlike:NN}
 % \begin{macro}[EXP]{\@@_expand_cs:N, \@@_expand_encoding:N}
 % \begin{macro}[EXP]{\@@_expand_encoding_escape:N}
-% \begin{macro}[EXP]{\@@_expand_protect:N}
-% \begin{macro}[EXP]{\@@_expand_protect:nN}
-% \begin{macro}[EXP]{\@@_expand_protect:Nw}
 % \begin{macro}[EXP]{\@@_expand_testopt:N}
 % \begin{macro}[EXP]{\@@_expand_testopt:NNn}
 % \begin{macro}[EXP]{\@@_expand_replace:N}
@@ -945,17 +942,17 @@
       { \@@_expand_letterlike:NN #1 }
   }
 %    \end{macrocode}
-%   \LaTeXe{}'s \cs{protect} makes life interesting. Where possible, we
-%   simply remove it and replace with the \enquote{parent} command; of course,
-%   the \cs{protect} might be explicit, in which case we need to leave it alone.
-%   That includes the case where it's not even followed by an \texttt{N}-type
-%   token. There is also the case of a straight \tn{@protected at testopt} to
+%   \LaTeXe{}'s \cs{protect} needs to be filtered out specifically.
+%   There is also the case of a straight \tn{@protected at testopt} to
 %   cover.
 %    \begin{macrocode}
 \cs_new:Npx \@@_expand_cs:N #1
   {
     \exp_not:N \str_if_eq:nnTF {#1} { \exp_not:N \protect }
-      { \exp_not:N \@@_expand_protect:w }
+      {
+        \exp_not:N \@@_expand_store:n { \exp_not:N \protect }
+        \exp_not:N \@@_expand_end:w
+      }
       {
         \bool_lazy_and:nnTF
           { \cs_if_exist_p:N \fmtname }
@@ -964,39 +961,6 @@
           { \exp_not:N \@@_expand_replace:N #1 }
       }
   }
-\cs_new:Npn \@@_expand_protect:w #1 \q_@@_recursion_stop
-  {
-    \tl_if_head_is_N_type:nTF {#1}
-      { \@@_expand_protect:N }
-      {
-        \@@_expand_store:n { \protect }
-        \@@_expand_loop:w
-      }
-        #1 \q_@@_recursion_stop
-  }
-\cs_new:Npn \@@_expand_protect:N #1
-  {
-    \@@_if_recursion_tail_stop_do:Nn #1
-      {
-        \@@_expand_store:n { \protect }
-        \@@_expand_end:w
-      }
-    \exp_args:Ne \@@_expand_protect:nN
-      { \cs_to_str:N #1 } #1
-  }
-\cs_new:Npn \@@_expand_protect:nN #1#2
-  { \@@_expand_protect:Nw #2 #1 \q_@@_nil #1 ~ \q_@@_nil \q_@@_nil \s_@@_stop }
-\cs_new:Npn \@@_expand_protect:Nw #1 #2 ~ \q_@@_nil #3 \q_@@_nil #4 \s_@@_stop
-  {
-    \@@_quark_if_nil:nTF {#4}
-      {
-        \cs_if_exist:cTF {#2}
-          { \exp_args:Ne \@@_expand_store:n { \exp_not:c {#2} } }
-          { \@@_expand_store:n { \protect #1 } }
-      }
-      { \@@_expand_store:n { \protect #1 } }
-    \@@_expand_loop:w
-  }
 \cs_new:Npn \@@_expand_testopt:N #1
   {
     \token_if_eq_meaning:NNTF #1 \@protected at testopt
@@ -1135,9 +1099,6 @@
 % \end{macro}
 % \end{macro}
 % \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
 %
 % \begin{macro}
 %   {





More information about the latex3-commits mailing list.