The core of my question is how to define a macro that does something different the first time it is called with a given argument. And further, have the ability to reset that so that that first time behaviour can be restored.
I want to use this to cause citations to show the cited work's title the first time they are used, in the margin.
This is what I have come up with, using etoolbox flags.
\documentclass[]{article}
\usepackage{etoolbox}
\usepackage[style=authoryear, backend=biber]{biblatex}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Arguments: namespace,key,if first-action, if-not-first action
\newcommand{\iffirstuse}[4]{%
\global\providetoggle{#1#2}%
\global\nottoggle{#1#2}{#3}{#4}%
\global\toggletrue{#1#2}%
}
\let\oldcite\cite
\def\citenamespace{citeA}
\renewcommand{\cite}[1]{%
\iffirstuse{\citenamespace}{#1}%
{%
\oldcite{#1}%
\marginpar{\citetitle{#1}}%
}{%
\oldcite{#1}%
}%
}
\newcommand{\resetcitescount}{%
\xdef\citenamespace{{\citenamespace}A}
}
%%%%%%%%%%%%%%%%%%%%%%
\begin{filecontents}{\jobname.bib}
@book{Labov1972,
Address = {Philadelphia},
Author = {William Labov},
Publisher = {University of Pennsylvania Press},
Title = {Sociolinguistic Patterns},
Year = {1972}}
@book{Chomsky1957,
Address = {The Hague},
Author = {Noam Chomsky},
Publisher = {Mouton},
Title = {Syntactic Structures},
Year = {1957}}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
It was said that there were patterns (\cite{Labov1972}.)\\
\cite{Labov1972} speaks of patterns in language based on society.\\
This can be contrasted with the earlier work of \cite{Chomsky1957}.\\
\cite{Labov1972} is newer than \cite{Chomsky1957}\\
With all that said\\
and all that done\\
\resetcitescount{}
Do not forget \cite{Chomsky1957}
\end{document}
This works, but I am not sure if it is the best way.
Further I don't know how well it would scale to all the complexities of the different cite commands in biblatex, like \parencite{refone,reftwo,refthree}.
Is there a smarter way to do this?


\ifciteseento check whether the current citation key has been seen before. It must be activated with thecitetrackeroption. The tracker can be reset with\citereset. – moewe Aug 27 '18 at 11:47