[latex3-commits] [git/LaTeX3-latex3-latex2e] gh648: Drop wrong-cmd-hook error message (e643dff3)

PhelypeOleinik phelype.oleinik at latex-project.org
Mon Aug 16 07:42:43 CEST 2021


Repository : https://github.com/latex3/latex2e
On branch  : gh648
Link       : https://github.com/latex3/latex2e/commit/e643dff304f80f2598032a28b3d8c24915aa8735

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

commit e643dff304f80f2598032a28b3d8c24915aa8735
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date:   Mon Aug 16 02:42:43 2021 -0300

    Drop wrong-cmd-hook error message
    
    Now the generic hook declaration just doesn't happen for misnamed hooks


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

e643dff304f80f2598032a28b3d8c24915aa8735
 base/ltcmdhooks.dtx                       | 55 ++++++++++++++++++++++---------
 base/testfiles-lthooks/ltcmdhooks-011.tlg |  6 ----
 2 files changed, 39 insertions(+), 22 deletions(-)

diff --git a/base/ltcmdhooks.dtx b/base/ltcmdhooks.dtx
index 8e5afd23..15398430 100644
--- a/base/ltcmdhooks.dtx
+++ b/base/ltcmdhooks.dtx
@@ -403,21 +403,38 @@
 % \begin{macro}{\@@_try_put_cmd_hook:n,\@@_try_put_cmd_hook:w}
 %   Before |\begin{document}| all patching is delayed.
 %   This function is called from within \cs{AddToHook}, when code is
-%   added to a generic |cmd| hook is newly declared.  It checks whether
-%   the patch position is valid, then proceeds to trying to patch or
-%   delaying to |\begin{document}| if in the preamble.
+%   added to a generic |cmd| hook is newly declared.  It checks either
+%   tries to patch or delay patching to |\begin{document}| if in the
+%   preamble.
 %    \begin{macrocode}
+%<latexrelease>\IncludeInRelease{2021/11/15}{\@@_try_put_cmd_hook:n}%
+%<latexrelease>                 {Standardise~generic~hook~names}
 \cs_new_protected:Npn \@@_try_put_cmd_hook:n #1
   { \@@_try_put_cmd_hook:w #1 / / / \s_@@_mark {#1} }
 \cs_new_protected:Npn \@@_try_put_cmd_hook:w
     #1 / #2 / #3 / #4 \s_@@_mark #5
   {
     \@@_debug:n { \iow_term:n { ->~Adding~cmd~hook~to~'#2'~(#3): } }
-    \str_case:nnTF {#3}
-        { { before } { } { after } { } }
-      { \exp_args:Nc \@@_patch_cmd_or_delay:Nnn {#2} {#2} {#3} }
-      { \msg_error:nnnn { hooks } { wrong-cmd-hook } {#2} {#3} }
+    \exp_args:Nc \@@_patch_cmd_or_delay:Nnn {#2} {#2} {#3}
   }
+%<latexrelease>\EndIncludeInRelease
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+%<latexrelease>\IncludeInRelease{2021/06/01}{\@@_try_put_cmd_hook:n}%
+%<latexrelease>                 {Standardise~generic~hook~names}
+%<latexrelease>\cs_new_protected:Npn \@@_try_put_cmd_hook:n #1
+%<latexrelease>  { \@@_try_put_cmd_hook:w #1 / / / \s_@@_mark {#1} }
+%<latexrelease>\cs_new_protected:Npn \@@_try_put_cmd_hook:w
+%<latexrelease>    #1 / #2 / #3 / #4 \s_@@_mark #5
+%<latexrelease>  {
+%<latexrelease>    \@@_debug:n { \iow_term:n { ->~Adding~cmd~hook~to~'#2'~(#3): } }
+%<latexrelease>    \str_case:nnTF {#3}
+%<latexrelease>        { { before } { } { after } { } }
+%<latexrelease>      { \exp_args:Nc \@@_patch_cmd_or_delay:Nnn {#2} {#2} {#3} }
+%<latexrelease>      { \msg_error:nnnn { hooks } { wrong-cmd-hook } {#2} {#3} }
+%<latexrelease>  }
+%<latexrelease>\EndIncludeInRelease
 %    \end{macrocode}
 % \end{macro}
 %
@@ -1050,15 +1067,21 @@
 % \subsection{Messages}
 %
 %    \begin{macrocode}
-\msg_new:nnnn { hooks } { wrong-cmd-hook }
-  {
-    Generic~hook~`cmd/#1/#2'~is~invalid.
-%    The~hook~should~be~`cmd/#1/before'~or~`cmd/#1/after'.
-  }
-  {
-    You~tried~to~add~a~generic~hook~to~command~\iow_char:N \\#1,~but~`#2'~
-    is~an~invalid~component.~Only~`before'~or~`after'~are~allowed.
-  }
+%<latexrelease>\IncludeInRelease{2021/11/15}{wrong-cmd-hook}%
+%<latexrelease>                 {Standardise~generic~hook~names}
+%<latexrelease>\EndIncludeInRelease
+%<latexrelease>\IncludeInRelease{2021/11/15}{wrong-cmd-hook}%
+%<latexrelease>                 {Standardise~generic~hook~names}
+%<latexrelease>\msg_new:nnnn { hooks } { wrong-cmd-hook }
+%<latexrelease>  {
+%<latexrelease>    Generic~hook~`cmd/#1/#2'~is~invalid.
+%<latexrelease>%    The~hook~should~be~`cmd/#1/before'~or~`cmd/#1/after'.
+%<latexrelease>  }
+%<latexrelease>  {
+%<latexrelease>    You~tried~to~add~a~generic~hook~to~command~\iow_char:N \\#1,~but~`#2'~
+%<latexrelease>    is~an~invalid~component.~Only~`before'~or~`after'~are~allowed.
+%<latexrelease>  }
+%<latexrelease>\EndIncludeInRelease
 \msg_new:nnnn { hooks } { cant-patch }
   {
     Generic~hooks~cannot~be~added~to~'#1'.
diff --git a/base/testfiles-lthooks/ltcmdhooks-011.tlg b/base/testfiles-lthooks/ltcmdhooks-011.tlg
index 735aaaad..3f163505 100644
--- a/base/testfiles-lthooks/ltcmdhooks-011.tlg
+++ b/base/testfiles-lthooks/ltcmdhooks-011.tlg
@@ -1,11 +1,5 @@
 This is a generated file for the l3build validation system.
 Don't change this file in any respect.
-! LaTeX hooks Error: Generic hook `cmd/textbf/middle' is invalid.
-For immediate help type H <return>.
- ...                                              
-l. ...\AddToHook{cmd/textbf/middle}{error}
-You tried to add a generic hook to command \textbf, but `middle' is an invalid
-component. Only `before' or `after' are allowed.
 ! LaTeX hooks Error: Generic hooks cannot be added to '\undefined'.
 For immediate help type H <return>.
  ...                                              





More information about the latex3-commits mailing list.