[latex3-commits] [git/LaTeX3-latex3-latex2e] gh569: Copying \begin part of environments done (80e9f1ec)

PhelypeOleinik phelype.oleinik at latex-project.org
Sun Aug 29 05:11:10 CEST 2021


Repository : https://github.com/latex3/latex2e
On branch  : gh569
Link       : https://github.com/latex3/latex2e/commit/80e9f1ec57cb1c9d03bfe40edb3654992d171993

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

commit 80e9f1ec57cb1c9d03bfe40edb3654992d171993
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date:   Sun Aug 29 00:11:10 2021 -0300

    Copying \begin part of environments done
    
    hopefully


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

80e9f1ec57cb1c9d03bfe40edb3654992d171993
 base/ltcmd.dtx | 88 ++++++++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 71 insertions(+), 17 deletions(-)

diff --git a/base/ltcmd.dtx b/base/ltcmd.dtx
index fbe8d924..2521a084 100644
--- a/base/ltcmd.dtx
+++ b/base/ltcmd.dtx
@@ -1951,7 +1951,7 @@
 % \begin{macro}{\@@_copy:NN}
 % \begin{macro}{\@@_set_eq_if_exist:NN,\@@_set_eq_if_exist:cc}
 %   This macro just branches to the proper copying command by using
-%   \cs{@@_cmd_type_cases:NnnnF}.  The copying command takes the names
+%   \cs{@@_cmd_type_cases:NnnnnF}.  The copying command takes the names
 %   of the commands to be copied to and from, and the actual commands
 %   as its four arguments.
 %    \begin{macrocode}
@@ -1960,10 +1960,11 @@
     \use:x
       {
         \int_set:Nn \tex_escapechar:D { 92 }
-        \exp_not:N \@@_cmd_type_cases:NnnnF \exp_not:N #2
+        \exp_not:N \@@_cmd_type_cases:NnnnnF \exp_not:N #2
           { \@@_copy_command:nnNN }
           { \@@_copy_expandable:nnNN }
-          { \@@_copy_environment:nnNN }
+          { \@@_copy_env:nnNN }
+          { \@@_copy_env_end:nnNN }
           { \@@_cant_copy:nwn { non-ltcmd } }
             { \cs_to_str:N #1 } { \cs_to_str:N #2 }
             \exp_not:N #1 \exp_not:N #2
@@ -2195,9 +2196,54 @@
 % \end{macro}
 % \end{macro}
 %
-% \begin{macro}{\@@_copy_environment:nnNN}
+% \begin{macro}{\@@_copy_env:nnNN}
 %    \begin{macrocode}
-\cs_new_protected:Npn \@@_copy_environment:nnNN #1 #2 #3 #4
+\cs_new_protected:Npn \@@_copy_env:nnNN #1 #2 #3 #4
+  {
+    \@@_set_eq_if_exist:cc { #1 ~ defaults } { #2 ~ defaults }
+    \exp_after:wN \@@_copy_env:NnnnnnnN #4 {#1} #3
+  }
+\cs_new_protected:Npn \@@_copy_env:NnnnnnnN #1 #2 #3 #4 #5 #6 #7 #8
+  {
+    \cs_set_protected_nopar:Npn #8 { #1 {#2} {#7} {#4} {#5} {#6} }
+    \@@_split_signature:n {#2}
+    \cs_generate_from_arg_count:cNnn { #7 ~ code }
+      \cs_set_protected:Npx { \l_@@_current_arg_int - 1 }
+        {
+          \cs_set_nopar:Npx \exp_not:c { environment~ #7 ~end~aux }
+            {
+              \exp_not:N \exp_not:N
+              \exp_not:c { environment~ #7 ~end~aux~ }
+              \exp_not:n { \exp_not:o \l_@@_args_tl }
+            }
+          \exp_args:NNo \exp_args:No \exp_not:o
+            {
+              \exp_after:wN \exp_after:wN
+              \exp_after:wN \use_none:nnn
+              \cs:w environment~ #3 ~ code
+                \exp_after:wN \@@_make_parm_aux:w
+                \int_value:w \int_eval:n { \l_@@_current_arg_int - 1 } ;
+            }
+        }
+    % #1: \__cmd_start_env:nnnnn
+    % #2: {+b}
+    % #3: {foo} % old name
+    % #4: {\__cmd_grab_b_long:w }
+    % #5: {} % defaults
+    % #6: {} % processors
+    % #7: new name
+    % #8: new cs
+  }
+\cs_new:Npn \@@_make_parm_aux:w #1 ;
+  {
+    \int_compare:nNnTF {#1} = { 0 }
+      { \cs_end: }
+      {
+        \exp_after:wN \@@_make_parm_aux:w
+          \int_value:w \int_eval:n { #1 - 1 } ; { ## #1 }
+      }
+  }
+\cs_new_protected:Npn \@@_copy_env_end:nnNN #1 #2 #3 #4
   { \msg_error:nn { cmd } { env-copy } }
 \msg_new:nnn { cmd } { env-copy }
   { Copying~environments~is~not~possible. }
@@ -2226,7 +2272,7 @@
 %
 % \begin{macro}{\@@_show:N}
 %   This macro just branches to the proper showing command by using
-%   \cs{@@_cmd_type_cases:NnnnF}.  The showing command takes the command
+%   \cs{@@_cmd_type_cases:NnnnnF}.  The showing command takes the command
 %   to be shown as argument.
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_show:N #1
@@ -2234,10 +2280,11 @@
     \use:x
       {
         \int_set:Nn \tex_escapechar:D { 92 }
-        \exp_not:N \@@_cmd_type_cases:NnnnF \exp_not:N #1
+        \exp_not:N \@@_cmd_type_cases:NnnnnF \exp_not:N #1
           { \@@_show_command:N }
           { \@@_show_expandable:N }
-          { \@@_show_environment:N }
+          { \@@_show_env:N }
+          { \@@_show_env_end:N }
           { \@@_cant_copy:nwn { non-ltcmd } }
             \exp_not:N #1
         \exp_not:N \@@_break_point:n { \cs_to_str:N #1 }
@@ -2253,7 +2300,7 @@
 %     \@@_show_expandable:N,
 %     \@@_show_expandable:NnNNNNnN,
 %     \@@_show_command_aux:nNNn,
-%     \@@_show_environment:N,
+%     \@@_show_env:N,
 %   }
 %   These commands just expand the command once to reveal its innards,
 %   then pass the type of command, the control sequence, the signature,
@@ -2287,7 +2334,9 @@
 %
 %   But complain when used with an environment:
 %    \begin{macrocode}
-\cs_new_protected:Npn \@@_show_environment:N #1
+\cs_new_protected:Npn \@@_show_env:N #1
+  { \msg_error:nn { cmd } { env-show } }
+\cs_new_protected:Npn \@@_show_env_end:N #1
   { \msg_error:nn { cmd } { env-show } }
 \msg_new:nnn { cmd } { env-show }
   { Showing~environments~is~not~possible. }
@@ -3983,10 +4032,10 @@
 % \end{macro}
 %
 % \begin{macro}{\__kernel_cmd_if_xparse:NTF}
-% \begin{macro}{\@@_cmd_type_cases:Nnnn}
+% \begin{macro}{\@@_cmd_type_cases:Nnnnn}
 % \changes{v1.0d}{2021/04/19}{Renamed \cs{__cmd_cmd_if_xparse:NTF} to
 %      \cs{__kernel_cmd_if_xparse:NTF} for cross-module usage}
-% \changes{v1.0d}{2021/07/30}{Added \cs{@@_cmd_type_cases:Nnnn} for
+% \changes{v1.0d}{2021/07/30}{Added \cs{@@_cmd_type_cases:Nnnnn} for
 %      \cs{NewCommandCopy} and \cs{ShowCommand} support}
 % \begin{macro}{\@@_cmd_if_xparse_aux:N}
 %
@@ -3995,12 +4044,13 @@
 %    that its |replacement_spec| starts with either
 %    \cs{@@_start:nNNnnn} (non-expandable command) or
 %    \cs{@@_start_expandable:nNNNNn} (expandable command) or
-%    \cs{@@_start_env:nnnnn} (environment).
+%    \cs{@@_start_env:nnnnn} (environment) or
+%    \cs[no-index]{environment~#1~end~aux} (environment end).
 %
 %    This conditional is needed in several kernel modules and is
 %    therefore has a kernel-internal name.
 %    \begin{macrocode}
-\cs_new_protected:Npn \@@_cmd_type_cases:NnnnF #1 #2 #3 #4 #5
+\cs_new_protected:Npn \@@_cmd_type_cases:NnnnnF #1 #2 #3 #4 #5 #6
   {
     \str_case_e:nnF
       {
@@ -4014,14 +4064,18 @@
         { \token_to_str:N \@@_start:nNNnnn } {#2}
         { \token_to_str:N \@@_start_expandable:nNNNNn } {#3}
         { \token_to_str:N \@@_start_env:nnnnn } {#4}
+        {
+          \exp_after:wN \token_to_str:N
+            \cs:w environment~ \cs_to_str:N #1 ~end~aux \cs_end:
+        } {#5}
       }
-      {#5}
+      {#6}
   }
 \cs_new:Npn \@@_cmd_if_xparse_aux:w #1 ~ #2 \q_stop {#1}
 \cs_new_protected:Npn \__kernel_cmd_if_xparse:NTF #1
   {
-    \@@_cmd_type_cases:NnnnF #1
-      { } { } { } { \use_iii:nnn }
+    \@@_cmd_type_cases:NnnnnF #1
+      { } { } { } { } { \use_iii:nnn }
     \use_i:nn
   }
 %    \end{macrocode}





More information about the latex3-commits mailing list.