[latex3-commits] [git/LaTeX3-latex3-latex2e] hook-args: Update hook code after declaring it (5b96a1b8)

PhelypeOleinik phelype.oleinik at latex-project.org
Thu Apr 6 01:32:32 CEST 2023


Repository : https://github.com/latex3/latex2e
On branch  : hook-args
Link       : https://github.com/latex3/latex2e/commit/5b96a1b8fd849a31ebdd46cf5736f36ac9bfa206

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

commit 5b96a1b8fd849a31ebdd46cf5736f36ac9bfa206
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date:   Wed Apr 5 20:32:32 2023 -0300

    Update hook code after declaring it


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

5b96a1b8fd849a31ebdd46cf5736f36ac9bfa206
 base/lthooks.dtx                                   |  6 ++++
 base/testfiles-lthooks/lthooks-021.tlg             |  1 +
 base/testfiles-lthooks/lthooks-028.tlg             |  4 +--
 base/testfiles-lthooks/lthooks-033.tlg             |  7 ++++
 base/testfiles-lthooks/lthooks-034.lvt             | 23 +++++++++++++
 .../{lthooks-029b.tlg => lthooks-034.tlg}          | 40 ++++++++++++----------
 6 files changed, 60 insertions(+), 21 deletions(-)

diff --git a/base/lthooks.dtx b/base/lthooks.dtx
index f7a66689..6ad97104 100644
--- a/base/lthooks.dtx
+++ b/base/lthooks.dtx
@@ -2693,6 +2693,12 @@
       {
         \tl_new:c { g_@@_#1_declared_tl }
         \@@_make_usable:nn {#1} {#2}
+%    \end{macrocode}
+%   In case there is already code in a hook, but it's undeclared, run
+%   \cs{@@_update_hook_code:n} to make it ready to be executed (see test
+%   \texttt{lthooks-034}).
+%    \begin{macrocode}
+        \@@_update_hook_code:n {#1}
       }
   }
 %<latexrelease>\EndIncludeInRelease
diff --git a/base/testfiles-lthooks/lthooks-021.tlg b/base/testfiles-lthooks/lthooks-021.tlg
index 17c28098..40f92e68 100644
--- a/base/testfiles-lthooks/lthooks-021.tlg
+++ b/base/testfiles-lthooks/lthooks-021.tlg
@@ -165,6 +165,7 @@ LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line ....
 LaTeX Font Info:    ... okay on input line ....
 LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line ....
 LaTeX Font Info:    ... okay on input line ....
+Update code for hook 'aaa' on input line ...:
 **** Add to hook aaa (label1) on input line ... <- code1
 Update code for hook 'aaa' on input line ...:
 Code labels for sorting:
diff --git a/base/testfiles-lthooks/lthooks-028.tlg b/base/testfiles-lthooks/lthooks-028.tlg
index ce6b38f9..3131be6f 100644
--- a/base/testfiles-lthooks/lthooks-028.tlg
+++ b/base/testfiles-lthooks/lthooks-028.tlg
@@ -60,7 +60,7 @@ l. ...\ShowHook{bbb}
 > Rules:
 >     package|other package with relation >
 > Execution order (after applying rules):
->     ---.
+>     other package, package.
 <recently read> }
 l. ...\ShowHook{bbb}
 -> The hook 'ccc':
@@ -89,7 +89,7 @@ l. ...\ShowHook{ccc}
 > Rules:
 >     package|other package with relation >
 > Execution order (after reversal and applying rules):
->     ---.
+>     other package, package.
 <recently read> }
 l. ...\ShowHook{ccc}
 -> The hook 'ddd':
diff --git a/base/testfiles-lthooks/lthooks-033.tlg b/base/testfiles-lthooks/lthooks-033.tlg
index 282564bf..41c76202 100644
--- a/base/testfiles-lthooks/lthooks-033.tlg
+++ b/base/testfiles-lthooks/lthooks-033.tlg
@@ -435,6 +435,13 @@ l. ...  }
 You meant to type ## instead of #, right?
 Or maybe a } was forgotten somewhere earlier, and things
 are all screwed up? I'm going to assume that you meant ##.
+! Illegal parameter number in definition of \__hook liar.
+<to be read again> 
+                   1
+l. ...  }
+You meant to type ## instead of #, right?
+Or maybe a } was forgotten somewhere earlier, and things
+are all screwed up? I'm going to assume that you meant ##.
 -> The hook 'liar':
 > Code chunks:
 >     label -> \typeout {label-arg(#1)}\typeout {label-hash(##1)}\typeout {more-label-hash(##1)}
diff --git a/base/testfiles-lthooks/lthooks-034.lvt b/base/testfiles-lthooks/lthooks-034.lvt
new file mode 100644
index 00000000..2f3d44a0
--- /dev/null
+++ b/base/testfiles-lthooks/lthooks-034.lvt
@@ -0,0 +1,23 @@
+\input{regression-test}
+
+\documentclass{minimal}
+
+\begin{document}
+
+\START
+
+\AddToHook{foo}[pkga]{\typeout{pkga}}
+\AddToHook{foo}[pkgb]{\typeout{pkgb}}
+\DeclareHookRule{foo}{pkga}{after}{pkgb}
+\typeout{====== A}
+\ShowHook{foo}
+\typeout{====== B}
+\UseHook{foo}
+\typeout{====== C}
+\NewHook{foo}
+\typeout{====== D}
+\ShowHook{foo}
+\typeout{====== E}
+\UseHook{foo}
+
+\END
diff --git a/base/testfiles-lthooks/lthooks-029b.tlg b/base/testfiles-lthooks/lthooks-034.tlg
similarity index 55%
copy from base/testfiles-lthooks/lthooks-029b.tlg
copy to base/testfiles-lthooks/lthooks-034.tlg
index 995e62dc..cd959fdb 100644
--- a/base/testfiles-lthooks/lthooks-029b.tlg
+++ b/base/testfiles-lthooks/lthooks-034.tlg
@@ -1,36 +1,38 @@
 This is a generated file for the l3build validation system.
 Don't change this file in any respect.
--> The hook 'baz/middle':
+====== A
+-> The hook 'foo':
 > The hook is not declared.
 > Code chunks:
->     X -> \typeout {X middle no cmd}
+>     pkga -> \typeout {pkga}
+>     pkgb -> \typeout {pkgb}
 > Document-level (top-level) code:
->     -> \typeout {middle no cmd}
+>     ---
 > Extra code for next invocation:
 >     ---
 > Rules:
->     ---
+>     pkgb|pkga with relation <
 > Execution order:
 >     Not set because the hook is undeclared.
 <recently read> }
-l. ...\ShowHook{baz/middle}
-baz start
-baz end
--> The hook 'baz/middle':
+l. ...\ShowHook{foo}
+====== B
+====== C
+====== D
+-> The hook 'foo':
 > Code chunks:
->     X -> \typeout {X middle no cmd}
+>     pkga -> \typeout {pkga}
+>     pkgb -> \typeout {pkgb}
 > Document-level (top-level) code (executed last):
->     -> \typeout {middle no cmd}
+>     ---
 > Extra code for next invocation:
 >     ---
 > Rules:
->     ---
-> Execution order:
->     X.
+>     pkgb|pkga with relation <
+> Execution order (after applying rules):
+>     pkgb, pkga.
 <recently read> }
-l. ...\ShowHook{baz/middle}
-baz start
-middle cmd
-X middle no cmd
-middle no cmd
-baz end
+l. ...\ShowHook{foo}
+====== E
+pkgb
+pkga





More information about the latex3-commits mailing list.