[latex3-commits] [git/LaTeX3-latex3-latex2e] gh625: Do not queue removals (210dee34)

PhelypeOleinik phelype.oleinik at latex-project.org
Fri Jul 23 01:18:21 CEST 2021


Repository : https://github.com/latex3/latex2e
On branch  : gh625
Link       : https://github.com/latex3/latex2e/commit/210dee349477bc3109e147c8ed1bc3c6bbb90603

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

commit 210dee349477bc3109e147c8ed1bc3c6bbb90603
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date:   Thu Jul 22 20:18:21 2021 -0300

    Do not queue removals
    
    Closes #625


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

210dee349477bc3109e147c8ed1bc3c6bbb90603
 base/lthooks.dtx | 181 +++++++++++++++++++++++++++++++++----------------------
 1 file changed, 110 insertions(+), 71 deletions(-)

diff --git a/base/lthooks.dtx b/base/lthooks.dtx
index 2a6a114e..247aaab6 100644
--- a/base/lthooks.dtx
+++ b/base/lthooks.dtx
@@ -31,8 +31,8 @@
 %%% From File: lthooks.dtx
 %
 %    \begin{macrocode}
-\def\lthooksversion{v1.0n}
-\def\lthooksdate{2021/07/18}
+\def\lthooksversion{v1.0o}
+\def\lthooksdate{2021/07/22}
 %    \end{macrocode}
 %
 %<*driver>
@@ -2711,9 +2711,12 @@
 % \begin{macro}{\hook_gput_code:nnn}
 % \begin{macro}{\@@_gput_code:nnn,\@@_gput_code:nxv,\@@_hook_gput_code_do:nnn}
 %
+%<latexrelease>\IncludeInRelease{2021/11/15}%
+%<latexrelease>                 {\hook_gput_code:nnn}{Do~not~queue~removals}
 %    With \cs{hook_gput_code:nnn}\Arg{hook}\Arg{label}\Arg{code} a
 %    chunk of \meta{code} is added to an existing \meta{hook} labeled
 %    with \meta{label}.
+% \changes{v1.0o}{2021/07/22}{Do not queue removals (gh/625)}
 %    \begin{macrocode}
 \cs_new_protected:Npn \hook_gput_code:nnn #1 #2
   { \@@_normalize_hook_args:Nnn \@@_gput_code:nnn {#1} {#2} }
@@ -2729,50 +2732,63 @@
       {#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.
+%    Then check if the hook is usable.
 %    \begin{macrocode}
-        \@@_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}
-            \@@_if_usable:nTF {#1}
+        \@@_if_usable: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.
+%    If the hook is not usable, before giving up, check if it's not
+%    disabled and otherwise try to declare it as a generic hook, if its
+%    name matches one of the valid patterns.
 %    \begin{macrocode}
-              {
-                \@@_if_disabled:nTF {#1}
-                  { \msg_error:nnn { hooks } { hook-disabled } {#1} }
-                  { \@@_try_declaring_generic_hook:nnn {#1} {#2} {#3} }
-              }
+          {
+            \@@_if_disabled:nTF {#1}
+              { \msg_error:nnn { hooks } { hook-disabled } {#1} }
+              { \@@_try_declaring_generic_hook:nnn {#1} {#2} {#3} }
           }
       }
   }
 %    \end{macrocode}
+%<latexrelease>\EndIncludeInRelease
+%
+%<latexrelease>\IncludeInRelease{2020/10/01}%
+%<latexrelease>                 {\hook_gput_code:nnn}{Do~not~queue~removals}
+%<latexrelease>\cs_new_protected:Npn \@@_gput_code:nnn #1 #2 #3
+%<latexrelease>  {
+%<latexrelease>    \prop_if_in:NnTF \g_@@_execute_immediately_prop {#1}
+%<latexrelease>      {#3}
+%<latexrelease>      {
+%<latexrelease>        \@@_if_marked_removal:nnTF {#1} {#2}
+%<latexrelease>          { \@@_unmark_removal:nn {#1} {#2} }
+%<latexrelease>          {
+%<latexrelease>            \@@_if_usable:nTF {#1}
+%<latexrelease>              {
+%<latexrelease>                \@@_hook_gput_code_do:nnn {#1} {#2} {#3}
+%<latexrelease>                \@@_update_hook_code:n {#1}
+%<latexrelease>              }
+%<latexrelease>              {
+%<latexrelease>                \@@_if_disabled:nTF {#1}
+%<latexrelease>                  { \msg_error:nnn { hooks } { hook-disabled } {#1} }
+%<latexrelease>                  { \@@_try_declaring_generic_hook:nnn {#1} {#2} {#3} }
+%<latexrelease>              }
+%<latexrelease>          }
+%<latexrelease>      }
+%<latexrelease>  }
+%<latexrelease>\EndIncludeInRelease
 %
 %    \begin{macrocode}
 \cs_generate_variant:Nn \@@_gput_code:nnn { nxv }
@@ -3083,8 +3099,11 @@
 % \begin{macro}{\hook_gremove_code:nn}
 % \begin{macro}{\@@_gremove_code:nn}
 %
+%<latexrelease>\IncludeInRelease{2021/11/15}%
+%<latexrelease>                 {\hook_gremove_code:nn}{Do~not~queue~removals}
 %    With \cs{hook_gremove_code:nn}\Arg{hook}\Arg{label} any code
 %    for \meta{hook} stored under \meta{label} is removed.
+% \changes{v1.0o}{2021/07/22}{Do not queue removals (gh/625)}
 %    \begin{macrocode}
 \cs_new_protected:Npn \hook_gremove_code:nn #1 #2
   { \@@_normalize_hook_args:Nnn \@@_gremove_code:nn {#1} {#2} }
@@ -3116,27 +3135,13 @@
           {
 %    \end{macrocode}
 %    If the label is |top-level| then clear the token list, as all code
-%    there is under the same label.  Marked removal is not implemented
-%    for |top-level| because it is hard to reliably know that no code
-%    was added to \cs{@@_toplevel\textvisiblespace\meta{hook}} (granted that
-%    an empty code could be interpreted as that, but then it differs in
-%    behaviour from other labels, in which an empty chunk is still valid
-%    for removal).  Besides, it doesn't make much (if any) sense for
-%    packages to remove |top-level| code.  So here the chunk is just
-%    cleared unconditionally.
+%    there is under the same label.
 %    \begin{macrocode}
             \str_if_eq:nnTF {#2} { top-level }
               { \@@_tl_gclear:c { @@_toplevel~#1 } }
               {
-%    \end{macrocode}
-%    Otherwise check if the label being removed exists in the code pool.
-%    If it does, just call \cs{@@_gremove_code_do:nn} to do the removal,
-%    otherwise mark it to be removed.
-%    \begin{macrocode}
-                \prop_get:cnNTF { g_@@_#1_code_prop } {#2} \l_@@_return_tl
-                  { \@@_gremove_code_do:nn }
-                  { \@@_mark_removal:nn }
-                      {#1} {#2}
+                \prop_gpop:cnNF { g_@@_#1_code_prop } {#2} \l_@@_return_tl
+                  { \msg_error:nnnn { hooks } { cannot-remove } {#1} {#2} }
               }
           }
 %    \end{macrocode}
@@ -3151,17 +3156,40 @@
 %    tried to add to it before, so we just queue this removal order for
 %    later.
 %    \begin{macrocode}
-      { \@@_mark_removal:nn {#1} {#2} }
+      { \msg_error:nnnn { hooks } { cannot-remove } {#1} {#2} }
   }
 %    \end{macrocode}
+%<latexrelease>\EndIncludeInRelease
 %
-% \begin{macro}{\@@_gremove_code_do:nn}
-%   Remove code for a given label.
-%    \begin{macrocode}
-\cs_new_protected:Npn \@@_gremove_code_do:nn #1 #2
-  { \prop_gremove:cn { g_@@_#1_code_prop } {#2} }
-%    \end{macrocode}
-% \end{macro}
+%<latexrelease>\IncludeInRelease{2020/10/01}%
+%<latexrelease>                 {\hook_gremove_code:nn}{Do~not~queue~removals}
+%<latexrelease>\cs_gset_protected:Npn \@@_gremove_code:nn #1 #2
+%<latexrelease>  {
+%<latexrelease>    \@@_if_structure_exist:nTF {#1}
+%<latexrelease>      {
+%<latexrelease>        \str_if_eq:nnTF {#2} {*}
+%<latexrelease>          {
+%<latexrelease>            \prop_gclear:c { g_@@_#1_code_prop }
+%<latexrelease>            \@@_tl_gclear:c { @@_toplevel~#1 }
+%<latexrelease>            \@@_tl_gclear:c { @@_next~#1 }
+%<latexrelease>          }
+%<latexrelease>          {
+%<latexrelease>            \str_if_eq:nnTF {#2} { top-level }
+%<latexrelease>              { \@@_tl_gclear:c { @@_toplevel~#1 } }
+%<latexrelease>              {
+%<latexrelease>                \prop_get:cnNTF { g_@@_#1_code_prop } {#2} \l_@@_return_tl
+%<latexrelease>                  { \@@_gremove_code_do:nn }
+%<latexrelease>                  { \@@_mark_removal:nn }
+%<latexrelease>                      {#1} {#2}
+%<latexrelease>              }
+%<latexrelease>          }
+%<latexrelease>        \@@_if_usable:nT {#1}
+%<latexrelease>          { \@@_update_hook_code:n {#1} }
+%<latexrelease>      }
+%<latexrelease>      { \@@_mark_removal:nn {#1} {#2} }
+%<latexrelease>  }
+%<latexrelease>\cs_gset_protected:Npn \@@_gremove_code_do:nn #1 #2
+%<latexrelease>  { \prop_gremove:cn { g_@@_#1_code_prop } {#2} }
 % \end{macro}
 % \end{macro}
 %
@@ -3176,11 +3204,11 @@
 %   hold repeated items, so multiple usages of \cs{@@_mark_removal:nn}
 %   would be cancelled by a single \cs{@@_unmark_removal:nn}.
 %    \begin{macrocode}
-\cs_new_protected:Npn \@@_mark_removal:nn #1 #2
-  {
-    \tl_gput_right:Nx \g_@@_removal_list_tl
-      { \@@_removal_tl:nn {#1} {#2} }
-  }
+%<latexrelease>\cs_new_protected:Npn \@@_mark_removal:nn #1 #2
+%<latexrelease>  {
+%<latexrelease>    \tl_gput_right:Nx \g_@@_removal_list_tl
+%<latexrelease>      { \@@_removal_tl:nn {#1} {#2} }
+%<latexrelease>  }
 %    \end{macrocode}
 % \end{macro}
 %
@@ -3190,11 +3218,11 @@
 %   \cs{tl_gremove_all:Nx} so that two additions are needed to cancel
 %   two marked removals, rather than only one.
 %    \begin{macrocode}
-\cs_new_protected:Npn \@@_unmark_removal:nn #1 #2
-  {
-    \tl_gremove_once:Nx \g_@@_removal_list_tl
-      { \@@_removal_tl:nn {#1} {#2} }
-  }
+%<latexrelease>\cs_new_protected:Npn \@@_unmark_removal:nn #1 #2
+%<latexrelease>  {
+%<latexrelease>    \tl_gremove_once:Nx \g_@@_removal_list_tl
+%<latexrelease>      { \@@_removal_tl:nn {#1} {#2} }
+%<latexrelease>  }
 %    \end{macrocode}
 % \end{macro}
 %
@@ -3202,12 +3230,12 @@
 %   Checks if the \cs{g_@@_removal_list_tl} contains the current
 %   \meta{label} (\verb=#2=) and \meta{hook} (\verb=#1=).
 %    \begin{macrocode}
-\prg_new_protected_conditional:Npnn \@@_if_marked_removal:nn #1 #2 { TF }
-  {
-    \exp_args:NNx \tl_if_in:NnTF \g_@@_removal_list_tl
-      { \@@_removal_tl:nn {#1} {#2} }
-      { \prg_return_true: } { \prg_return_false: }
-  }
+%<latexrelease>\prg_new_protected_conditional:Npnn \@@_if_marked_removal:nn #1 #2 { TF }
+%<latexrelease>  {
+%<latexrelease>    \exp_args:NNx \tl_if_in:NnTF \g_@@_removal_list_tl
+%<latexrelease>      { \@@_removal_tl:nn {#1} {#2} }
+%<latexrelease>      { \prg_return_true: } { \prg_return_false: }
+%<latexrelease>  }
 %    \end{macrocode}
 % \end{macro}
 %
@@ -3217,10 +3245,11 @@
 %   so that \verb=#1= can't be mistaken by \verb=#2= and vice versa, and
 %   the two |$|$_3$ delimit the two arguments
 %    \begin{macrocode}
-\cs_new:Npn \@@_removal_tl:nn #1 #2
-  { & \tl_to_str:n {#2} $ \tl_to_str:n {#1} $ }
+%<latexrelease>\cs_new:Npn \@@_removal_tl:nn #1 #2
+%<latexrelease>  { & \tl_to_str:n {#2} $ \tl_to_str:n {#1} $ }
 %    \end{macrocode}
 % \end{macro}
+%<latexrelease>\EndIncludeInRelease
 %
 %
 % \begin{macro}{
@@ -4697,6 +4726,16 @@
   }
 %    \end{macrocode}
 %
+%    \begin{macrocode}
+\msg_new:nnn { hooks } { cannot-remove }
+  {
+    Cannot~remove~chunk~'#2'~from~hook~'#1'~because~
+    \@@_if_structure_exist:nTF {#1}
+      { it~does~not~exist~in~that~hook. }
+      { the~hook~does~not~exist. }
+  }
+%    \end{macrocode}
+%
 %
 %
 %





More information about the latex3-commits mailing list.