[latex3-commits] [git/LaTeX3-latex3-latex2e] gh569: Set up end environment code outside of the environment macro (6ab19a43)

PhelypeOleinik phelype.oleinik at latex-project.org
Mon Aug 30 01:23:12 CEST 2021


Repository : https://github.com/latex3/latex2e
On branch  : gh569
Link       : https://github.com/latex3/latex2e/commit/6ab19a43cba4eca0791cf974f10a5a600f19e3e4

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

commit 6ab19a43cba4eca0791cf974f10a5a600f19e3e4
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date:   Sun Aug 29 20:23:12 2021 -0300

    Set up end environment code outside of the environment macro


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

6ab19a43cba4eca0791cf974f10a5a600f19e3e4
 base/ltcmd.dtx                    | 28 +++++++++++++++-------------
 base/testfiles-ltcmd/ltcmd001.tlg | 20 +++++---------------
 base/testfiles-ltcmd/ltcmd004.lvt |  0
 3 files changed, 20 insertions(+), 28 deletions(-)

diff --git a/base/ltcmd.dtx b/base/ltcmd.dtx
index 78d2b463..fb0b5877 100644
--- a/base/ltcmd.dtx
+++ b/base/ltcmd.dtx
@@ -343,8 +343,7 @@
 %
 % \begin{macro}{\@@_declare_cmd:Nnn, \@@_declare_expandable_cmd:Nnn}
 % \begin{macro}{\@@_declare_cmd_aux:Nnn}
-% \begin{macro}
-%   {\@@_declare_cmd_internal:Nnnn, \@@_declare_cmd_internal:cnxn}
+% \begin{macro}{\@@_declare_cmd_internal:Nnnn}
 %   The main functions for creating commands set the appropriate flag then
 %   use the same internal code to do the definition.
 %    \begin{macrocode}
@@ -400,7 +399,6 @@
     #4
     \@@_break_point:n {#2}
   }
-\cs_generate_variant:Nn \@@_declare_cmd_internal:Nnnn { cnx }
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
@@ -565,15 +563,8 @@
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_declare_env_internal:nnnn #1#2#3#4
   {
-    \@@_declare_cmd_internal:cnxn { environment~ #1 } {#2}
-      {
-        \cs_set_nopar:Npx \exp_not:c { environment~ #1 ~end~aux }
-          {
-            \exp_not:N \exp_not:N \exp_not:c { environment~ #1~end~aux~ }
-            \exp_not:n { \exp_not:o \l_@@_args_tl }
-          }
-        \exp_not:n {#3}
-      }
+    \exp_args:Nc \@@_declare_cmd_internal:Nnnn { environment~ #1 } {#2}
+      {#3}
       {
         \cs_set_nopar:cpx { environment~ #1 ~end }
           { \exp_not:c { environment~ #1 ~end~aux } }
@@ -584,6 +575,14 @@
         \cs_set_eq:cc { end #1 } { environment~ #1 ~end }
       }
   }
+\cs_new_protected:Npn \@@_set_environment_end:n #1
+  {
+    \cs_set_nopar:cpx { environment~ #1 ~end~aux }
+      {
+        \exp_not:c { environment~ #1 ~end~aux~ }
+        \exp_not:o \l_@@_args_tl
+      }
+  }
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
@@ -639,7 +638,10 @@
     \tl_set:Nn \l_@@_fn_code_tl {#2}
     \tl_set:Nn \l_@@_defaults_tl {#5}
     \tl_set:Nn \l_@@_process_all_tl {#6}
-    #4 \@@_run_code:
+    #4
+    \bool_if:NT \l_@@_environment_bool
+      { \exp_args:No \@@_set_environment_end:n \l_@@_environment_str }
+    \@@_run_code:
   }
 \cs_generate_variant:Nn \@@_start_aux:NNnnnn { cc }
 %    \end{macrocode}
diff --git a/base/testfiles-ltcmd/ltcmd001.tlg b/base/testfiles-ltcmd/ltcmd001.tlg
index 8f4614ea..7548918c 100644
--- a/base/testfiles-ltcmd/ltcmd001.tlg
+++ b/base/testfiles-ltcmd/ltcmd001.tlg
@@ -471,9 +471,7 @@ LaTeX will ignore this entire definition.
 > \environment foo=\protected macro:->\__cmd_start_env:nnnnn {}{foo}{}{}{}.
 <recently read> }
 l. ...}
-> \environment foo code=\protected\long macro:->\cs_set_nopar:Npx \environment
-foo end aux {\exp_not:N \environment foo end aux  \exp_not:o \l__cmd_args_tl
-}First.
+> \environment foo code=\protected\long macro:->First.
 <recently read> }
 l. ...}
 ============================================================
@@ -484,36 +482,28 @@ TEST 11: Valid environment declarations
 {mmm}{foo}{\__cmd_grab_m_3:w }{}{}.
 <recently read> }
 l. ...}
-> \environment foo code=\protected\long macro:#1#2#3->\cs_set_nopar:Npx
-\environment foo end aux {\exp_not:N \environment foo end aux  \exp_not:o
-\l__cmd_args_tl }(#1)(#2)(#3).
+> \environment foo code=\protected\long macro:#1#2#3->(#1)(#2)(#3).
 <recently read> }
 l. ...}
 > \environment foo=\protected macro:->\__cmd_start_env:nnnnn
 {som}{foo}{\__cmd_grab_t:w *\__cmd_grab_D:w []\__cmd_grab_m_1:w }{}{}.
 <recently read> }
 l. ...}
-> \environment foo code=\protected\long macro:#1#2#3->\cs_set_nopar:Npx
-\environment foo end aux {\exp_not:N \environment foo end aux  \exp_not:o
-\l__cmd_args_tl }(#1)(#2)(#3).
+> \environment foo code=\protected\long macro:#1#2#3->(#1)(#2)(#3).
 <recently read> }
 l. ...}
 > \environment foo=\protected macro:->\__cmd_start_env:nnnnn
 {so+m}{foo}{\__cmd_grab_t:w *\__cmd_grab_D:w []\__cmd_grab_m_long:w }{}{}.
 <recently read> }
 l. ...}
-> \environment foo code=\protected\long macro:#1#2#3->\cs_set_nopar:Npx
-\environment foo end aux {\exp_not:N \environment foo end aux  \exp_not:o
-\l__cmd_args_tl }(#1)(#2)(#3).
+> \environment foo code=\protected\long macro:#1#2#3->(#1)(#2)(#3).
 <recently read> }
 l. ...}
 > \environment foo=\protected macro:->\__cmd_start_env:nnnnn
 {moo}{foo}{\__cmd_grab_m_1:w \__cmd_grab_D:w []\__cmd_grab_D:w []}{}{}.
 <recently read> }
 l. ...}
-> \environment foo code=\protected\long macro:#1#2#3->\cs_set_nopar:Npx
-\environment foo end aux {\exp_not:N \environment foo end aux  \exp_not:o
-\l__cmd_args_tl }(#1)(#2)(#3).
+> \environment foo code=\protected\long macro:#1#2#3->(#1)(#2)(#3).
 <recently read> }
 l. ...}
 ============================================================





More information about the latex3-commits mailing list.