Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

\hook_debug_on: does not log changes made by AddToHookNext #1459

Open
ysalmon opened this issue Sep 6, 2024 · 3 comments
Open

\hook_debug_on: does not log changes made by AddToHookNext #1459

ysalmon opened this issue Sep 6, 2024 · 3 comments
Assignees
Labels
bug (documentation) category base (latex) enhancement fixed in dev Fixed in development branch, not in stable release

Comments

@ysalmon
Copy link

ysalmon commented Sep 6, 2024

Brief outline of the bug

I am trying to debug some code that uses AddToHookNext and ClearHookNext with \hook_debug_on:. However, these do not seem to be tracked by it. When modifying a cmd hook, there is a trace in the log as lthooks analyses the command, but the actual update is not logged with as much precision as with AddToHook. And for the para hook, nothing shows.

Minimal example showing the bug

\RequirePackage{latexbug}
\documentclass{article}
\begin{document}
\ExplSyntaxOn
\hook_debug_on:
\ExplSyntaxOff
\AddToHookNext{cmd/par/before}{\relax}
\AddToHookNext{para/before}{\relax}
contenu...
\ExplSyntaxOn
\hook_debug_off:
\ExplSyntaxOff
\end{document}

Log file (required) and possibly PDF file

texstudio_FNpaGC.log

@FrankMittelbach
Copy link
Member

If your code really attempts to add a hook into \par then I'm not surprised that you need to debug it. This can't work, because LaTeX redefines \par back and forth all over the place, so the cmd/par/before would vanish again from the definition of \par leaving the whole setup in a strange state.

@FrankMittelbach
Copy link
Member

\documentclass{article}
\begin{document}
\DebugHooksOn

\AddToHookNext{cmd/par/before}{\typeout{-> cmdHook1}}
\AddToHook{para/before}{\typeout{-> before hook always}}
\AddToHookNext{para/before}{\typeout{-> before hook1}}
\ShowHook{cmd/par/before}
\ShowCommand\par
contenu...

\begin{itemize}
\item
\end{itemize}

\ShowHook{cmd/par/before}
\ShowCommand\par            % <--- cmd hook lost

\AddToHookNext{cmd/par/before}{\typeout{-> cmdHook2}}
\AddToHookNext{para/before}{\typeout{-> before hook2}}
\ShowHook{cmd/par/before}   % <--- but still believed to be there
\ShowCommand\par

test

\end{document}

I agree that \AddToHookNext should perhaps also write something like

**** Add to hook para/before (top-level) on input line 6 <- \typeout {-> before
 hook always}

but that wouldn't help here because the problem is that the command to which the cmd hook is added gets redefined.
Now that is something we can't really test for (ok for \par we know but to single that out seems pointless). What we can do is to add a warning in the documentation perhaps.

By the way, why do you try to use cmd/par/before, If there is a perfectly fine para/before already?

@ysalmon
Copy link
Author

ysalmon commented Sep 6, 2024

The use case is explained there, and indeed, the redefinitions of \par make it tricky. But I think I managed to get something that more or less works, and the present report is in fact not at all about having hooks into \par, but the way the hook debugging system works with \AddToHookNext for any hook.

@josephwright josephwright added this to the Release 2025 Spring milestone Oct 22, 2024
@github-project-automation github-project-automation bot moved this to Pool (unscheduled issues) in upcoming LaTeX2e releases Oct 22, 2024
FrankMittelbach added a commit that referenced this issue Nov 26, 2024
FrankMittelbach added a commit that referenced this issue Nov 26, 2024
FrankMittelbach added a commit that referenced this issue Nov 26, 2024
This reverts commit 055eb78.
@FrankMittelbach FrankMittelbach moved this from Pool (unscheduled issues) to In progress in upcoming LaTeX2e releases Nov 26, 2024
FrankMittelbach added a commit that referenced this issue Nov 27, 2024
@FrankMittelbach FrankMittelbach moved this from In progress to Done in dev in upcoming LaTeX2e releases Dec 10, 2024
@FrankMittelbach FrankMittelbach added fixed in dev Fixed in development branch, not in stable release and removed fixed in branch labels Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug (documentation) category base (latex) enhancement fixed in dev Fixed in development branch, not in stable release
Projects
Status: Done in dev
Development

No branches or pull requests

3 participants