[latex3-commits] [git/LaTeX3-latex3-latex2e] hook-args: Fix \@@_if_execute_immediately:nTF for undeclared one-time hooks (8e945b2d)

PhelypeOleinik phelype.oleinik at latex-project.org
Fri Mar 10 04:55:09 CET 2023


Repository : https://github.com/latex3/latex2e
On branch  : hook-args
Link       : https://github.com/latex3/latex2e/commit/8e945b2da396a8080dae2bf0bafcd39d7b5ff44d

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

commit 8e945b2da396a8080dae2bf0bafcd39d7b5ff44d
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date:   Fri Mar 10 00:55:09 2023 -0300

    Fix \@@_if_execute_immediately:nTF for undeclared one-time hooks
    
    See testfiles-lthooks/lthooks-032.lvt.
    
    With the old definition, after `\UseOneTimeHook{package/./after}`
    (assuming the hook `package/./after` is not used at all), the result of
    `\@@_if_execute_immediately:nTF` would still be falsey because the hook
    would not be usable.  The new looks directly to `reversed_tl`, returning
    the correct branch even if the hook didn't get used.


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

8e945b2da396a8080dae2bf0bafcd39d7b5ff44d
 base/lthooks.dtx | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/base/lthooks.dtx b/base/lthooks.dtx
index 27083a31..aed0cf18 100644
--- a/base/lthooks.dtx
+++ b/base/lthooks.dtx
@@ -5845,9 +5845,8 @@
 % \end{macro}
 %
 % \begin{macro}[pTF]{\@@_if_execute_immediately:n}
-%   To check whether the code being added should be executed immediately (that
-%   is, if the hook is a one-time hook), we check if it's usable (it
-%   can't be one-time if it was not already usable), then we check that
+%   To check whether the code being added should be executed immediately
+%   (that is, if the hook is a one-time hook), we check if
 %   \cs[no-index]{g_@@_\meta{hook}_reversed_tl} is |I|.  The gymnastics
 %   around \cs{if:w} is there to allow the |reversed| token list to be
 %   empty.
@@ -5855,16 +5854,16 @@
 %    \begin{macrocode}
 \prg_new_conditional:Npnn \@@_if_execute_immediately:n #1 { T, F, TF }
   {
-    \@@_if_usable:nTF {#1}
-      {
-        \exp_after:wN \@@_use_none_delimit_by_s_mark:w
-        \if:w I \cs:w g_@@_#1_reversed_tl \cs_end:
-          \s_@@_mark \prg_return_true:
-        \else:
-          \s_@@_mark \prg_return_false:
+    \exp_after:wN \@@_use_none_delimit_by_s_mark:w
+    \if:w I
+        \if_cs_exist:w g_@@_#1_reversed_tl \cs_end:
+          \cs:w g_@@_#1_reversed_tl \exp_after:wN \cs_end:
         \fi:
-      }
-      { \prg_return_false: }
+        X
+      \s_@@_mark \prg_return_true:
+    \else:
+      \s_@@_mark \prg_return_false:
+    \fi:
   }
 %    \end{macrocode}
 %  \end{macro}





More information about the latex3-commits mailing list.