[latex3-commits] [git/LaTeX3-latex3-latex2e] lthooks2: \AddToHookNext needs to update the hook code sometimes (f5e6d98d)

PhelypeOleinik tex.phelype at gmail.com
Sat Aug 22 22:47:23 CEST 2020


Repository : https://github.com/latex3/latex2e
On branch  : lthooks2
Link       : https://github.com/latex3/latex2e/commit/f5e6d98d9ce9f8b44a4b4eb8efe9e3fde2b91d33

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

commit f5e6d98d9ce9f8b44a4b4eb8efe9e3fde2b91d33
Author: PhelypeOleinik <tex.phelype at gmail.com>
Date:   Sat Aug 22 17:47:23 2020 -0300

    \AddToHookNext needs to update the hook code sometimes


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

f5e6d98d9ce9f8b44a4b4eb8efe9e3fde2b91d33
 base/lthooks.dtx                       | 6 +++++-
 base/testfiles-lthooks/lthooks-009.tlg | 7 ++++---
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/base/lthooks.dtx b/base/lthooks.dtx
index 54aede99..afdd0625 100644
--- a/base/lthooks.dtx
+++ b/base/lthooks.dtx
@@ -3271,10 +3271,14 @@
 %   don't get lost.  \cs{tl_gclear:c} is used instead of
 %   \cs{tl_gclear:N} in case the hook is used in an expansion-only
 %   context, so the token list doesn't expand before \cs{tl_gclear:N}:
-%   that would make an infinite loop.
+%   that would make an infinite loop.  Also in case the main code token
+%   list is empty, the hook code has to be updated to add the next
+%   execution token list.
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_gput_next_do:Nnn #1 #2
   {
+    \tl_if_empty:cT { g_@@_#2_code_tl }
+      { \@@_update_hook_code:n {#2} }
     \tl_if_empty:NT #1
       { \tl_gset:Nn #1 { \tl_gclear:c { g_@@_#2_next_code_tl } } }
     \tl_gput_right:Nn #1
diff --git a/base/testfiles-lthooks/lthooks-009.tlg b/base/testfiles-lthooks/lthooks-009.tlg
index 060beb9a..63f91a00 100644
--- a/base/testfiles-lthooks/lthooks-009.tlg
+++ b/base/testfiles-lthooks/lthooks-009.tlg
@@ -68,6 +68,7 @@ Std sffamily code
 Update code for hook 'sffamily' on input line ...:
 only this code
 Nothing?
+Update code for hook 'hook' on input line ...:
 The hook 'hook':
  Code chunks:
     ---
@@ -76,7 +77,7 @@ The hook 'hook':
  Rules:
     ---
  Execution order:
-Use 'hook': 
+Use 'hook': \tl_gclear:c {g__hook_hook_next_code_tl}Hello, \AddToHookNext {hook}{nested}world!
 The hook 'hook':
  Code chunks:
     ---
@@ -85,7 +86,7 @@ The hook 'hook':
  Rules:
     ---
  Execution order:
-and again: 
+and again: \tl_gclear:c {g__hook_hook_next_code_tl}Hello, \AddToHookNext {hook}{nested}world!
 The hook 'hook':
  Code chunks:
     ---
@@ -94,7 +95,7 @@ The hook 'hook':
  Rules:
     ---
  Execution order:
-once more: 
+once more: \tl_gclear:c {g__hook_hook_next_code_tl}Hello, \AddToHookNext {hook}{nested}world!
 The hook 'hook':
  Code chunks:
     ---





More information about the latex3-commits mailing list.