I'm trying to patch some bidi footnote commands (\@footnotetext, \@LTRfootnotetext, and \@RTLfootnotetext) in biblatex.
The footnote patching commands in biblatex occur in an AtEndPreamble macro in biblatex.sty.
And I'm trying to use #1 as a hook in \patchcmd.
This is a combination which fails, and I'm looking for ideas as to the best way around the problem.
MWE:
\documentclass{article}
\usepackage{etoolbox}
\usepackage{bidi}
\tracingpatches
\newtoggle{blx@footnote}
\makeatletter
\AtEndPreamble{%
\patchcmd\@footnotetext
{#1}
{\toggletrue{blx@footnote}#1}
{\def\patchresult{success}}
{\def\patchresult{failure}}}%
\makeatother
\begin{document}
\patchresult
\end{document}
\@footnotetext is defined this way in bidi:
\long\def\@footnotetext#1{%
\footdir@write
\footdir@fntext{\bidi@footdir@footnote}%
\stepcounter{footdir@label}%
\footdir@fntext{\bidi@footdir@footnote}%
\footdir@toks{#1}%
\footdir@toks\expandafter
{\the\expandafter\footdir@toks
\expandafter \zref@labelbyprops
\expandafter{\thefootdir@label}{abspage}}%
\expandafter\footdir@ORG@bidi@footnotetext
\expandafter{\the\footdir@toks}}
This is in order to fix issue #412 in biblatex. See https://github.com/plk/biblatex/issues/412