latex3 / latex2e

The LaTeX2e kernel
https://www.latex-project.org/
LaTeX Project Public License v1.3c
1.96k stars 267 forks source link

`\ShowHook` does not recognize generic hooks #1220

Open jlaurens opened 11 months ago

jlaurens commented 11 months ago

Brief outline of the bug

According to section 2.6 Generic hooks provided by packages of lthooks.pdf, babel/⟨language⟩/afterextras is a generic hook, but that is not what gives \ShowHook

Actually, hooks are either

Either \ActivateGenericHook should make the hook generic if it is not already a generic hook, or the correct hook categorization should be

and \ShowHook only recognizes the builtin generic.

The documentation should be amended in both cases.

Minimal example showing the bug

\nonstopmode
\RequirePackage{latexbug}       % <--should be always the first line (see CONTRIBUTING)!
\documentclass{article}
\begin{document}
\ShowHook{babel/french/afterextras}
\ActivateGenericHook{babel/french/afterextras}
\ShowHook{babel/french/afterextras}
\end{document}

Log file (required) and possibly PDF file

2.log

github-actions[bot] commented 9 months ago

This issue has been automatically marked as stale because it has not had recent activity.

josephwright commented 7 months ago

Did one of your suggested improvements to \ShowHooks touch on this?

muzimuzhi commented 7 months ago

According to section 2.6 Generic hooks provided by packages of lthooks.pdf, babel/⟨language⟩/afterextras is a generic hook, but that is not what gives \ShowHook

The last paragraph of section 2.6 Generic hooks says (bold style added by me)

Generic hooks defined in this way are always normal hooks (i.e., you can’t implement reversed hooks this way). This is a deliberate limitation, because it speeds up the processing considerably.

So it seems to me it works as expected that code

\ShowHook{babel/french/afterextras}
\ActivateGenericHook{babel/french/afterextras}
\ShowHook{babel/french/afterextras}

writes to log

-> The hook 'babel/french/afterextras':
> The hook is not declared.
> The hook is empty.
<recently read> }

l.5 \ShowHook{babel/french/afterextras}

-> The hook 'babel/french/afterextras':
> The hook is empty.
<recently read> }

l.7 \ShowHook{babel/french/afterextras}
jlaurens commented 7 months ago

@josephwright PR #1250 is related to this bug/feature request but does not fix it. PR #1250 is still a draft PR as long as I have no positive agreement on the concept there. The documentation must be modified accordingly because it also refers to the output of the old \ShowHook and IIRC some test files are missing.

@muzimuzhi Paragraph 2.6 is not crystal clear, my interpretation is that locally "normal hook" only means "non reversed", it does not mean "non generic". In particular, applying \ActivateGenericHook to a hook that is not generic seems contradictory provided the command name does refer to "activating a generic hook".

josephwright commented 7 months ago

@jlaurens I think we had no issue with the core idea in #1250 - but it needs to be focussed just on that change.

muzimuzhi commented 7 months ago

@muzimuzhi Paragraph 2.6 is not crystal clear, my interpretation is that locally "normal hook" only means "non reversed", it does not mean "non generic". In particular, applying \ActivateGenericHook to a hook that is not generic seems contradictory provided the command name does refer to "activating a generic hook".

Maybe "generic" hooks other than cmd, env, file, include, package, and class need a new name, like semi-generic hooks or so.

jlaurens commented 7 months ago

Or call cmd, env, file, include, package, and class related hook "builtin generic hooks" and call the other generic ones "custom generic hooks"?