we had a bit of discussion some time ago on how to extend xparse
here is one suggestion which i think might be of interest:
suppose we have a parsing class "x" in the second argument of
\DeclareUserCommand which would take a list of tokens (for example comma
spearated) and parses the input to see if any of those tokens follows. If so
it would return \BooleanTrue otherwise \BooleanFalse. eg
\DeclareUserCommand \footnotemark { o x{\footnotemark,\footnote} }
would scan for an optional argument and returns it as #1 (or \NoValue if not
found) and then scans for either \footnotemark or \footnote and returns
\BooleanTrue or False respectively
if this is a sensible extension (not sure) one has to be clear about a couple
of points:
a) is the parsing happening only on top-level of the source document or does
one parse using expansion? That is, if the user says
\newcommand\fn[1]{\footnote{#1}} would \footnotemark\fn{foo} see the hidden
\footnote or not? --- i think it probably should find it
b) what do we do about spaces: is the first in \footnote{foo} \footnote{bar}
seeing the second one despite the fact that there is a space inbetween and if
so what happens to this space? --- again i think it should probably see the
second footnote (or perhaps there should be a variation class "X" that can
look past such spaces) but it would need to communicate that such a space is
there (somehow)
any suggestions/comments on something like this? --- it certainly would need
some further thought to become useful (if it is useful at all)
anybody out there who needs a nightcap puzzle? would be interesting to
experiment with such an implementation.
frank