# Add period after dashed authors, but comma after dashed editors (biblatex)

First I remove the parentheses around the year in the bibliography and add a period after the entry name with:

\usepackage{xpatch}


Then I add a period after the dash for dashed entries with:

\renewcommand*\bibnamedash{\rule[0.48ex]{3em}{0.14ex}\addperiod\space}


This looks fine when the dashed entry is an author (see McCartney in the MWE below), but it looks wrong for dashed editors. Instead of

------. Ed. 1966. More songs I like.

It should be

------, ed. 1966. More songs I like.

In effect, the dash should only replace the repeated name, and change nothing else. How can I do this?

\documentclass{article}
\usepackage[style=authoryear-comp]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{lennon1965,
EDITOR = "John Lennon",
TITLE = "Old songs I like",
YEAR = "1965"}
@book{lennon1966,
EDITOR = "John Lennon",
TITLE = "More old songs I like",
YEAR = "1966"}
@book{mccartney1965,
AUTHOR = "Paul McCartney",
TITLE = "This is what I did yesterday",
YEAR = "1965"}
@book{mccartney1966,
AUTHOR = "Paul McCartney",
TITLE = "My troubles don't seem so far away",
YEAR = "1966"}

\end{filecontents}

\usepackage{xpatch}
\xpatchbibmacro{date+extrayear}{\printtext[parens]}{\setunit*{\addperiod\space}\printtext}{}{} % remove parenthesis around year in bibliography
\renewcommand*\bibnamedash{\rule[0.48ex]{3em}{0.14ex}\addperiod\space} % use a 3em dash with period after it for dashed author names

\begin{document}
\nocite{*}
\printbibliography
\end{document}


Make use of biblatex's punctuation tracker.

\renewcommand*\bibnamedash{%
\printtext{%
\rule[0.48ex]{3em}{0.14ex}}%


That way we print the name dash and afterwards use the punctuation tracker to sort things out for us.

With

\documentclass{article}
\usepackage[style=authoryear-comp]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{lennon1965,
EDITOR = "John Lennon",
TITLE = "Old songs I like",
YEAR = "1965"}
@book{lennon1966,
EDITOR = "John Lennon",
TITLE = "More old songs I like",
YEAR = "1966"}
@book{mccartney1965,
AUTHOR = "Paul McCartney",
TITLE = "This is what I did yesterday",
YEAR = "1965"}
@book{mccartney1966,
AUTHOR = "Paul McCartney",
TITLE = "My troubles don't seem so far away",
YEAR = "1966"}

\end{filecontents}