[latex3-commits] [git/LaTeX3-latex3-latex2e] hotfix/activate-generic: ensure that activating a generic hook sets the execution code (1b52a420)
Frank Mittelbach
frank.mittelbach at latex-project.org
Wed Jun 15 10:39:45 CEST 2022
Repository : https://github.com/latex3/latex2e
On branch : hotfix/activate-generic
Link : https://github.com/latex3/latex2e/commit/1b52a4202d111e1e92d430ffc2ce19161379a99e
>---------------------------------------------------------------
commit 1b52a4202d111e1e92d430ffc2ce19161379a99e
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date: Wed Jun 15 10:39:45 2022 +0200
ensure that activating a generic hook sets the execution code
>---------------------------------------------------------------
1b52a4202d111e1e92d430ffc2ce19161379a99e
base/changes.txt | 5 +++++
base/lthooks.dtx | 11 ++++++++--
base/testfiles-lthooks/lthooks-029.lvt | 38 ++++++++++++++++++++++++++++++---
base/testfiles-lthooks/lthooks-029.tlg | 32 +++++++++++++++++++++++----
base/testfiles-lthooks/lthooks-029b.lvt | 36 +++++++++++++++++++++++++++++++
base/testfiles-lthooks/lthooks-029b.tlg | 36 +++++++++++++++++++++++++++++++
6 files changed, 149 insertions(+), 9 deletions(-)
diff --git a/base/changes.txt b/base/changes.txt
index c68e1ac8..becab75e 100644
--- a/base/changes.txt
+++ b/base/changes.txt
@@ -10,6 +10,11 @@ are not part of the distribution.
All changes above are only part of the development branch for the next release.
================================================================================
+2022-06-15 Frank Mittelbach <Frank.Mittelbach at latex-project.org>
+
+ * lthooks.dtx (subsubsection{Disabling and providing hooks}):
+ Ensure that a newly activated generic hook gets its execution code set
+
2022-06-14 Frank Mittelbach <Frank.Mittelbach at latex-project.org>
* ltxdoc.dtx: Delay definitions of \enquote etc in case they get defined in
diff --git a/base/lthooks.dtx b/base/lthooks.dtx
index 06a0e825..cfa14547 100644
--- a/base/lthooks.dtx
+++ b/base/lthooks.dtx
@@ -31,8 +31,8 @@
%%% From File: lthooks.dtx
%
% \begin{macrocode}
-\def\lthooksversion{v1.0u}
-\def\lthooksdate{2022/05/19}
+\def\lthooksversion{v1.0v}
+\def\lthooksdate{2022/06/15}
% \end{macrocode}
%
%<*driver>
@@ -2649,6 +2649,13 @@
\@@_make_usable:n {#1}
\tl_gset:cx { g_@@_#1_reversed_tl }
{ \@@_if_generic_reversed:nT {#1} { - } }
+% \end{macrocode}
+% Reflect that we have activated the generic hook and set its
+% execution code.
+% \changes{v1.0v}{2022/06/15}{Ensure that a newly activated generic hook
+% gets its execution code set}
+% \begin{macrocode}
+ \@@_update_hook_code:n {#1}
}
}
}
diff --git a/base/testfiles-lthooks/lthooks-029.lvt b/base/testfiles-lthooks/lthooks-029.lvt
index e807e89e..1bcc76f1 100644
--- a/base/testfiles-lthooks/lthooks-029.lvt
+++ b/base/testfiles-lthooks/lthooks-029.lvt
@@ -7,6 +7,9 @@
\documentclass{article}
+
+\begin{document}
+
\START
\typeout{------------ all unknown --------------}
@@ -14,6 +17,7 @@
\ShowHook{aaa}
\ShowHook{env/bbb/begin}
\ShowHook{env/ccc/end}
+\ShowHook{ddd}
\NewHook{aaa}
\ShowHook{aaa}
@@ -25,33 +29,61 @@
\typeout{------------ activate a known hook with data --------------}
-\AddToHook{aaa}[X]{X1}
+\AddToHook{aaa}[X]{\typeout{aaa: X1}}
\ActivateGenericHook{aaa}
\ShowHook{aaa}
-\AddToHook{env/bbb/begin}[Y]{Y1}
+\AddToHook{env/bbb/begin}[Y]{\typeout{bbb: Y1}}
+
+\UseHook{aaa}
+\UseHook{env/bbb/begin}
+\UseHook{env/ccc/end}
+\UseHook{ddd}
\typeout{------------ activate an unknown hook with data --------------}
\ActivateGenericHook{env/bbb/begin}
\ShowHook{env/bbb/begin}
+\UseHook{aaa}
+\UseHook{env/bbb/begin}
+\UseHook{env/ccc/end}
+\UseHook{ddd}
+
\typeout{------------ activate an unknown reversed hook --------------}
\ActivateGenericHook{env/ccc/end}
\ShowHook{env/ccc/end}
+\UseHook{aaa}
+\UseHook{env/bbb/begin}
+\UseHook{env/ccc/end}
+\UseHook{ddd}
+
\typeout{------------ activate an known reversed hook with data --------------}
-\AddToHook{env/ccc/end}[Z]{Z1}
+\AddToHook{env/ccc/end}[Z]{\typeout{ccc: Z1}}
\ActivateGenericHook{env/ccc/end}
\ShowHook{env/ccc/end}
+\UseHook{aaa}
+\UseHook{env/bbb/begin}
+\UseHook{env/ccc/end}
+\UseHook{ddd}
+
\typeout{------------ activate hook that was disabled --------------}
+
+\AddToHook{ddd}[W]{\typeout{ddd: W1}}
+
+\ActivateGenericHook{ddd}
+\UseHook{ddd}
+
+
\DisableGenericHook{ddd}
\ActivateGenericHook{ddd}
\ShowHook{ddd}
+\UseHook{ddd}
\END
diff --git a/base/testfiles-lthooks/lthooks-029.tlg b/base/testfiles-lthooks/lthooks-029.tlg
index 6d352e87..2f15f012 100644
--- a/base/testfiles-lthooks/lthooks-029.tlg
+++ b/base/testfiles-lthooks/lthooks-029.tlg
@@ -16,6 +16,11 @@ l. ...\ShowHook{env/bbb/begin}
> The hook is empty.
<recently read> }
l. ...\ShowHook{env/ccc/end}
+-> The hook 'ddd':
+> The hook is not declared.
+> The hook is empty.
+<recently read> }
+l. ...\ShowHook{ddd}
-> The hook 'aaa':
> The hook is empty.
<recently read> }
@@ -28,7 +33,7 @@ l. ...\ShowHook{aaa}
------------ activate a known hook with data --------------
-> The hook 'aaa':
> Code chunks:
-> X -> X1
+> X -> \typeout {aaa: X1}
> Document-level (top-level) code (executed last):
> ---
> Extra code for next invocation:
@@ -39,10 +44,12 @@ l. ...\ShowHook{aaa}
> X.
<recently read> }
l. ...\ShowHook{aaa}
+aaa: X1
+bbb: Y1
------------ activate an unknown hook with data --------------
-> The generic hook 'env/bbb/begin':
> Code chunks:
-> Y -> Y1
+> Y -> \typeout {bbb: Y1}
> Document-level (top-level) code (executed last):
> ---
> Extra code for next invocation:
@@ -53,15 +60,19 @@ l. ...\ShowHook{aaa}
> Y.
<recently read> }
l. ...\ShowHook{env/bbb/begin}
+aaa: X1
+bbb: Y1
------------ activate an unknown reversed hook --------------
-> The generic hook 'env/ccc/end':
> The hook is empty.
<recently read> }
l. ...\ShowHook{env/ccc/end}
+aaa: X1
+bbb: Y1
------------ activate an known reversed hook with data --------------
-> The generic hook 'env/ccc/end':
> Code chunks:
-> Z -> Z1
+> Z -> \typeout {ccc: Z1}
> Document-level (top-level) code (executed last):
> ---
> Extra code for next invocation:
@@ -72,11 +83,24 @@ l. ...\ShowHook{env/ccc/end}
> Z.
<recently read> }
l. ...\ShowHook{env/ccc/end}
+aaa: X1
+bbb: Y1
+ccc: Z1
------------ activate hook that was disabled --------------
+ddd: W1
LaTeX hooks Warning: Cannot activate hook 'ddd' because it is disabled!
-> The hook 'ddd':
> The hook is not declared.
> The hook is disabled.
-> The hook is empty.
+> Code chunks:
+> W -> \typeout {ddd: W1}
+> Document-level (top-level) code:
+> ---
+> Extra code for next invocation:
+> ---
+> Rules:
+> ---
+> Execution order:
+> Not set because the hook is disabled.
<recently read> }
l. ...\ShowHook{ddd}
diff --git a/base/testfiles-lthooks/lthooks-029b.lvt b/base/testfiles-lthooks/lthooks-029b.lvt
new file mode 100644
index 00000000..b79a4a36
--- /dev/null
+++ b/base/testfiles-lthooks/lthooks-029b.lvt
@@ -0,0 +1,36 @@
+\RequirePackage[enable-debug]{expl3}
+\ExplSyntaxOn
+\debug_on:n { check-declarations , deprecation }
+\ExplSyntaxOff
+
+\input{regression-test}
+
+\documentclass{article}
+
+
+\begin{document}
+
+\START
+
+\AddToHook{cmd/baz/middle}{\typeout{middle cmd}}
+\AddToHook{baz/middle}{\typeout{middle no cmd}}
+\AddToHook{baz/middle}[X]{\typeout{X middle no cmd}}
+
+\ShowHook{baz/middle}
+
+\newcommand\baz{\typeout{baz start}
+ \UseHook{cmd/baz/middle}
+ \UseHook{baz/middle}
+ \typeout{baz end}}
+
+\baz
+
+\ActivateGenericHook{baz/middle}
+\ActivateGenericHook{cmd/baz/middle}
+
+\ShowHook{baz/middle}
+
+\baz
+
+
+\END
diff --git a/base/testfiles-lthooks/lthooks-029b.tlg b/base/testfiles-lthooks/lthooks-029b.tlg
new file mode 100644
index 00000000..995e62dc
--- /dev/null
+++ b/base/testfiles-lthooks/lthooks-029b.tlg
@@ -0,0 +1,36 @@
+This is a generated file for the l3build validation system.
+Don't change this file in any respect.
+-> The hook 'baz/middle':
+> The hook is not declared.
+> Code chunks:
+> X -> \typeout {X middle no cmd}
+> Document-level (top-level) code:
+> -> \typeout {middle no cmd}
+> Extra code for next invocation:
+> ---
+> Rules:
+> ---
+> Execution order:
+> Not set because the hook is undeclared.
+<recently read> }
+l. ...\ShowHook{baz/middle}
+baz start
+baz end
+-> The hook 'baz/middle':
+> Code chunks:
+> X -> \typeout {X middle no cmd}
+> Document-level (top-level) code (executed last):
+> -> \typeout {middle no cmd}
+> Extra code for next invocation:
+> ---
+> Rules:
+> ---
+> Execution order:
+> X.
+<recently read> }
+l. ...\ShowHook{baz/middle}
+baz start
+middle cmd
+X middle no cmd
+middle no cmd
+baz end
More information about the latex3-commits
mailing list.