This question led to a new feature in a package:
xpatch
The etoolbox package provides various tools that "are useful to hook into or modify existing code" (etoolbox manual, section 3.4). The most important one is the \patchcmd command with the syntax
\patchcmd[<prefix>]{<command>}{<search>}{<replace>}{<success>}{<failure>}
which "extracts the replacement text of a <command>, replaces [the first occurence of] <search>
with <replace>, and reassembles the <command>". Other useful macros are, e.g., \apptocmd and \pretocmd which will append resp. prepend code to the replacement text of a command.
The biblatex package features the commands \newbibmacro, \renewbibmacro, and \providebibmacro (plus their starred counterparts). These commands resemble \newcommand/\renewcommand/\providecommand "except that [the command name] may contain characters such as numbers and punctuation marks and does not start with a backslash" (biblatex manual, section 4.6.4). The "bibmacros" defined this way may be executed via \usebibmacro{<command name>}.
Is it possible to define a \patchbibmacro command that extracts and modifies the replacement text of macros created with \newbibmacro the same way \patchcmd does for macros created with \newcommand?
optvariants is inadvisable? If not, why not use just these variants (and rename them)? – lockstep Jan 10 '12 at 22:46\newbibmacro{foo}[1]{...}), you mustn't use the "opt" variant. It would be possible to catch this automatically, but it's complicated and I don't think it's worth a try. However, you can look forxpatchcmdon the site for an automatic solution that could be ported to this case. – egreg Jan 10 '12 at 22:51xpatchpackage that incorporates code for this kind of patching. – egreg Jan 12 '12 at 21:54