I'm trying to patch biblatex's bibmacro cite using xpatch's \xpretobibmacro and \xapptobibmacro in a way that would require (I think...) to give unbalanced braces to the patch commands. Namely, I'd like to patch the cite bibmacro in the form "if the entry is of a certain entrytype, do as I say, otherwise do what you would normally do".
So, I thought of using xpatch for this, which would enable me to do this patch irrespective of the current citestyle, which is pretty much what I'd like to. But, to do this, I'd need to prepend the conditional with a hanging open brace, and append a single close brace. Which, of course, makes latex complain.
Is there a way to do this?
Here a MWE:
\documentclass{article}
\usepackage[style=authoryear]{biblatex}
\usepackage{xpatch}
\addbibresource{biblatex-examples.bib}
% This is the desired end result, which works
\renewbibmacro*{cite}{%
\ifentrytype{article}
{This is an article.}
{\iffieldundef{shorthand}
{\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
{\usebibmacro{cite:label}%
\setunit{\printdelim{nonameyeardelim}}}
{\printnames{labelname}%
\setunit{\printdelim{nameyeardelim}}}%
\usebibmacro{cite:labeldate+extradate}}
{\usebibmacro{cite:shorthand}}}%
}
% This is what I'd like to do, which doesn't work
%\xpretobibmacro{cite}{%
% \ifentrytype{archive}
% {This is an article.}
% {%
% }
%{}{}% <success> and <failure>
%
%\xapptobibmacro{cite}{}}
%{}{}% <success> and <failure>
\xshowbibmacro{cite}
\begin{document}
An article: \cite{bertram}.
A book: \cite{gerhardt}.
\end{document}

l3regexfor details, but I couldn't find it either with texdoc or on the package page on CTAN. Am I missing somewhere obvious where I should be looking? – gusbrs Jan 14 '18 at 18:19