Joseph,

 > Frank Mittelbach wrote:
 > > Joseph,
 > > 
 > >  > I've been trying to work out if the current expl3 has anything like
 > >  > \patchcmd from etoolbox.  
 > > 
 > > the current expl3 doesn't have something comparible to \patchcmd, not on that
 > > level of complexity / generality
 > > 
 > > 
 > >  > Will suggested looking at the various \tlp_
 > >  > ... macros.  However, even a simple two-part test in this way fails:
 > >  > 
 > >  > \documentclass{article}
 > >  > \usepackage{expl3}
 > >  > \CodeStart
 > >  > \cs_if_really_exist:cT{thanks}{
 > >  >   \tlp_if_in:NnT\thanks{\footnotemark}{
 > >  >     % Do something
 > >  >   }
 > >  >   \tlp_if_in:NnT\thanks{\footnotetext}{
 > >  >     % Also do something
 > >  >   }
 > >  > }
 > >  > \CodeStop
 > >  > \begin{document}
 > >  > \end{document}
 > >  > 
 > >  > I guess I'm abusing the functions.  So have I missed something obvious?
 > > 
 > > well, one thing obvious is \thanks is not a "tlp" variable is it?
 > 
 > No.  

ok some sort of obvious :-) like for me, but you'll agree that \thanks is not
a tlp as it expects an argument (ie it therefore a function)

 > The original context of the suggestion was that I couldn't see a
 > replacement for \g@addto@macro (I may of course have missed it).  Here,
 > using one of the \tlp_put functions does work.  So I was extrapolating!

well the \tlp_put functions work because in 2e \g@addto@macro  only works for
macros without arguments (ie "tlp"s in expl3 terminology)

try

\show\thanks

\g@addto@macro\thanks{foo}

\show\thanks


 > I'm guessing that something like \g@addto@macro will be needed, in the end.

so \tlp_gput_right:Nn is indeed the replacement for \g@addto@macro (which
would have been better named \g@addto@macro@not@having@arguments)


 >  > The \patchcmd does detokenization (loosing catcodes) and then
 > rebuilds the
 > > code using "current" catcodes, so it is kind of dangerous in situations
 > 
 > At least in the context I was thinking of, this would not be an issue.
 > I'd imagine that stuff with funny catcodes wouldn't typically be where a
 > simple find-and-replace would apply.

and even if, I agree that for certain types of questions (packages on top of
packages) such a patching functionality would be useful.

and providing \patchcmd shouldn't be too difficult

good night
frank