[latex3-commits] [git/LaTeX3-latex3-latex2e] gh606: Setting to one-time has to be done before executing (056a22b0)

PhelypeOleinik phelype.oleinik at latex-project.org
Sun Sep 5 22:17:30 CEST 2021


Repository : https://github.com/latex3/latex2e
On branch  : gh606
Link       : https://github.com/latex3/latex2e/commit/056a22b0598fb3a168e1ccf99f0d87a32783263f

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

commit 056a22b0598fb3a168e1ccf99f0d87a32783263f
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date:   Sun Sep 5 17:17:30 2021 -0300

    Setting to one-time has to be done before executing


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

056a22b0598fb3a168e1ccf99f0d87a32783263f
 base/lthooks.dtx | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/base/lthooks.dtx b/base/lthooks.dtx
index 0659d7d4..6e178318 100644
--- a/base/lthooks.dtx
+++ b/base/lthooks.dtx
@@ -4816,25 +4816,31 @@
   {
     \@@_if_execute_immediately:nF {#1}
       {
+        \@@_normalize_hook_args:Nn \@@_use_once_set:n { \use:n {#1} }
         \hook_use:n {#1}
-        \@@_normalize_hook_args:Nn \@@_use_once_store:n { \use:n {#1} }
+        \@@_normalize_hook_args:Nn \@@_use_once_clear:n { \use:n {#1} }
       }
   }
 %    \end{macrocode}
 %
-% \begin{macro}{\@@_use_once_store:n}
-%   \cs{@@_use_once_store:n} is used after the actual hook code is
-%   executed so that we can clear it.  Setting
+% \begin{macro}{\@@_use_once_set:n}
+% \begin{macro}{\@@_use_once_clear:n}
+%   \cs{@@_use_once_set:n} is used before the actual hook code is
+%   executed so that any usage of \cs{AddToHook} inside the hook causes
+%   the code to execute immediately.  Setting
 %   \cs[no-index]{g_@@_\meta{hook}_reversed_tl} to |I| prevents further
-%   code from being added to the hook.
+%   code from being added to the hook.  \cs{@@_use_once_clear:n} then
+%   clears the hook so that any further call to \cs{hook_use:n} or
+%   \cs{hook_use_once:n} will expand to nothing.
 %    \begin{macrocode}
-\cs_new_protected:Npn \@@_use_once_store:n #1
+\cs_new_protected:Npn \@@_use_once_set:n #1
+  { \@@_tl_gset:cn { g_@@_#1_reversed_tl } { I } }
+\cs_new_protected:Npn \@@_use_once_clear:n #1
   {
     \@@_tl_gclear:c { @@~#1 }
     \@@_tl_gclear:c { @@_next~#1 }
     \@@_tl_gclear:c { @@_toplevel~#1 }
     \prop_gclear:c { g_@@_#1_code_prop }
-    \@@_tl_gset:cn { g_@@_#1_reversed_tl } { I }
   }
 %    \end{macrocode}
 % \end{macro}





More information about the latex3-commits mailing list.