Is it actually true that every command `\⟨name⟩` offers now two associated hooks to which code can be added using `\AddToHookWithArguments` and `\AddToHookNextWithArguments`?
The ltcmdhooks-doc reads:
This file implements generic hooks for (arbitrary) commands. In theory every command
\⟨name⟩offers now two associated hooks to which code can be added using\AddToHook,¹\AddToHookNext,\AddToHookWithArguments, and\AddToHookNextWithArguments.²
So I naïvely thought e.g. \AddToHookWithArguments{cmd/⟨name⟩/before}{...} might apply to ⟨name⟩=section.
But, IIUC, not every command \⟨name⟩ offers these two associated hooks to which code can be added using \AddToHookWithArguments and \AddToHookNextWithArguments: in particular, not all (or any of the?) commands documented in e.g. LaTeX2e: An unofficial reference manual are concerned and only the ones documented in source2e.pdf are. If so, it is worth IMO to add this precision in the documentation.
It's one of the limitations of command hooks, see texdoc ltcmdhooks-doc, sec. 2.2 "Commands that look ahead":
Some commands are defined in different “steps” and they look ahead in the input stream to find more arguments. If you try to add some code to the
cmd/⟨name⟩/afterhook of such command, it will not work, and it is not possible to detect that programmatically, so the user has to know (or find out) which commands can or cannot have hooks attached to them. One good example is the\sectioncommand. You can add something to the cmd/section/before hook, but if you try to add something to thecmd/section/afterhook,\sectionwill no longer work. That happens because the\sectionmacro takes no argument, but instead calls a few internal LaTeX macros to look for the optional and mandatory arguments. By adding code to thecmd/section/afterhook, you get in the way of that scanning.
It's one of the limitations of command hooks, see
texdoc ltcmdhooks-doc, sec. 2.2 "Commands that look ahead":
Okay but, in my question on TeX.SE, I added something only to the cmd/section/before hook.
As Ulrike Fischer commented in your TeX.SE question, that's because "\section has no arguments at all."
Looks like the words in sec. 2.2 "Commands that look ahead" can be refined.
As Ulrike Fischer commented in your TeX.SE question, that's because "\section has no arguments at all."
Okay but, once again, LaTeX2e: An unofficial reference manual contains plenty of commands that, at a first glance, do have arguments (and \section is one of them). Hence how a user could proceed to know which of them do actually have arguments, if he wants to play with \AddToHookWithArguments{cmd/⟨name⟩/before}{...}?
Command hooks are different to other generic hooks. They are not built-in but normally have to be patched into the commands. That makes them more fragile and also more difficult to use. E.g. with french this patching can easily fail as it changes catcodes of various chars. In a class I wouldn't use them to adapt section. Redefine the command properly, then you can also declare and add the code hook explicitly.
@u-fischer In fact, my initial concern was with biblatex's \addbibresource, not with \section: I gave an MCE with the latter in order to make my question less specific.
Anyway, the ltcmdhooks-doc deserves improvements IMO.