From 6548ebe38427d2147c904dda0e2750f03152fa44 Mon Sep 17 00:00:00 2001 From: PhelypeOleinik Date: Tue, 17 May 2022 00:04:36 -0300 Subject: [PATCH] Refuse sorting one-time hooks Fixes #818 --- base/lthooks.dtx | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/base/lthooks.dtx b/base/lthooks.dtx index 806189ee6..b914f893e 100644 --- a/base/lthooks.dtx +++ b/base/lthooks.dtx @@ -31,8 +31,8 @@ %%% From File: lthooks.dtx % % \begin{macrocode} -\def\lthooksversion{v1.0t} -\def\lthooksdate{2022/04/14} +\def\lthooksversion{v1.0u} +\def\lthooksdate{2022/05/17} % \end{macrocode} % %<*driver> @@ -3843,8 +3843,8 @@ % \begin{macrocode} \cs_new_protected:Npn \@@_initialize_hook_code:n #1 { - \@@_debug:n{ \iow_term:x{^^JUpdate~ code~ for~ hook~ - '#1' \on@line :^^J} } + \@@_debug:n + { \iow_term:x { ^^J Update~code~for~hook~'#1' \on@line :^^J } } % \end{macrocode} % This does the sorting and the updates. % First thing we do is to check if a legacy hook macro exists and @@ -3862,8 +3862,11 @@ % \cs{@@_initialize_single:NNn} and pass to it ready made csnames % as they are needed several times inside. This way we save a bit % on processing time if we do that up front. +% \changes{v1.0u}{2022/05/17}{Refuse sorting one-time hooks (gh/818).} % \begin{macrocode} - \@@_if_usable:nT {#1} + \bool_lazy_and:nnT + { \@@_if_usable_p:n {#1} } + { ! \@@_if_execute_immediately_p:n {#1} } { \prop_if_empty:cTF { g_@@_#1_code_prop } { @@ -3876,7 +3879,7 @@ { % \end{macrocode} % By default the algorithm sorts the code chunks and then saves the -% result in a token list for fast execution; this is done by adding the code chunks +% result in a token list for fast execution; this is done by adding the code chunks % one after another, using \cs{tl_gput_right:NV}. When we sort code for % a reversed hook, all we have to do is to add the code chunks in % the opposite order into the token list. So all we have to do @@ -4323,16 +4326,17 @@ % \@@_apply_-rule_>:nnn, % \@@_apply_-rule_<-:nnn, % \@@_apply_-rule_->:nnn, -% \@@_apply_-rule_x:nnn, +% \@@_apply_-rule_xW:nnn, +% \@@_apply_-rule_xE:nnn, % } % Reversed rules. % \begin{macrocode} -\cs_new_eq:cc { @@_apply_-rule_<:nnn } { @@_apply_rule_>:nnn } -\cs_new_eq:cc { @@_apply_-rule_>:nnn } { @@_apply_rule_<:nnn } +\cs_new_eq:cc { @@_apply_-rule_<:nnn } { @@_apply_rule_>:nnn } +\cs_new_eq:cc { @@_apply_-rule_>:nnn } { @@_apply_rule_<:nnn } \cs_new_eq:cc { @@_apply_-rule_<-:nnn } { @@_apply_rule_<-:nnn } \cs_new_eq:cc { @@_apply_-rule_->:nnn } { @@_apply_rule_->:nnn } -\cs_new_eq:cc { @@_apply_-rule_xE:nnn } { @@_apply_rule_xE:nnn } -\cs_new_eq:cc { @@_apply_-rule_xW:nnn } { @@_apply_rule_xW:nnn } +\cs_new_eq:cc { @@_apply_-rule_xE:nnn } { @@_apply_rule_xE:nnn } +\cs_new_eq:cc { @@_apply_-rule_xW:nnn } { @@_apply_rule_xW:nnn } % \end{macrocode} % \end{macro} % @@ -4875,7 +4879,7 @@ % empty. % \changes{v1.0r}{2021/09/06}{Macro added (gh/606)} % \begin{macrocode} -\prg_new_conditional:Npnn \@@_if_execute_immediately:n #1 { F, TF } +\prg_new_conditional:Npnn \@@_if_execute_immediately:n #1 { p, F, TF } { \@@_if_usable:nTF {#1} {