[latex3-commits] [git/LaTeX3-latex3-latex2e] apdf161: Move one-time checking to \hook_gput_code:nnn (9dcc3e98)

PhelypeOleinik phelype.oleinik at latex-project.org
Mon Sep 7 20:09:42 CEST 2020


Repository : https://github.com/latex3/latex2e
On branch  : apdf161
Link       : https://github.com/latex3/latex2e/commit/9dcc3e98646cf7e0c4e84787badd93470fe0f8c9

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

commit 9dcc3e98646cf7e0c4e84787badd93470fe0f8c9
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date:   Mon Sep 7 15:09:42 2020 -0300

    Move one-time checking to \hook_gput_code:nnn


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

9dcc3e98646cf7e0c4e84787badd93470fe0f8c9
 base/lthooks.dtx | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/base/lthooks.dtx b/base/lthooks.dtx
index 8ccf7bd3..6587a6dd 100644
--- a/base/lthooks.dtx
+++ b/base/lthooks.dtx
@@ -1926,42 +1926,49 @@
 \cs_new_protected:Npn \@@_gput_code:nnn #1 #2 #3
   {
 %    \end{macrocode}
-%    First check if the current \meta{hook}/\meta{label} pair was marked
+%    First check if the hook was used as a one-time hook:
+%    \begin{macrocode}
+    \clist_if_in:NnTF \g_@@_execute_immediately_clist {#1}
+      {#3}
+      {
+%    \end{macrocode}
+%    Then check if the current \meta{hook}/\meta{label} pair was marked
 %    for removal, in which case \cs{@@_unmark_removal:nn} is used to
 %    remove that mark (once).  This may happen when a package removes
 %    code from another package which was not yet loaded:  the removal
 %    order is stored, and at this stage it is executed by not adding to
 %    the hook.
 %    \begin{macrocode}
-    \@@_if_marked_removal:nnTF {#1} {#2}
-      { \@@_unmark_removal:nn {#1} {#2} }
-      {
+        \@@_if_marked_removal:nnTF {#1} {#2}
+          { \@@_unmark_removal:nn {#1} {#2} }
+          {
 %    \end{macrocode}
 %    If no removal is queued, we are free to add.  Start by checking if
 %    the hook exists.
 %    \begin{macrocode}
-        \hook_if_exist:nTF {#1}
+            \hook_if_exist:nTF {#1}
 %    \end{macrocode}
 %    If so we simply add (or append) the new code to the property list
 %    holding different chunks for the hook. At \verb=\begin{document}=
 %    this is then sorted into a token list for fast execution.
 %    \begin{macrocode}
-          {
-            \@@_hook_gput_code_do:nnn {#1} {#2} {#3}
+              {
+                \@@_hook_gput_code_do:nnn {#1} {#2} {#3}
 %    \end{macrocode}
 %    However, if there is an update within the document we need to alter
 %    this execution code which is done by
 %    \cs{@@_update_hook_code:n}. In the preamble this does nothing.
 %    \begin{macrocode}
-            \@@_update_hook_code:n {#1}
-          }
+                \@@_update_hook_code:n {#1}
+              }
 %    \end{macrocode}
 %
 %    If the hook does not exist, however, before giving up try to
 %    declare it as a generic hook, if its name matches one of the valid
 %    patterns.
 %    \begin{macrocode}
-          { \@@_try_declaring_generic_hook:nnn {#1} {#2} {#3} }
+              { \@@_try_declaring_generic_hook:nnn {#1} {#2} {#3} }
+          }
       }
   }
 \cs_generate_variant:Nn \@@_gput_code:nnn { nxv }
@@ -3594,11 +3601,7 @@
 %    
 %    \begin{macrocode}
 \NewDocumentCommand \AddToHook { m o +m }
-  {
-    \clist_if_in:NnTF \g_@@_execute_immediately_clist {#1}
-      {#3}
-      { \hook_gput_code:nnn {#1} {#2} {#3} }
-  }
+  { \hook_gput_code:nnn {#1} {#2} {#3} }
 %    \end{macrocode}
 %  \end{macro}
 %





More information about the latex3-commits mailing list.