# Prepend/Append to Field Format in BibLaTeX

Consider the eprint:arxiv. It is originally defined in biblatex.def as:

\DeclareFieldFormat{eprint:arxiv}{%
\ifhyperref
{\href{http://arxiv.org/\abx@arxivpath/#1}{%
\iffieldundef{eprintclass}
{}
\iffieldundef{eprintclass}
{}


but suppose I want all arXiv links to appear in red, then I need:

\DeclareFieldFormat*{eprint:arxiv}{{% Note the extra brace
\color{red}%
\ifhyperref
{\href{http://arxiv.org/\abx@arxivpath/#1}{%
\iffieldundef{eprintclass}
{}
\iffieldundef{eprintclass}
{}


The problem, however, is that this will override any modification to the eprint:arxiv field format that may have been introduced by another style.

Is there a way to make modifications to a field format in a style-agnostic manner? Obviously, this will (and should) not modify the existing output of a style but just wrap around it (and as a result, I understand that if the style already has a {\color{blue}...} for their arXiv links, then wrapping it with {\color{red}...} won't do anything)

I thought that the \savefieldformat and \restorefieldformat commands may have been helpful, but it doesn't seem like it now and I can't find anything else within the documentation that might help.

As a little extra, it would be great if there was a function such as \AddToFieldFormat[<entrytype...>]{<field>}{<code>} so that modifying eprint:arxiv would be

\AddToField{eprint:arxiv}{{\color{red}#1}}


and where #1 is the by the previous bibliography style's output.

egreg's xpatch package seems the way to go. Amongst others it provides \xpretofieldformat to prepend code to the field definitions

You just need

\xpretofieldformat{eprint:arxiv}{\color{red}}{}{}


MWE

\documentclass{article}
\usepackage[style=verbose,backend=biber]{biblatex}