[latex3-commits] [git/LaTeX3-latex3-latex2e] hook-args: Cleanup when adding new code to a declared hook (de68f1fc)
PhelypeOleinik
phelype.oleinik at latex-project.org
Fri Apr 14 06:18:07 CEST 2023
Repository : https://github.com/latex3/latex2e
On branch : hook-args
Link : https://github.com/latex3/latex2e/commit/de68f1fcc121e0a8f6e89063af2394890ea19cff
>---------------------------------------------------------------
commit de68f1fcc121e0a8f6e89063af2394890ea19cff
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date: Fri Apr 14 01:18:07 2023 -0300
Cleanup when adding new code to a declared hook
This prevents, for example, that declaring a rule in the hook triggers a
row of “Illegal parameter in definition” errors due to the
fast-execution token list (macro now) being defined again. Now the hook
code also shows correctly in `\ShowHook`.
>---------------------------------------------------------------
de68f1fcc121e0a8f6e89063af2394890ea19cff
base/lthooks.dtx | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/base/lthooks.dtx b/base/lthooks.dtx
index ba7a1429..c5272914 100644
--- a/base/lthooks.dtx
+++ b/base/lthooks.dtx
@@ -3470,7 +3470,8 @@
% \@@_gput_code:nnn,
% \@@_gput_code_store:nnn,
% \@@_hook_gput_code_do:nnn,
-% \@@_prop_gput_labeled_do:Nnn
+% \@@_prop_gput_labeled_cleanup:nnn,
+% \@@_prop_gput_labeled_do:Nnnn
% }
%
% With \cs{hook_gput_code:nnn}\Arg{hook}\Arg{label}\Arg{code} a
@@ -3609,15 +3610,14 @@
% later it is turned into a single parameter token, rather than a
% parameter to the hook macro.
% \begin{macrocode}
- \exp_args:Ncx \@@_prop_gput_labeled_do:Nnn
- { g_@@_#1_code_prop }
+ \exp_args:Nx \@@_prop_gput_labeled_cleanup:nnn
{
\@@_if_replacing_args:TF
{ \exp_not:n }
{ \@@_double_hashes:n }
{#3}
}
- {#2}
+ {#1} {#2}
}
}
% \end{macrocode}
@@ -3626,6 +3626,23 @@
% \changes{v1.1a}{2023/04/06}
% {Macro added (hook-args).}
% \begin{macrocode}
+\cs_new_protected:Npn \@@_prop_gput_labeled_cleanup:nnn #1 #2 #3
+ {
+ \tl_set:Nn \l_@@_return_tl {#1}
+ \@@_if_replacing_args:TF
+ {
+ \@@_if_usable:nT {#2}
+ {
+ \@@_set_normalise_fn:nn {#2}
+ { Invalid~code~added~\msg_line_context: }
+ \@@_normalise_fn:nn {#3} {#1}
+ \prop_get:NnN \l_@@_work_prop {#3} \l_@@_return_tl
+ }
+ }
+ { }
+ \exp_args:NcV \@@_prop_gput_labeled_do:Nnn
+ { g_@@_#2_code_prop } \l_@@_return_tl {#3}
+ }
\cs_new_protected:Npn \@@_prop_gput_labeled_do:Nnn #1 #2 #3
{
\prop_get:NnNTF #1 {#3} \l_@@_return_tl
More information about the latex3-commits
mailing list.