[latex3-commits] [latex3/latex2e] cmd-args: Don't show argument count when unknown (7d8414ab)

github at latex-project.org github at latex-project.org
Thu May 18 03:01:57 CEST 2023


Repository : https://github.com/latex3/latex2e
On branch  : cmd-args
Link       : https://github.com/latex3/latex2e/commit/7d8414abfd5046a7571a52c4297b0ea094a274cd

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

commit 7d8414abfd5046a7571a52c4297b0ea094a274cd
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date:   Wed May 17 22:01:57 2023 -0300

    Don't show argument count when unknown


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

7d8414abfd5046a7571a52c4297b0ea094a274cd
 base/lthooks.dtx | 51 +++++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 43 insertions(+), 8 deletions(-)

diff --git a/base/lthooks.dtx b/base/lthooks.dtx
index 59562817..d0348ccc 100644
--- a/base/lthooks.dtx
+++ b/base/lthooks.dtx
@@ -2396,8 +2396,9 @@
 %     \tl_show:x,
 %     \tl_log:x,
 %     \tl_set:Ne,
+%     \cs_replacement_spec:c,
 %     \prop_put:Nne,
-%     \cs_replacement_spec:c
+%     \str_count:e
 %   }
 %   Some variants of \pkg{expl3} functions.
 %   \fmiinline{should probably be moved to expl3}
@@ -2408,6 +2409,7 @@
 \cs_generate_variant:Nn \tl_set:Nn { Ne }
 \cs_generate_variant:Nn \cs_replacement_spec:N { c }
 \cs_generate_variant:Nn \prop_put:Nnn { Nne }
+\cs_generate_variant:Nn \str_count:n { e }
 %    \end{macrocode}
 % \end{macro}
 %
@@ -5153,7 +5155,7 @@
 %    \begin{macrocode}
     \@@_debug:n
       {
-        \iow_term:x{^^JAll~ initialized~ (non-empty)~ hooks:}
+        \iow_term:x { ^^J All~initialized~(non-empty)~hooks: }
         \prop_map_inline:Nn \g_@@_used_prop
           {
             \iow_term:x
@@ -5915,10 +5917,13 @@
         ^^J ->~The~
         \@@_if_generic:nT {#1} { generic~ }
         hook~'#1'
-        \exp_args:Nf \@@_print_args:n
+        \@@_if_disabled:nF {#1}
           {
-            \int_eval:n
-              { \exp_args:Ne \str_count:n { \@@_parameter:n {#1} } / 3 }
+            \exp_args:Nf \@@_print_args:nn {#1}
+              {
+                \int_eval:n
+                  { \str_count:e { \@@_parameter:n {#1} } / 3 }
+              }
           }
         :
       }
@@ -6159,10 +6164,18 @@
 % \begin{macro}{\@@_print_args:n}
 %    Pretty-prints the number of arguments of a hook.
 %    \begin{macrocode}
-\cs_new:Npn \@@_print_args:n #1
+\cs_new:Npn \@@_print_args:nn #1 #2
   {
-    \int_compare:nNnT {#1} > { 0 }
-      { ~ (#1~argument \int_compare:nNnT {#1} > { 1 } { s } ) }
+    \int_compare:nNnT {#2} > { 0 }
+      {
+        \@@_if_cmd_hook:nT {#1}
+          {
+            \cs_if_exist:NT \@@_cmd_begindocument_code:
+              { \use_i:nnn { ~ (unknown ~ } }
+          }
+        \use:n { ~ (#2 ~ }
+        argument \int_compare:nNnT {#2} > { 1 } { s } )
+      }
   }
 %    \end{macrocode}
 % \end{macro}
@@ -6915,6 +6928,28 @@
 %  \end{macro}
 %  \end{macro}
 %
+% \begin{macro}[pTF]{\@@_if_cmd_hook:n}
+% \begin{macro}[pTF]{\@@_if_cmd_hook:w}
+%   An internal conditional that checks if a given hook is a valid
+%   generic \hook{cmd} hook.
+%    \begin{macrocode}
+\prg_new_conditional:Npnn \@@_if_cmd_hook:n #1 { T }
+  { \@@_if_cmd_hook:w #1 / / / \s_@@_mark }
+\cs_new:Npn \@@_if_cmd_hook:w #1 / #2 / #3 / #4 \s_@@_mark
+  {
+    \if:w Y
+          \str_if_eq:nnF {#1} { cmd } { N }
+          \tl_if_exist:cF { c_@@_generic_#1/./#3_tl } { N }
+          Y
+      \prg_return_true:
+    \else:
+      \prg_return_false:
+    \fi:
+  }
+%    \end{macrocode}
+%  \end{macro}
+%  \end{macro}
+%
 % \begin{macro}[pTF]{\@@_if_generic_reversed:n}
 %   An internal conditional that checks if a name belongs to a generic
 %   reversed hook.





More information about the latex3-commits mailing list.