[latex3-commits] [git/LaTeX3-latex3-latex3] gh241-show-log: Implement tl_log_analysis to complement the show function (see #241) (e1c695e81)

Joseph Wright joseph.wright at morningstar2.co.uk
Wed May 12 14:26:25 CEST 2021


Repository : https://github.com/latex3/latex3
On branch  : gh241-show-log
Link       : https://github.com/latex3/latex3/commit/e1c695e8125aae1d6c845d44d367266b4f1fa4d5

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

commit e1c695e8125aae1d6c845d44d367266b4f1fa4d5
Author: Bruno Le Floch <blflatex at gmail.com>
Date:   Tue May 11 12:39:55 2021 +0200

    Implement tl_log_analysis to complement the show function (see #241)


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

e1c695e8125aae1d6c845d44d367266b4f1fa4d5
 l3kernel/CHANGELOG.md                          |  1 +
 l3kernel/l3tl-analysis.dtx                     | 44 ++++++++++++++++++--------
 l3kernel/testfiles/m3tl-analysis001.luatex.tlg |  8 ++---
 l3kernel/testfiles/m3tl-analysis001.lvt        |  4 +--
 l3kernel/testfiles/m3tl-analysis001.tlg        |  8 ++---
 l3kernel/testfiles/m3tl-analysis001.xetex.tlg  |  8 ++---
 6 files changed, 40 insertions(+), 33 deletions(-)

diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index 65f0be2eb..8423cd21d 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -9,6 +9,7 @@ this project uses date-based 'snapshot' version identifiers.
 
 ### Added
 - `\sys_timer:`
+- `\tl_log_analysis:N`, `\tl_log_analysis:n` (issue #241)
 
 ## [2021-05-11]
 
diff --git a/l3kernel/l3tl-analysis.dtx b/l3kernel/l3tl-analysis.dtx
index 05f32c25f..88217288b 100644
--- a/l3kernel/l3tl-analysis.dtx
+++ b/l3kernel/l3tl-analysis.dtx
@@ -75,11 +75,16 @@
 % In addition, there is a debugging function \cs{tl_analysis_show:n},
 % very similar to the \cs[no-index]{ShowTokens} macro from the \pkg{ted} package.
 %
-% \begin{function}[added = 2018-04-09]{\tl_analysis_show:N, \tl_analysis_show:n}
+% \begin{function}[added = 2021-05-11]
+%   {
+%     \tl_analysis_show:N, \tl_analysis_show:n,
+%     \tl_analysis_log:N, \tl_analysis_log:n
+%   }
 %   \begin{syntax}
 %     \cs{tl_analysis_show:n} \Arg{token list}
+%     \cs{tl_analysis_log:n} \Arg{token list}
 %   \end{syntax}
-%   Displays to the terminal the detailed decomposition of the
+%   Displays to the terminal (or log) the detailed decomposition of the
 %   \meta{token list} into tokens, showing the category code of each
 %   character token, the meaning of control sequences and active
 %   characters, and the value of registers.
@@ -978,26 +983,39 @@
 %
 % \subsection{Showing the results}
 %
-% \begin{macro}{\tl_analysis_show:N, \tl_analysis_show:n}
+% \begin{macro}{\tl_analysis_show:N, \tl_analysis_log:N, \@@_analysis_show:NNN}
 %   Add to \cs{@@_analysis:n} a third pass to display tokens to the terminal.
 %   If the token list variable is not defined, throw the same error
 %   as \cs{tl_show:N} by simply calling that function.
 %    \begin{macrocode}
-\cs_new_protected:Npn \tl_analysis_show:N #1
+\cs_new_protected:Npn \tl_analysis_show:N
+  { \@@_analysis_show:NNN \__kernel_msg_show:nnxxxx \tl_show:N }
+\cs_new_protected:Npn \tl_analysis_log:N
+  { \@@_analysis_show:NNN \__kernel_msg_log:nnxxxx \tl_log:N }
+\cs_new_protected:Npn \@@_analysis_show:NNN #1#2#3
   {
-    \tl_if_exist:NTF #1
+    \tl_if_exist:NTF #3
       {
-        \exp_args:No \@@_analysis:n {#1}
-        \__kernel_msg_show:nnxxxx { tl } { show-analysis }
-          { \token_to_str:N #1 } { \@@_analysis_show: } { } { }
+        \exp_args:No \@@_analysis:n {#3}
+        #1 { tl } { show-analysis }
+          { \token_to_str:N #3 } { \@@_analysis_show: } { } { }
       }
-      { \tl_show:N #1 }
+      { #2 #3 }
   }
-\cs_new_protected:Npn \tl_analysis_show:n #1
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\tl_analysis_show:n, \tl_analysis_log:n, \@@_analysis_show:Nn}
+%   No existence test needed here.
+%    \begin{macrocode}
+\cs_new_protected:Npn \tl_analysis_show:n
+  { \@@_analysis_show:Nn \__kernel_msg_show:nnxxxx }
+\cs_new_protected:Npn \tl_analysis_log:n
+  { \@@_analysis_show:Nn \__kernel_msg_log:nnxxxx }
+\cs_new_protected:Npn \@@_analysis_show:Nn #1#2
   {
-    \@@_analysis:n {#1}
-    \__kernel_msg_show:nnxxxx { tl } { show-analysis }
-      { } { \@@_analysis_show: } { } { }
+    \@@_analysis:n {#2}
+    #1 { tl } { show-analysis } { } { \@@_analysis_show: } { } { }
   }
 %    \end{macrocode}
 % \end{macro}
diff --git a/l3kernel/testfiles/m3tl-analysis001.luatex.tlg b/l3kernel/testfiles/m3tl-analysis001.luatex.tlg
index 112e4f873..faa4b149a 100644
--- a/l3kernel/testfiles/m3tl-analysis001.luatex.tlg
+++ b/l3kernel/testfiles/m3tl-analysis001.luatex.tlg
@@ -9,9 +9,7 @@ The token list \c_empty_tl is empty
 <recently read> }
 l. ...  }
 The token list \c_catcode_other_space_tl contains the tokens:
->    (the character  ).
-<recently read> }
-l. ...  }
+>    (the character  )
 The token list is empty
 > .
 <recently read> }
@@ -21,9 +19,7 @@ The token list contains the tokens:
 <recently read> }
 l. ...  }
 The token list contains the tokens:
->  \  (control sequence=\ ).
-<recently read> }
-l. ...  }
+>  \  (control sequence=\ )
 The token list contains the tokens:
 >  & (alignment tab character &).
 <recently read> }
diff --git a/l3kernel/testfiles/m3tl-analysis001.lvt b/l3kernel/testfiles/m3tl-analysis001.lvt
index f70235e89..035de06d9 100644
--- a/l3kernel/testfiles/m3tl-analysis001.lvt
+++ b/l3kernel/testfiles/m3tl-analysis001.lvt
@@ -29,10 +29,10 @@
 \TEST { tl_analysis_show~basic }
   {
     \tl_analysis_show:N \c_empty_tl
-    \tl_analysis_show:N \c_catcode_other_space_tl
+    \tl_analysis_log:N \c_catcode_other_space_tl
     \tl_analysis_show:n { }
     \tl_analysis_show:n { ~ }
-    \tl_analysis_show:n { \ }
+    \tl_analysis_log:n { \ }
     \tl_analysis_show:n { & }
     \tl_analysis_show:n { { } }
     \tl_analysis_show:n { abc }
diff --git a/l3kernel/testfiles/m3tl-analysis001.tlg b/l3kernel/testfiles/m3tl-analysis001.tlg
index ea6f8c2ff..0447d3cc3 100644
--- a/l3kernel/testfiles/m3tl-analysis001.tlg
+++ b/l3kernel/testfiles/m3tl-analysis001.tlg
@@ -9,9 +9,7 @@ The token list \c_empty_tl is empty
 <recently read> }
 l. ...  }
 The token list \c_catcode_other_space_tl contains the tokens:
->    (the character  ).
-<recently read> }
-l. ...  }
+>    (the character  )
 The token list is empty
 > .
 <recently read> }
@@ -21,9 +19,7 @@ The token list contains the tokens:
 <recently read> }
 l. ...  }
 The token list contains the tokens:
->  \  (control sequence=\ ).
-<recently read> }
-l. ...  }
+>  \  (control sequence=\ )
 The token list contains the tokens:
 >  & (alignment tab character &).
 <recently read> }
diff --git a/l3kernel/testfiles/m3tl-analysis001.xetex.tlg b/l3kernel/testfiles/m3tl-analysis001.xetex.tlg
index 112e4f873..faa4b149a 100644
--- a/l3kernel/testfiles/m3tl-analysis001.xetex.tlg
+++ b/l3kernel/testfiles/m3tl-analysis001.xetex.tlg
@@ -9,9 +9,7 @@ The token list \c_empty_tl is empty
 <recently read> }
 l. ...  }
 The token list \c_catcode_other_space_tl contains the tokens:
->    (the character  ).
-<recently read> }
-l. ...  }
+>    (the character  )
 The token list is empty
 > .
 <recently read> }
@@ -21,9 +19,7 @@ The token list contains the tokens:
 <recently read> }
 l. ...  }
 The token list contains the tokens:
->  \  (control sequence=\ ).
-<recently read> }
-l. ...  }
+>  \  (control sequence=\ )
 The token list contains the tokens:
 >  & (alignment tab character &).
 <recently read> }





More information about the latex3-commits mailing list.