Saving Aristotle: How can Biblatex redefinitions be made conditional on the style selected (or otherwise made more fool-proof)?

In general

\Citeauthor{aristotle:rhetoric,aristotle:poetics}


will typeset Aristotle; Aristotle rather than simply Aristotle. In order to avoid this, I asked for help getting \citeauthor and friends to behave more like their \textcite counterparts. In response, I got an excellent answer from moewe which became a chunk of code in my biblatex.cfg.

This works very nicely for authoryear styles. However, it does not work so well in other cases. This is perfectly understandable, but I'd like to make it more proof against human errors (mine, especially).

In an ideal world, the code would obviously work with all styles. However, I'm hoping that the following question may be more realistic:

Is it possible to check the current style in order to execute the changes only if a known-compatible style has been loaded? Is the (citation) style stored in a macro I could check, for example?

Obviously, I would then be back to Aristotle; Aristotle, but I can live with that. What I'd like to avoid is the altogether more sinister scenario in which Aristotle is not cloned, but rather eliminated or disappeared.

\documentclass{article}
\usepackage[backend=biber,style=verbose]{biblatex}
\bibliography{biblatex-examples}
\makeatletter
% ateb moewe: http://tex.stackexchange.com/a/352471/ addaswyd o gôd Biblatex am \textcite et al.
% BEGIN redefine \citeauthor et al. to behave more like \textcite et al.
\providebibmacro*{cite:reinit}{%
\global\undef\cbx@lasthash
\global\undef\cbx@lastyear
}
\providebibmacro*{cite:init}{\usebibmacro{cite:reinit}}

\newbibmacro*{citeauthor}{%
\ifnameundef{labelname}
{\usebibmacro{cite:reinit}}
{%
\iffieldequals{namehash}{%
\cbx@lasthash
}{}{%
\printnames{labelname}%
\stepcounter{textcitecount}%
\savefield{namehash}{\cbx@lasthash}%
}%
}%
\setunit{\textcitedelim}%
}

\DeclareCiteCommand{\cbx@citeauthor}
{%
\usebibmacro{cite:init}%
}{%
\usebibmacro{citeindex}%
\usebibmacro{citeauthor}%
}{}{%
\usebibmacro{postnote}%
}

\providerobustcmd{\cbx@textcite@init}[2]{%
\setcounter{textcitetotal}{0}%
\setcounter{textcitecount}{0}%
\def\cbx@savedcites{#1}#2\cbx@savedcites\empty}

\DeclareCiteCommand{\citeauthor}[\cbx@textcite@init\cbx@citeauthor]{%
\gdef\cbx@savedkeys{}%
\citetrackerfalse
\pagetrackerfalse
\DeferNextCitekeyHook
\usebibmacro{cite:init}%
}{%
\ifthenelse{%
\iffirstcitekey\AND\value{multicitetotal}>0%
}{%
\protected@xappto\cbx@savedcites{()(\thefield{multipostnote})}%
\global\clearfield{multipostnote}%
}{}%
\xappto\cbx@savedkeys{\thefield{entrykey},}%
\iffieldequals{namehash}{%
\cbx@lasthash
}{}{%
\stepcounter{textcitetotal}%
\savefield{namehash}{\cbx@lasthash}%
}%
}{}
{%
\protected@xappto\cbx@savedcites{%
[\thefield{prenote}][\thefield{postnote}]{\cbx@savedkeys}%
}%
}

\DeclareDelimcontextAlias{cbx@citeauthor}{textcite}

% END redefine \citeauthor et al
\makeatother
\begin{document}
\Citeauthor{aristotle:rhetoric,aristotle:poetics}
\end{document}


The current styles are stored in the internal macros \blx@bbxfile and \blx@cbxfile. Happy branching!

\documentclass{article}

\usepackage[style=authoryear,citestyle=verbose]{biblatex}

\begin{document}

\csname blx@bbxfile\endcsname

\csname blx@cbxfile\endcsname

\end{document}


• Brilliant! I knew it must be somewhere ... ;). Works great - see below. I guess verbose styles are peculiarly tricky or something. – cfr Apr 19 '17 at 16:38

This is a supplement to Henri Menke's answer, just in case anybody else needs something like this. Based on that answer, here's how I set the conditionalisation up in biblatex.cfg.

% ateb Henri Menke: https://tex.stackexchange.com/a/365438/
% bibstyle name: \csname blx@bbxfile\endcsname
% citestyle name: \csname blx@cbxfile\endcsname

\newif\ifcfr@biblatex@authorcomp
\cfr@biblatex@authorcompfalse
\def\cfr@blx@splitfile#1-#2\@null{#1}
\edef\tempa{\expandafter\cfr@blx@splitfile\blx@cbxfile-x\@null}
\edef\tempb{authoryear}
\edef\tempc{authortitle}
\edef\tempd{alphabetic}
\edef\tempe{numeric}
\ifx\tempa\tempb
\cfr@biblatex@authorcomptrue
\else\ifx\tempa\tempc
\cfr@biblatex@authorcomptrue
\else\ifx\tempa\tempd
\cfr@biblatex@authorcomptrue
\else\ifx\tempa\tempe
\cfr@biblatex@authorcomptrue
\else\ifx\tempa\tempf
\cfr@biblatex@authorcomptrue
\fi
\fi
\fi
\fi
\fi

\ifcfr@biblatex@authorcomp

...

\else

...

\fi


It turns out that pretty much any style but verbose is fine with the redefinitions provided by moewe. But, just to be on the safe-side, I've gone for a more long-winded check against standard styles which work OK, excluding verbose, which isn't OK, and draft and debug which are special cases.