You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
\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?
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.
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
Log file (required) and possibly PDF file
texstudio_FNpaGC.log
The text was updated successfully, but these errors were encountered: