[latex3-commits] [git/LaTeX3-latex3-latex3] main: Avoid showing internals in \keys_show:nn (022f116c9)

Joseph Wright joseph.wright at morningstar2.co.uk
Tue Mar 8 22:36:14 CET 2022


Repository : https://github.com/latex3/latex3
On branch  : main
Link       : https://github.com/latex3/latex3/commit/022f116c9a0733d527b73a990cadd1a18db23908

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

commit 022f116c9a0733d527b73a990cadd1a18db23908
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Tue Mar 8 21:35:20 2022 +0000

    Avoid showing internals in \keys_show:nn


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

022f116c9a0733d527b73a990cadd1a18db23908
 l3kernel/l3keys.dtx                     | 75 +++++++++++++++++++++++++--------
 l3kernel/testfiles/m3keys004.tlg        |  6 +--
 l3kernel/testfiles/m3show002.luatex.tlg |  6 +--
 l3kernel/testfiles/m3show002.tlg        |  6 +--
 l3kernel/testfiles/m3show003.tlg        |  6 +--
 5 files changed, 66 insertions(+), 33 deletions(-)

diff --git a/l3kernel/l3keys.dtx b/l3kernel/l3keys.dtx
index f48b9e9b5..901ae2532 100644
--- a/l3kernel/l3keys.dtx
+++ b/l3kernel/l3keys.dtx
@@ -1714,6 +1714,19 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\@@_precompile:n}
+%   An auxiliary to allow cleaner showing of code.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_precompile:n #1
+  {
+    \bool_if:NTF \l_@@_precompile_bool
+      { \tl_put_right:Nn \l_@@_precompile_tl }
+      { \use:n }
+        {#1}
+  }
+%    \end{macrocode}
+% \end{macro}
+%
 % \subsection{The key defining mechanism}
 %
 % \begin{macro}{\keys_define:nn}
@@ -1980,15 +1993,7 @@
 %   defining a new key, then saves the code.
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_cmd_set:nn #1#2
-  {
-    \@@_cmd_set_direct:nn {#1}
-      {
-        \bool_if:NTF \l_@@_precompile_bool
-          { \tl_put_right:Nn \l_@@_precompile_tl }
-          { \use:n }
-            {#2}
-      }
-  }
+  {  \@@_cmd_set_direct:nn {#1} { \@@_precompile:n {#2} } }
 \cs_generate_variant:Nn \@@_cmd_set:nn { nx , Vn , Vo }
 \cs_new_protected:Npn \@@_cmd_set_direct:nn #1#2
   { \cs_set_protected:cpn { \c_@@_code_root_str #1 } ##1 {#2} }
@@ -2004,10 +2009,8 @@
   {
     \cs_set_protected:cpx { \c_@@_code_root_str \l_keys_path_str } ##1
       {
-        \exp_not:N \bool_if:NTF \exp_not:N \l_@@_precompile_bool
-          { \tl_put_right:Nn \exp_not:N \l_@@_precompile_tl }
-          { \exp_not:N \use:n }
-            { #1 \exp_not:N #2 \exp_not:n {#3} {##1} }
+        \@@_precompile:n
+          { #1 \exp_not:N #2 \exp_not:n {#3} {##1} }
       }
     \use_none:n
   }
@@ -3435,7 +3438,11 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\keys_show:nn, \keys_log:nn, \@@_show:Nnn}
+% \begin{macro}{\keys_show:nn, \keys_log:nn}
+% \begin{macro}{\@@_show:Nnn}
+% \begin{macro}{\@@_show:n}
+% \begin{macro}{\@@_show:w}
+% \begin{macro}{\@@_show:Nw}
 %   To show a key, show its code using a message.
 %    \begin{macrocode}
 \cs_new_protected:Npn \keys_show:nn
@@ -3451,18 +3458,52 @@
           {
             \exp_args:Nnf \msg_show_item_unbraced:nn { code }
               {
-                \exp_args:Nc \cs_replacement_spec:N
+                \exp_args:Ne \@@_show:n
                   {
-                    \c_@@_code_root_str
-                    \@@_trim_spaces:n { #2 / #3 }
+                    \exp_args:Nc \cs_replacement_spec:N
+                    {
+                      \c_@@_code_root_str
+                      \@@_trim_spaces:n { #2 / #3 }
+                    }
                   }
               }
           }
       }
       { } { }
   }
+\cs_new:Npx \@@_show:n #1
+  {
+    \exp_not:N \@@_show:w
+      #1
+      \tl_to_str:n { \@@_precompile:n }
+      #1
+      \tl_to_str:n { \@@_precompile:n }
+      \exp_not:N \s_@@_stop
+  }
+\use:x
+  {
+    \cs_new:Npn \exp_not:N \@@_show:w
+      ##1 \tl_to_str:n { \@@_precompile:n }
+      ##2 \tl_to_str:n { \@@_precompile:n }
+      ##3 \exp_not:N \s_@@_stop
+  }
+  {
+    \tl_if_blank:nTF {#2}
+      {#1}
+      { \@@_show:Nw #2 \s_@@_stop }
+  }
+\use:x
+  {
+    \cs_new:Npn \exp_not:N \@@_show:Nw ##1##2
+      \c_right_brace_str \exp_not:N \s_@@_stop
+  }
+  {#2}
 %    \end{macrocode}
 % \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
 %
 % \subsection{Messages}
 %
diff --git a/l3kernel/testfiles/m3keys004.tlg b/l3kernel/testfiles/m3keys004.tlg
index 33493b0c3..ab1a45c19 100644
--- a/l3kernel/testfiles/m3keys004.tlg
+++ b/l3kernel/testfiles/m3keys004.tlg
@@ -187,13 +187,11 @@ FALSE
 TEST 11: \keys_show:nn 
 ============================================================
 The key module/key-one has the properties:
->  code  =>  \bool_if:NTF \l__keys_precompile_bool {\tl_put_right:Nn
-\l__keys_precompile_tl }{\use:n }{\TYPE {"#1"}}.
+>  code  =>  \TYPE {"#1"}.
 <recently read> }
 l. ...  }
 The key module/key-two has the properties:
->  code  =>  \bool_if:NTF \l__keys_precompile_bool {\tl_put_right:Nn
-\l__keys_precompile_tl }{\use:n }{\tl_set:Nn \l_tmpa_tl {#1}}.
+>  code  =>  \tl_set:Nn \l_tmpa_tl {#1}.
 <recently read> }
 l. ...  }
 The key module/key-three is undefined.
diff --git a/l3kernel/testfiles/m3show002.luatex.tlg b/l3kernel/testfiles/m3show002.luatex.tlg
index dfe9b0130..50d79103b 100644
--- a/l3kernel/testfiles/m3show002.luatex.tlg
+++ b/l3kernel/testfiles/m3show002.luatex.tlg
@@ -177,11 +177,9 @@ l. ...  }
 TEST 7: KEYS
 ============================================================
 The key test/text has the properties:
->  code  =>  \bool_if:NTF \l__keys_precompile_bool {\tl_put_right:Nn
-\l__keys_precompile_tl }{\use:n }{\tl_set:Nn \l_tmpa_tl {#1}}.
+>  code  =>  \tl_set:Nn \l_tmpa_tl {#1}.
 The key test/expanded has the properties:
->  code  =>  \bool_if:NTF \l__keys_precompile_bool {\tl_put_right:Nn
-\l__keys_precompile_tl }{\use:n }{\tl_gset:Nx \l_tmpb_tl {#1}}.
+>  code  =>  \tl_gset:Nx \l_tmpb_tl {#1}.
 ============================================================
 ============================================================
 TEST 8: CHAR
diff --git a/l3kernel/testfiles/m3show002.tlg b/l3kernel/testfiles/m3show002.tlg
index 56060dff7..3c217bc1d 100644
--- a/l3kernel/testfiles/m3show002.tlg
+++ b/l3kernel/testfiles/m3show002.tlg
@@ -177,11 +177,9 @@ l. ...  }
 TEST 7: KEYS
 ============================================================
 The key test/text has the properties:
->  code  =>  \bool_if:NTF \l__keys_precompile_bool {\tl_put_right:Nn
-\l__keys_precompile_tl }{\use:n }{\tl_set:Nn \l_tmpa_tl {#1}}.
+>  code  =>  \tl_set:Nn \l_tmpa_tl {#1}.
 The key test/expanded has the properties:
->  code  =>  \bool_if:NTF \l__keys_precompile_bool {\tl_put_right:Nn
-\l__keys_precompile_tl }{\use:n }{\tl_gset:Nx \l_tmpb_tl {#1}}.
+>  code  =>  \tl_gset:Nx \l_tmpb_tl {#1}.
 ============================================================
 ============================================================
 TEST 8: CHAR
diff --git a/l3kernel/testfiles/m3show003.tlg b/l3kernel/testfiles/m3show003.tlg
index 3d8be9f88..36e5ffab2 100644
--- a/l3kernel/testfiles/m3show003.tlg
+++ b/l3kernel/testfiles/m3show003.tlg
@@ -156,11 +156,9 @@ The following output streams are in use:
 TEST 9: keys
 ============================================================
 The key test/text has the properties:
->  code  =>  \bool_if:NTF \l__keys_precompile_bool {\tl_put_right:Nn
-\l__keys_precompile_tl }{\use:n }{\tl_set:Nn \l_tmpa_tl {#1}}.
+>  code  =>  \tl_set:Nn \l_tmpa_tl {#1}.
 The key test/expanded has the properties:
->  code  =>  \bool_if:NTF \l__keys_precompile_bool {\tl_put_right:Nn
-\l__keys_precompile_tl }{\use:n }{\tl_gset:Nx \l_tmpb_tl {#1}}.
+>  code  =>  \tl_gset:Nx \l_tmpb_tl {#1}.
 ============================================================
 ============================================================
 TEST 10: muskip





More information about the latex3-commits mailing list.