From 639318d6e7443445fe3f9ffdeae3ff73b1266c94 Mon Sep 17 00:00:00 2001
From: Robert Alessi <alessi@robertalessi.net>
Date: Thu, 4 Oct 2018 17:18:54 +0200
Subject: new biblatex engine

---
 _preamble_bbl.tex | 140 ++++++++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 120 insertions(+), 20 deletions(-)

(limited to '_preamble_bbl.tex')

diff --git a/_preamble_bbl.tex b/_preamble_bbl.tex
index 383f396..c0e41fa 100644
--- a/_preamble_bbl.tex
+++ b/_preamble_bbl.tex
@@ -1,21 +1,121 @@
-\usepackage[style=footnote-dw, xref=true, loccittracker, opcittracker,
-autopunct=false, ibidemfont=italic, idemfont=italic,
-citeauthorname=firstfull, idembibformat=dash, nopublisher=false,
-annotation=true, pageref=true, journalnumber=date,
-acronyms=true]{biblatex}
-
-\DefineBibliographyExtras{french}{%
-  \renewcommand{\mkbibnamefamily}[1]{#1}%
-}
-\renewcommand{\mkbibacro}[1]{%
-  \textls[55]{\scalefont{0.95}#1}\isdot}
-\renewcommand{\labelnamepunct}{\addperiod\space}
-\DeclareLanguageMapping{french}{french-dw}
-\DeclareFieldFormat[book]{title}{\mkbibemph{#1}}
-\DeclareFieldFormat[book]{citetitle}{\mkbibemph{#1}}
-\DeclareFieldFormat[article]{title}{\mkbibquote{#1}}
-\DeclareFieldFormat[article]{citetitle}{\mkbibquote{#1}}
-\DeclareFieldFormat[inreference]{citetitle}{\mkbibquote{#1}}
-\DeclareFieldFormat{journaltitle}{\mkbibemph{#1}}
-\DeclareFieldFormat{citejournaltitle}{\mkbibemph{#1}}
+% biblatex-dw:
+% \usepackage[style=footnote-dw, xref=true, loccittracker, opcittracker,
+% autopunct=false, ibidemfont=italic, idemfont=italic,
+% citeauthorname=firstfull, idembibformat=dash, nopublisher=false,
+% annotation=true, pageref=true, journalnumber=date,
+% acronyms=true]{biblatex}
+
+% \renewcommand{\mkbibacro}[1]{%
+%   \textls[55]{\scalefont{0.95}#1}\isdot}
+% \renewcommand{\labelnamepunct}{\addperiod\space}
+% \DeclareLanguageMapping{french}{french-dw}
+% \DeclareFieldFormat[book]{title}{\mkbibemph{#1}}
+% \DeclareFieldFormat[book]{citetitle}{\mkbibemph{#1}}
+% \DeclareFieldFormat[article]{title}{\mkbibquote{#1}}
+% \DeclareFieldFormat[article]{citetitle}{\mkbibquote{#1}}
+% \DeclareFieldFormat[inreference]{citetitle}{\mkbibquote{#1}}
+% \DeclareFieldFormat{journaltitle}{\mkbibemph{#1}}
+% \DeclareFieldFormat{citejournaltitle}{\mkbibemph{#1}}
+
+\usepackage[style=ext-verbose-inote]{biblatex}
+
+% \DefineBibliographyExtras{french}{%
+%   \renewcommand{\mkbibnamefamily}[1]{#1}%
+% }
+
 \addbibresource{../bibliography.bib}
+
+% Automatically cite authors in full at first, then only by last
+% name. See https://tex.stackexchange.com/a/314708
+\makeatletter
+\newrobustcmd*{\cbx@nametracker@global}[1]{%
+  \xifinlistcs{#1}{cbx@bseen@names@\the\c@refsection}
+    {}
+    {\listcsxadd{cbx@bseen@names@\the\c@refsection}{#1}}}
+
+\newrobustcmd*{\cbx@nametracker@context}[1]{%
+  \iftoggle{blx@footnote}
+    {\xifinlistcs{#1}{cbx@fseen@names@\the\c@refsection}
+       {}
+       {\listcsxadd{cbx@fseen@names@\the\c@refsection}{#1}}}
+    {\xifinlistcs{#1}{cbx@bseen@names@\the\c@refsection}
+       {}
+       {\listcsxadd{cbx@bseen@names@\the\c@refsection}{#1}}}}
+
+\newrobustcmd*{\cbx@ifnameseen@global}[1]{%
+  \xifinlistcs{#1}{cbx@bseen@names@\the\c@refsection}}
+
+\newrobustcmd*{\cbx@ifnameseen@context}[1]{%
+  \iftoggle{blx@footnote}%
+    {\xifinlistcs{#1}{cbx@fseen@names@\the\c@refsection}}%
+    {\xifinlistcs{#1}{cbx@bseen@names@\the\c@refsection}}}
+
+\DeclareBibliographyOption[string]{nametracker}[true]{%
+  \ifcsdef{blx@opt@nametracker@#1}
+    {\csuse{blx@opt@nametracker@#1}}
+    {\blx@err@invopt{nametracker=#1}{}}}
+
+\def\blx@opt@nametracker@global{%
+  \let\cbx@ifnameseen\cbx@ifnameseen@global
+  \let\cbx@nametracker\cbx@nametracker@global}
+
+\let\blx@opt@nametracker@true\blx@opt@nametracker@global
+
+\def\blx@opt@nametracker@false{%
+  \protected\long\def\cbx@ifnameseen##1##2##3{##3}%
+  \let\cbx@nametracker\relax}
+
+\def\blx@opt@nametracker@context{%
+  \let\cbx@ifnameseen\cbx@ifnameseen@context
+  \let\cbx@nametracker\cbx@nametracker@context}
+
+\appto\blx@secinit{%
+  \ifcsundef{cbx@bseen@names@\the\c@refsection}
+    {\global\cslet{cbx@bseen@names@\the\c@refsection}\@empty}
+    {}%
+  \ifcsundef{cbx@fseen@names@\the\c@refsection}
+    {\global\cslet{cbx@fseen@names@\the\c@refsection}\@empty}
+    {}}
+
+\InitializeCitationStyle{%
+  \global\cslet{cbx@bseen@names@\the\c@refsection}\@empty
+  \global\cslet{cbx@fseen@names@\the\c@refsection}\@empty}
+
+\ExecuteBibliographyOptions{nametracker=context}
+
+\DeclareNameFormat{labelname}{%
+  \cbx@ifnameseen{\thefield{hash}}
+    {\ifcase\value{uniquename}%
+       \usebibmacro{name:family}
+         {\namepartfamily}
+         {\namepartgiven}
+         {\namepartprefix}
+         {\namepartsuffix}%
+     \or
+       \ifuseprefix
+         {\usebibmacro{name:given-family}
+           {\namepartfamily}
+           {\namepartgiveni}
+           {\namepartprefix}
+           {\namepartsuffixi}}
+         {\usebibmacro{name:given-family}
+           {\namepartfamily}
+           {\namepartgiveni}
+           {\namepartprefixi}
+           {\namepartsuffixi}}%
+     \or
+       \usebibmacro{name:given-family}
+         {\namepartfamily}
+         {\namepartgiven}
+         {\namepartprefix}
+         {\namepartsuffix}%
+     \fi}
+    {\usebibmacro{name:given-family}
+       {\namepartfamily}
+       {\namepartgiven}
+       {\namepartprefix}
+       {\namepartsuffix}%
+     \cbx@nametracker{\thefield{hash}}}
+    \usebibmacro{name:andothers}}
+\makeatother
+
-- 
cgit v1.2.3

