Skip to content

Commit

Permalink
fix for #1459 (#1565)
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankMittelbach authored Nov 27, 2024
1 parent 8915fa7 commit d6aa629
Show file tree
Hide file tree
Showing 34 changed files with 2,700 additions and 2,402 deletions.
7 changes: 7 additions & 0 deletions base/changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ not part of the distribution.
* usrguide.tex:
Add syntax of \Make...case

2024-11-26 Frank Mittelbach <[email protected]>

* lthooks.dtx (subsection{Specifying code for next invocation}):
Add debugging message into \AddToHookNext and friends (gh/1459)

Slightly adjust messages in other places.

2024-11-17 Frank Mittelbach <[email protected]>

* ltmarks.dtx (section{Public interfaces for packages such as \pkg{multicol}}):
Expand Down
49 changes: 42 additions & 7 deletions base/lthooks.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
%<*driver>
% \fi
\ProvidesFile{lthooks.dtx}
[2024/10/29 v1.1k LaTeX Kernel (hooks)]
[2024/11/26 v1.1l LaTeX Kernel (hooks)]
% \iffalse
%
\documentclass{l3doc}
Expand Down Expand Up @@ -3707,11 +3707,13 @@
{
% \end{macrocode}
% However, first some debugging info if debugging is enabled:
% \changes{v1.1l}{2024/11/26}{Adjust debugging message (gh/1459)}
% \begin{macrocode}
\@@_debug:n{\iow_term:x{****~ Add~ to~
\@@_debug:n{\iow_term:x{[lthooks]~ Add~ to~
\@@_if_usable:nF {#1} { undeclared~ }
hook~ #1~ (#2)
\on@line\space <-~ \tl_to_str:n{#3}} }
hook~ '#1'~ (#2) \on@line
^^J [lthooks] \@spaces
<-~ \tl_to_str:n{#3}} }
% \end{macrocode}
% Then try to get the code chunk labeled \verb=#2= from the hook.
% If there's code already there, then append \verb=#3= to that,
Expand Down Expand Up @@ -5374,10 +5376,11 @@
% \end{macrocode}
% If we are debugging we show results hook by hook for all hooks
% that have data.
% \changes{v1.1l}{2024/11/26}{Adjust debugging message (gh/1459)}
% \begin{macrocode}
\@@_debug:n
{
\iow_term:x { ^^J All~initialized~(non-empty)~hooks: }
\iow_term:x { ^^J[lthooks]~ All~initialized~(non-empty)~hooks: }
\prop_map_inline:Nn \g_@@_used_prop
{
\iow_term:x
Expand Down Expand Up @@ -5433,13 +5436,14 @@
% afterwards only if the hook code changes.
% \changes{v1.1a}{2023/04/06}
% {Changes to add hook arguments (hook-args).}
% \changes{v1.1l}{2024/11/26}{Adjust debugging message (gh/1459)}
% \begin{macrocode}
%<latexrelease>\IncludeInRelease{2023/06/01}{\@@_initialize_hook_code:n}
%<latexrelease> {Hooks~with~args}
\cs_new_protected:Npn \@@_initialize_hook_code:n #1
{
\@@_debug:n
{ \iow_term:x { ^^J Update~code~for~hook~'#1' \on@line :^^J } }
{ \iow_term:x { ^^J[lthooks]~ 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
Expand Down Expand Up @@ -5732,9 +5736,10 @@
\exp_args:NNV \@@_tl_gput:Nn #1 \l_@@_return_tl
% \end{macrocode}
%
% \changes{v1.1l}{2024/11/26}{Adjust debugging message (gh/1459)}
% \begin{macrocode}
\@@_clist_gput:NV #2 \l_@@_front_tl
\@@_debug:n{ \iow_term:x{Handled~ code~ for~ \l_@@_front_tl} }
\@@_debug:n{ \iow_term:x{[lthooks]~ Handled~ code~ for~ \l_@@_front_tl} }
% \end{macrocode}
%
% This is step T6, except that we don't use a pointer $P$ to move
Expand Down Expand Up @@ -6535,12 +6540,42 @@
{
\@@_replacing_args_false:
\@@_normalize_hook_args:Nn \@@_gput_next_code:nn {#1} {#2}
% \end{macrocode}
%
% \changes{v1.1l}{2024/11/26}{Add debugging message (gh/1459)}
% \begin{macrocode}
\@@_debug:n{\iow_term:x{[lthooks]~ Add~ to~
\@@_if_usable:nF {#1} { undeclared~ }
hook~ '#1'~ ( next~ invocation~ only )
\on@line
^^J [lthooks] \@spaces
<-~ \tl_to_str:n{#2}
}
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_replacing_args_reset:
}
\cs_new_protected:Npn \hook_gput_next_code_with_args:nn #1 #2
{
\@@_replacing_args_true:
\@@_normalize_hook_args:Nn \@@_gput_next_code:nn {#1} {#2}
% \end{macrocode}
%
% \changes{v1.1l}{2024/11/26}{Add debugging message (gh/1459)}
% \begin{macrocode}
\@@_debug:n{\iow_term:x{[lthooks]~ Add~ to~
\@@_if_usable:nF {#1} { undeclared~ }
hook~ '#1'~ ( next~ invocation~ only )
\on@line
^^J [lthooks] \@spaces
<-~ \tl_to_str:n{#2}
}
}
% \end{macrocode}
%
% \begin{macrocode}
\@@_replacing_args_reset:
}
%<latexrelease>\EndIncludeInRelease
Expand Down
55 changes: 30 additions & 25 deletions base/testfiles-lthooks/filehook-002.tlg
Original file line number Diff line number Diff line change
@@ -1,73 +1,78 @@
This is a generated file for the l3build validation system.
Don't change this file in any respect.
Update code for hook 'package/before' on input line ...:
Update code for hook 'file/before' on input line ...:
[lthooks] Update code for hook 'package/before' on input line ...:
[lthooks] Update code for hook 'file/before' on input line ...:
(structuredlog.sty
Package: structuredlog ....-..-.. vv... Structuring the TeX transcript file
\g__filehook_nesting_level_int=\count...
**** Add to hook file/before (structuredlog) on input line ... <- \__filehook_log_file_record:n {START}
[lthooks] Add to hook 'file/before' (structuredlog) on input line ...
[lthooks] <- \__filehook_log_file_record:n {START}
[lthooks] Add to hook 'file/after' (next invocation only) on input line ...
[lthooks] <- \AddToHook {file/after}{\__filehook_log_file_record:n {STOP}}
)
Update code for hook 'file/after' on input line ...:
**** Add to hook file/after (structuredlog) on input line ... <- \__filehook_log_file_record:n {STOP}
Update code for hook 'package/after' on input line ...:
Update code for hook 'package/before' on input line ...:
Update code for hook 'file/before' on input line ...:
[lthooks] Update code for hook 'file/after' on input line ...:
[lthooks] Add to hook 'file/after' (structuredlog) on input line ...
[lthooks] <- \__filehook_log_file_record:n {STOP}
[lthooks] Update code for hook 'package/after' on input line ...:
[lthooks] Update code for hook 'package/before' on input line ...:
[lthooks] Update code for hook 'file/before' on input line ...:
Code labels for sorting:
structuredlog
Data structure for label rules:
structuredlog = 0 ->
Handled code for structuredlog
[lthooks] Handled code for structuredlog
= (LEVEL 1 START) tracefnt.sty
(tracefnt.sty
Package: tracefnt ....-..-.. v... Standard LaTeX package (font tracing)
\tracingfonts=\count...
LaTeX Info: Redefining \selectfont on input line ....
**** Add to hook selectfont (tracefnt) on input line ... <- \ifnum \tracingfonts >\tw@ \@font@info {Switching to \font@name }\fi
[lthooks] Add to hook 'selectfont' (tracefnt) on input line ...
[lthooks] <- \ifnum \tracingfonts >\tw@ \@font@info {Switching to \font@name }\fi
Applying: [....-..-..] Add hook to \selectfont on input line ....
Already applied: [....-..-..] Add hook to \selectfont on input line ....
)
Update code for hook 'file/after' on input line ...:
[lthooks] Update code for hook 'file/after' on input line ...:
Code labels for sorting:
structuredlog
Data structure for label rules:
structuredlog = 0 ->
Handled code for structuredlog
[lthooks] Handled code for structuredlog
= (LEVEL 1 STOP) tracefnt.sty
Update code for hook 'package/after' on input line ...:
Update code for hook 'class/before' on input line ...:
Update code for hook 'file/before' on input line ...:
[lthooks] Update code for hook 'package/after' on input line ...:
[lthooks] Update code for hook 'class/before' on input line ...:
[lthooks] Update code for hook 'file/before' on input line ...:
Code labels for sorting:
structuredlog
Data structure for label rules:
structuredlog = 0 ->
Handled code for structuredlog
[lthooks] Handled code for structuredlog
= (LEVEL 1 START) article.cls
(article.cls
Document Class: article ....-..-.. v... Standard LaTeX document class
Update code for hook 'file/before' on input line ...:
[lthooks] Update code for hook 'file/before' on input line ...:
Code labels for sorting:
structuredlog
Data structure for label rules:
structuredlog = 0 ->
Handled code for structuredlog
[lthooks] Handled code for structuredlog
== (LEVEL 2 START) size10.clo
(size10.clo
File: size10.clo ....-..-.. v... Standard LaTeX file (size option)
LaTeX Font Info: External font `cmr10 at10.0pt' loaded as
(Font) OT1/cmr/m/n/10 on input line ....
Update code for hook 'selectfont' on input line ...:
[lthooks] Update code for hook 'selectfont' on input line ...:
Code labels for sorting:
tracefnt
Data structure for label rules:
tracefnt = 0 ->
Handled code for tracefnt
[lthooks] Handled code for tracefnt
)
Update code for hook 'file/after' on input line ...:
[lthooks] Update code for hook 'file/after' on input line ...:
Code labels for sorting:
structuredlog
Data structure for label rules:
structuredlog = 0 ->
Handled code for structuredlog
[lthooks] Handled code for structuredlog
== (LEVEL 2 STOP) size10.clo
\c@part=\count...
\c@section=\count...
Expand All @@ -81,11 +86,11 @@ Handled code for structuredlog
\belowcaptionskip=\skip...
\bibindent=\dimen...
)
Update code for hook 'file/after' on input line ...:
[lthooks] Update code for hook 'file/after' on input line ...:
Code labels for sorting:
structuredlog
Data structure for label rules:
structuredlog = 0 ->
Handled code for structuredlog
[lthooks] Handled code for structuredlog
= (LEVEL 1 STOP) article.cls
Update code for hook 'class/after' on input line ...:
[lthooks] Update code for hook 'class/after' on input line ...:
39 changes: 39 additions & 0 deletions base/testfiles-lthooks/github-1459.lvt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

\ExplSyntaxOn
\debug_on:n { check-declarations , deprecation }
\ExplSyntaxOff

\documentclass{article}

\input{regression-test}

\newcommand\baz{}

\begin{document}

\START

\DebugHooksOn

\AddToHookNext{cmd/baz/before}{\typeout{--> next \string\baz 1}}

\AddToHookNext{foo}{\typeout{--> undeclared foo}}

\AddToHookNext{para/before}{\typeout{--> para/before 1}}

\typeout{--------- same without Next ----------}

\AddToHook{cmd/baz/before}{\typeout{--> next \string\baz 2}}

\AddToHook{foo}{\typeout{--> undeclared foo}}

\AddToHook{para/before}{\typeout{--> para/before 2}}


\baz

contenu...

\DebugHooksOff

\END
30 changes: 30 additions & 0 deletions base/testfiles-lthooks/github-1459.tlg
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
This is a generated file for the l3build validation system.
Don't change this file in any respect.
-> Adding cmd hook to 'baz' (before):
[lthooks] analyzing '\baz'
[lthooks] \baz=\long macro:->
[lthooks] ++ control sequence is defined
[lthooks] ++ control sequence is a macro
[lthooks] ++ macro is not private
[lthooks] ++ command can be patched without rescanning
[lthooks] Update code for hook 'cmd/baz/before' on input line ...:
[lthooks] Add to hook 'cmd/baz/before' (next invocation only) on input line ...
[lthooks] <- \typeout {--> next \string \baz 1}
[lthooks] Update code for hook 'foo' on input line ...:
[lthooks] Add to undeclared hook 'foo' (next invocation only) on input line ...
[lthooks] <- \typeout {--> undeclared foo}
[lthooks] Add to hook 'para/before' (next invocation only) on input line ...
[lthooks] <- \typeout {--> para/before 1}
--------- same without Next ----------
[lthooks] Add to hook 'cmd/baz/before' (top-level) on input line ...
[lthooks] <- \typeout {--> next \string \baz 2}
[lthooks] Update code for hook 'cmd/baz/before' on input line ...:
[lthooks] Add to undeclared hook 'foo' (top-level) on input line ...
[lthooks] <- \typeout {--> undeclared foo}
[lthooks] Add to hook 'para/before' (top-level) on input line ...
[lthooks] <- \typeout {--> para/before 2}
[lthooks] Update code for hook 'para/before' on input line ...:
--> next \baz2
--> next \baz1
--> para/before 2
--> para/before 1
Loading

0 comments on commit d6aa629

Please sign in to comment.