% authortitle-dw.bbx, Dominik Waßenhoven 2023

\ProvidesFile{authortitle-dw.bbx}[2023/03/11 v1.7b biblatex bibliography style]
  
\RequireBibliographyStyle{standard-dw}

\newbool{bbx:annotation}
\newbool{bbx:edbyidem}
\newbool{bbx:editorstring}% Test, ob editorstring auf parens oder brackets gesetzt wurde
\newbool{bbx:editionstring}
\newbool{bbx:edsuper}
\newbool{bbx:idembib}
\newbool{bbx:idemfont}% Test, ob idemfont gesetzt wurde
\newbool{bbx:library}
\newbool{bbx:nolocation}
\newbool{bbx:nopublisher}
\newbool{bbx:oldauthor}
\newbool{bbx:origfields}
\newbool{bbx:pseudoauthor}
\newbool{oldbookauthor}
\newbool{oldauthor}
\newbool{pseudoauthor}

\DeclareEntryOption{oldbookauthor}[true]{%
  \csuse{bool#1}{oldbookauthor}}
\DeclareEntryOption{oldauthor}[true]{%
  \csuse{bool#1}{oldauthor}}
\DeclareEntryOption{pseudoauthor}[true]{%
  \csuse{bool#1}{pseudoauthor}}

\DeclareBibliographyOption{annotation}[true]{%
  \csuse{bool#1}{bbx:annotation}}
\DeclareBibliographyOption{edbyidem}[true]{%
  \csuse{bool#1}{bbx:edbyidem}}
\DeclareBibliographyOption{editionstring}[true]{%
  \csuse{bool#1}{bbx:editionstring}}
\DeclareBibliographyOption{edsuper}[true]{%
  \csuse{bool#1}{bbx:edsuper}}
\DeclareBibliographyOption{idembib}[true]{%
  \csuse{bool#1}{bbx:idembib}}
\DeclareBibliographyOption{library}[true]{%
  \csuse{bool#1}{bbx:library}}
\DeclareBibliographyOption{nolocation}[true]{%
  \csuse{bool#1}{bbx:nolocation}}
\DeclareBibliographyOption{nopublisher}[true]{%
  \csuse{bool#1}{bbx:nopublisher}}
\DeclareBibliographyOption{oldauthor}[true]{%
  \csuse{bool#1}{bbx:oldauthor}}
\DeclareBibliographyOption{origfields}[true]{%
  \csuse{bool#1}{bbx:origfields}}
\DeclareBibliographyOption{pseudoauthor}[true]{%
  \csuse{bool#1}{bbx:pseudoauthor}}

\newcommand{\bbx@origfieldsformat}{}

\DeclareBibliographyOption{origfieldsformat}{%
  \renewcommand{\bbx@origfieldsformat}{#1}}

\DeclareBibliographyOption{namefont}[normal]{%
  \ifcsdef{bbx@opt@namefont@#1}
    {\csuse{bbx@opt@namefont@#1}}
    {\blxdw@error{%
       Invalid option 'namefont=#1'\MessageBreak
       Valid values are 'normal', 'smallcaps', 'italic', 'bold'}}}
\newcommand{\bbx@namefont}{}
\def\bbx@opt@namefont@normal{%
  \renewcommand{\bbx@namefont}{}}
\def\bbx@opt@namefont@smallcaps{%
  \renewcommand{\bbx@namefont}{\textsc}}
\def\bbx@opt@namefont@italic{%
  \renewcommand{\bbx@namefont}{\mkbibemph}}
\def\bbx@opt@namefont@bold{%
  \renewcommand{\bbx@namefont}{\mkbibbold}}

\DeclareBibliographyOption{firstnamefont}[normal]{%
  \ifcsdef{bbx@opt@firstnamefont@#1}
    {\csuse{bbx@opt@firstnamefont@#1}}
    {\blxdw@error{%
       Invalid option 'firstnamefont=#1'\MessageBreak
       Valid values are 'normal', 'smallcaps', 'italic', 'bold'}}}
\newcommand{\bbx@firstnamefont}{}
\def\bbx@opt@firstnamefont@normal{%
  \renewcommand{\bbx@firstnamefont}{}}
\def\bbx@opt@firstnamefont@smallcaps{%
  \renewcommand{\bbx@firstnamefont}{\textsc}}
\def\bbx@opt@firstnamefont@italic{%
  \renewcommand{\bbx@firstnamefont}{\mkbibemph}}
\def\bbx@opt@firstnamefont@bold{%
  \renewcommand{\bbx@firstnamefont}{\mkbibbold}}

\DeclareBibliographyOption{idemfont}[normal]{%
  \ifcsdef{bbx@opt@idemfont@#1}
    {\csuse{bbx@opt@idemfont@#1}}
    {\blxdw@error{%
       Invalid option 'idemfont=#1'\MessageBreak
       Valid values are 'normal', 'smallcaps', 'italic', 'bold'}}}
\newcommand{\bbx@idemfont}{}
\def\bbx@opt@idemfont@normal{%
  \global\booltrue{bbx:idemfont}%
  \renewcommand{\bbx@idemfont}{}}
\def\bbx@opt@idemfont@smallcaps{%
  \global\booltrue{bbx:idemfont}%
  \renewcommand{\bbx@idemfont}{\textsc}}
\def\bbx@opt@idemfont@italic{%
  \global\booltrue{bbx:idemfont}%
  \renewcommand{\bbx@idemfont}{\mkbibemph}}
\def\bbx@opt@idemfont@bold{%
  \global\booltrue{bbx:idemfont}%
  \renewcommand{\bbx@idemfont}{\mkbibbold}}
      
\DeclareBibliographyOption{ibidemfont}[normal]{%
  \ifcsdef{bbx@opt@ibidemfont@#1}
    {\csuse{bbx@opt@ibidemfont@#1}}
    {\blxdw@error{%
       Invalid option 'ibidemfont=#1'\MessageBreak
       Valid values are 'normal', 'smallcaps', 'italic', 'bold'}}}
\newcommand{\bbx@ibidemfont}{}
\def\bbx@opt@ibidemfont@normal{%
  \renewcommand{\bbx@ibidemfont}{}}
\def\bbx@opt@ibidemfont@smallcaps{%
  \renewcommand{\bbx@ibidemfont}{\textsc}}
\def\bbx@opt@ibidemfont@italic{%
  \renewcommand{\bbx@ibidemfont}{\mkbibemph}}
\def\bbx@opt@ibidemfont@bold{%
  \renewcommand{\bbx@ibidemfont}{\mkbibbold}}

\DeclareBibliographyOption{idembibformat}[idem]{%
  \ifcsdef{bbx@opt@idembibformat@#1}
    {\csuse{bbx@opt@idembibformat@#1}}
    {\blxdw@error{%
       Invalid option 'idembibformat=#1'\MessageBreak
       Valid values are 'idem', 'dash'}}}
\def\bbx@opt@idembibformat@idem{%
  \let\bibnamedashOrig\bibnamedash
  \AtBeginBibliography{
    \renewcommand*{\bibnamedash}{%
      \bibsentence\bibstring[\mkidem]{idem\thefield{gender}}}}}
\def\bbx@opt@idembibformat@dash{
  \AtBeginBibliography{%
    \let\bibnamedash\bibnamedashOrig}}%

\DeclareBibliographyOption{editorstring}[normal]{%
  \ifcsdef{bbx@opt@editorstring@#1}
    {\csuse{bbx@opt@editorstring@#1}}
    {\blxdw@error{%
       Invalid option 'editorstring=#1'\MessageBreak
       Valid values are 'normal', 'parens', 'brackets'}}}
\newcommand{\bbx@editorstring}{}
\def\bbx@opt@editorstring@normal{%
  \global\boolfalse{bbx:editorstring}%
  \renewcommand{\bbx@editorstring}{}}
\def\bbx@opt@editorstring@parens{%
  \global\booltrue{bbx:editorstring}%
  \renewcommand{\bbx@editorstring}{\printtext[parens]}}
\def\bbx@opt@editorstring@brackets{%
  \global\booltrue{bbx:editorstring}%
  \renewcommand{\bbx@editorstring}{\printtext[brackets]}}

\DeclareBibliographyOption{editorstringfont}[normal]{%
  \ifcsdef{bbx@opt@edstringfont@#1}
    {\csuse{bbx@opt@edstringfont@#1}}
    {\blxdw@error{%
       Invalid option 'editorstringfont=#1'\MessageBreak
       Valid values are 'normal' and 'namefont'}}}
\newcommand{\bbx@edstringfont}{}
\def\bbx@opt@edstringfont@normal{%
  \renewcommand{\bbx@edstringfont}{}}
\def\bbx@opt@edstringfont@namefont{%
  \renewcommand{\bbx@edstringfont}{\bbx@namefont}}
  
\ExecuteBibliographyOptions{
  edbyidem=true,
  editorstring=parens,
  idembib=true,
  idembibformat=idem,
  nolocation=false,
  nopublisher=true,
  oldauthor=true,
  origfields=true,
  origfieldsformat=punct,
  pseudoauthor=true
}

%% Autoren, Herausgeber und Übersetzter in der Bibliographie
\DeclareNameAlias{author}{sortname}
\DeclareNameAlias{editor}{sortname}
\DeclareNameAlias{translator}{sortname}

%% Komma statt Punkt nach einzelnen Elementen der Literaturangaben
\renewcommand*{\newunitpunct}{\addcomma\space}

%% Punkt zwischen Titel und Untertitel
\renewcommand*{\subtitlepunct}{\addperiod\space}

%% Punkt zwischen Untertitel und Titelzusatz ([book|main]titleaddon)
\newcommand*{\titleaddonpunct}{\addperiod\space}

%% Doppelpunkt nach Autoren/Editoren
\renewcommand*{\labelnamepunct}{\addcolon\space}

%% Zeichensetzung zwischen Ort und Jahr
\newcommand*{\locationdatepunct}{\addspace}

%% Zeichensetzung zwischen Ort und Verlag
\newcommand*{\locationpublisherpunct}{\addcolon\space}

%% Zeichensetzung zwischen Verlag und Jahr
\newcommand*{\publisherdatepunct}{\addcomma\space}

%% Zeichen vor 'Nachdruck' bei Benutzung von 'origfields'
\newcommand*{\origfieldspunct}{\addcomma\space}

%% Zeichen für pseudoauthor=true
\newcommand*{\bibleftpseudo}{}
\newcommand*{\bibrightpseudo}{}

%% Zeichen zw. Autoren/Editoren in der Bibliographie
\newcommand*{\bibrevsdnamedelim}{\addspace}
\newcommand*{\bibmultinamedelim}{\addcomma\space}
\newcommand*{\bibfinalnamedelim}{%
  \ifnum\value{liststop}>2 \finalandcomma\fi
  \addspace\bibstring{and}\space}%

\AtBeginBibliography{%
  \let\revsdnamedelim\bibrevsdnamedelim%
  \let\multinamedelim\bibmultinamedelim%
  \let\finalnamedelim\bibfinalnamedelim%
}

%% Makros für Schriften der Felder 'annotation' und 'library'
\newcommand{\annotationfont}{\small\itshape}
\newcommand{\libraryfont}{\small\sffamily}

%% Formate in der Bibliographie
\DeclareFieldFormat{annotation}{%
  \annotationfont #1}%\addperiod\par}
\DeclareFieldFormat{booktitle}{#1}
\DeclareFieldFormat{edition}{%
  \ifinteger{#1}
    {\mkbibordedition{#1}~\bibstring{edition}}
    {\ifbool{bbx:editionstring}
      {#1\addspace\bibstring{edition}\isdot}
      {#1\isdot}}}
\DeclareFieldFormat{edition:super}{% für Option 'edsuper'
  \ifinteger{#1}
    {\textsuperscript{#1}}
    {\blxdw@warning@noline{%
      The 'edition' field of entry\MessageBreak
      '\abx@field@entrykey' is not an integer.\MessageBreak
      The edition will not be printed as\MessageBreak
      superscript. Instead, the 'edition'\MessageBreak
      field is printed completely}}}
\DeclareFieldFormat{journaltitle}{#1}
\DeclareFieldFormat{issuetitle}{#1}
\DeclareFieldFormat{library}{%
  \libraryfont #1}%\addperiod\par}
\DeclareFieldFormat{maintitle}{#1}
\DeclareFieldFormat{review}{%
  \bibstring{review}%
  \mkbibquote{#1}}
\DeclareFieldFormat{shorthandwidth}{%
  \ifboolexpr{
    bool {bbx:shorthandacro}
    and
    bool {bbx:acronym}
  }
    {\mkbibacro{#1}\isdot}
    {#1\isdot}}
\DeclareFieldFormat{shortjournal}{%
  \ifboolexpr{
    bool {bbx:shorthandacro}
    and
    bool {bbx:acronym}
  }
    {\mkbibacro{#1}\isdot}
    {#1\isdot}}
\DeclareFieldFormat*{title}{#1}
\DeclareFieldFormat[inreference]{title}{%
  \bibstring{inrefstring}%
  \mkbibquote{#1}}
\DeclareFieldFormat[review]{title}{%
  \bibstring{review}%
  \mkbibquote{#1}}
\DeclareFieldFormat[inreference]{volume}{#1}% volume of an inreference entry
\DeclareFieldFormat[review]{volume}{#1}% volume of a review entry
\DeclareFieldFormat{shorthand}{%
  \ifbool{bbx:shorthandacro}
    {\ifbool{bbx:acronym}
      {\mkbibacro{#1}\isdot}
      {#1\isdot}}
    {#1\isdot}} 

%% Umdefinierung von finentry für 'annotation' und 'library'
\renewbibmacro*{finentry}{%
  \ifboolexpr{
    test {\iffieldundef{annotation}}
    and
    test {\iffieldundef{library}}
  }
    {\finentry}
    {\iffieldundef{annotation}
      {\iffieldundef{library}
        {\finentry}
        {}}%
      {\ifbool{bbx:annotation}
        {\setunit{\addperiod\par}
         \printfield{annotation}}
        {}}%
     \iffieldundef{library}
      {}
      {\ifbool{bbx:library}
        {\setunit{\addperiod\par}
         \printfield{library}}
        {}}%
     \finentry}}

% Ausschalten von annotation und library für die List of Shorthands
\AtEveryLositem{%
  \boolfalse{bbx:annotation}%
  \boolfalse{bbx:library}%
}

%% Wichtig für die Herausgebernamen in der List of Shorthands
\InitializeBibliographyStyle{%
  \let\bbx@lasthash\undefined}

% Nachnamen von Einträgen mit 'options = {oldauthor=true}' 
% oder 'options = {oldbookauthor=true}'
% werden nicht in der Schrift von 'namefont' gesetzt
% Formatierung der Nachnamen entsprechend der Option 'namefont'
\renewcommand*{\mkbibnamefamily}[1]{%
 \ifboolexpr{
 ( bool {bbx:oldauthor}
   and
   ( ( bool {oldauthor}
       and
       ( test {\ifcurrentname{author}}
         or
         ( test {\ifcurrentname{labelname}}
           and
           not test {\ifnameundef{author}} ) ) )
     or
     ( bool {oldbookauthor}
       and
       test {\ifcurrentname{bookauthor}} ) ) )
   or
 ( bool{cbx:citeauthor}
   and
   ( bool{cbx:citeauthornormalfont}
     or
     ( bool{cbx:citeauthorfoot}
       and
       not test {\iffootnote} ) ) )
 }
  {#1}
  {\bbx@namefont{#1}}}
	      
% Formatierung der Vornamen entsprechend der Option 'firstnamefont'
\renewcommand*{\mkbibnamegiven}[1]{%
 \ifboolexpr{
 ( bool {bbx:oldauthor}
   and
   ( ( bool {oldauthor}
       and
       ( test {\ifcurrentname{author}}
         or
         ( test {\ifcurrentname{labelname}}
           and
           not test {\ifnameundef{author}} ) ) )
     or
     ( bool {oldbookauthor}
       and
       test {\ifcurrentname{bookauthor}} ) ) )
   or
 ( bool{cbx:citeauthor}
   and
   ( bool{cbx:citeauthornormalfont}
     or
     ( bool{cbx:citeauthorfoot}
       and
       not test {\iffootnote} ) ) )
 }
  {#1}
  {\bbx@firstnamefont{#1}}}

% prefix richtet sich nach 'namefont' (useprefix=true)
% oder 'firstnamefont' (useprefix=false)
\renewcommand*{\mkbibnameprefix}[1]{%
 \ifboolexpr{
 ( bool {bbx:oldauthor}
   and
   ( ( bool {oldauthor}
       and
       ( test {\ifcurrentname{author}}
         or
         ( test {\ifcurrentname{labelname}}
           and
           not test {\ifnameundef{author}} ) ) )
     or
     ( bool {oldbookauthor}
       and
       test {\ifcurrentname{bookauthor}} ) ) )
   or
 ( bool{cbx:citeauthor}
   and
   ( bool{cbx:citeauthornormalfont}
     or
     ( bool{cbx:citeauthorfoot}
       and
       not test {\iffootnote} ) ) )
 }
  {#1}
  {\ifuseprefix
    {\bbx@namefont{#1}}
    {\bbx@firstnamefont{#1}}}}

% suffix richtet sich nach 'firstnamefont' 
\renewcommand*{\mkbibnamesuffix}[1]{%
 \ifboolexpr{
 ( bool {bbx:oldauthor}
   and
   ( ( bool {oldauthor}
       and
       ( test {\ifcurrentname{author}}
         or
         ( test {\ifcurrentname{labelname}}
           and
           not test {\ifnameundef{author}} ) ) )
     or
     ( bool {oldbookauthor}
       and
       test {\ifcurrentname{bookauthor}} ) ) )
   or
 ( bool{cbx:citeauthor}
   and
   ( bool{cbx:citeauthornormalfont}
     or
     ( bool{cbx:citeauthorfoot}
       and
       not test {\iffootnote} ) ) )
 }
  {#1}
  {\bbx@firstnamefont{#1}}}

%% \mkidem:
% wenn im Feld 'options' 'oldauthor=true' oder 'oldauthor' steht,
% werden keine Kapitälchen o.ä. bei Wiederholungszitaten ('Ders.') gesetzt
% ansonsten Formatierung entsprechend der Option 'idemfont',
% falls diese nicht vorhanden ist, wird der Wert von 'namefont' übernommen
\newcommand*{\mkidem}[1]{% 
  \ifboolexpr{
    bool {bbx:oldauthor}
    and
    bool {oldauthor}
  }
	  {#1}
	  {\ifbool{bbx:idemfont}
	    {\bbx@idemfont{#1}}
	    {\bbx@namefont{#1}}}}
		      
%% Punkt zwischen Untertitel und Titelzusatz ([book|main]titleaddon)
\renewbibmacro*{title}{%
  \iffieldundef{title}
    {}
    {\printtext[title]{%
       \printfield[titlecase]{title}%
       \setunit{\subtitlepunct}%
       \printfield[titlecase]{subtitle}}%
     \setunit{\titleaddonpunct}%
     \printfield{titleaddon}}}

\renewbibmacro*{booktitle}{%
  \iffieldundef{booktitle}
    {}
    {\printtext[booktitle]{%
       \printfield[titlecase]{booktitle}%
       \setunit{\subtitlepunct}%
       \printfield[titlecase]{booksubtitle}}%
     \setunit{\titleaddonpunct}%
     \printfield{booktitleaddon}}}

\renewbibmacro*{maintitle}{%
  \iffieldundef{maintitle}
    {}
    {\printtext[maintitle]{%
       \printfield[titlecase]{maintitle}%
       \setunit{\subtitlepunct}%
       \printfield[titlecase]{mainsubtitle}}%
     \setunit{\titleaddonpunct}%
     \printfield{maintitleaddon}}}

%% Ort, Verlag, Jahr:
%% - mit 'origfields=true' werden origlocation, origpublisher
%%   und origyear gesetzt, der Rest als 'reprint' angehängt
%% - der Verlag ist optional (nopublisher=true|false)
%% - die Edition kann hochgestellt werden (edsuper=true|false)
\newbibmacro*{origdate}{\printorigdate}

\renewbibmacro*{publisher+location+date}{%
  \ifbool{bbx:origfields}
    {\ifbool{bbx:nolocation}
      {\iffieldundef{origyear}
        {\usebibmacro{loc+pub+year}}
        {\usebibmacro{origloc+origpub+origyear}}}
      {\iflistundef{origlocation}
        {\iffieldundef{origyear}
          {\usebibmacro{loc+pub+year}}
          {\usebibmacro{origloc+origpub+origyear}}}
        {\iffieldundef{origyear}
          {\blxdw@warning{%
             Field 'origlocation' is set, but 'origdate' is 
             \MessageBreak%
             empty at entry '\abx@field@entrykey'.
             The 'orig' fields \MessageBreak are omitted
             for this entry}%
           \usebibmacro{loc+pub+year}}
          {\usebibmacro{origloc+origpub+origyear}}}}}
    {\usebibmacro{loc+pub+year}}}

\newbibmacro{loc+pub+year}{%
  \ifbool{bbx:nolocation}
    {}
    {\printlist{location}%
     \ifbool{bbx:nopublisher}
       {\setunit*{\locationdatepunct}}%
       {\iflistundef{publisher}
         {\setunit*{\locationdatepunct}}
         {\setunit*{\locationpublisherpunct}%
          \printlist{publisher}%
          \setunit*{\publisherdatepunct}}}}%
  \ifbool{bbx:edsuper}
    {\printfield[edition:super]{edition}}
    {}%
  \usebibmacro{date}%
  \newunit}

\newbibmacro{origloc+origpub+origyear}{%
  \ifbool{bbx:nolocation}
    {}
    {\printlist{origlocation}%
     \ifbool{bbx:nopublisher}
       {\setunit*{\locationdatepunct}}%
       {\iflistundef{origpublisher}
         {\setunit*{\locationdatepunct}}
         {\setunit*{\locationpublisherpunct}%
          \printlist{origpublisher}%
          \setunit*{\publisherdatepunct}}}}%
  \ifbool{bbx:edsuper}
    {\printfield[edition:super]{edition}}
    {}%
  \usebibmacro{origdate}%
  \ifdefstring{\bbx@origfieldsformat}{punct}
    {\setunit*{\origfieldspunct}%
     \usebibmacro{origfields:loc+pub+year}}
    {\ifdefstring{\bbx@origfieldsformat}{parens}
      {\setunit*{\addspace}%
       \printtext[parens]{%
         \usebibmacro{origfields:loc+pub+year}}}
      {\ifdefstring{\bbx@origfieldsformat}{brackets}
        {\setunit*{\addspace}%
         \printtext[brackets]{%
           \usebibmacro{origfields:loc+pub+year}}}
        {\setunit*{\origfieldspunct}%
         \usebibmacro{origfields:loc+pub+year}}}}
  \newunit}

\newbibmacro{origfields:loc+pub+year}{%
  \bibstring{reprint}%
  \setunit{\addspace}%
  \ifbool{bbx:nolocation}
    {}
    {\printlist{location}%
     \ifbool{bbx:nopublisher}
       {\setunit*{\locationdatepunct}}%
       {\iflistundef{publisher}
         {\setunit*{\locationdatepunct}}
         {\setunit*{\locationpublisherpunct}%
          \printlist{publisher}%
          \setunit*{\publisherdatepunct}}}}%
  \usebibmacro{date}}

%% Test, ob ein Feld nur eine Zahl beinhaltet
%\newcommand{\bbx@iffieldinteger}[1]{%
%  \iffieldundef{#1}
%    {\@secondoftwo}
%    {\edef\@tempa{\strfield{#1}}%
%     \expandafter\ifinteger\expandafter{\@tempa}}}

%% Edition nur ausgeben, wenn Option 'edsuper=false'
%\newbibmacro*{edition}{%
%  \ifbool{bbx:edsuper}
%    {\bbx@iffieldinteger{edition}
%       {}% falls 'edition' eine Zahl ist, wird hochgestellt
%       {\printfield{edition}%
%        \newunit}}% ansonsten wird komplett ausgegeben
%    {\printfield{edition}%
%     \newunit}}
\newbibmacro*{edition}{%
  \ifbool{bbx:edsuper}
    {\iffieldint{edition}
       {}% falls 'edition' eine Zahl ist, wird hochgestellt
       {\printfield{edition}%
        \newunit}}% ansonsten wird komplett ausgegeben
    {\printfield{edition}%
     \newunit}}

%% Hilfsmakro für Option editorstring
\newbibmacro*{editorstringpunct}{%
  \ifbool{bbx:editorstring}
    {\addspace}
    {\addcomma\space}}
                      
%% Herausgeber ('Hrsg.') je nach Option editorstring
\renewbibmacro*{editorstrg}{%
  \iffieldundef{editortype}
    {\ifthenelse{\value{editor}>1\OR\ifandothers{editor}}
      {\bbx@edstringfont{\bbx@editorstring{\bibstring{editors}}}}
      {\bbx@edstringfont{\bbx@editorstring{\bibstring{editor}}}}}
    {\ifthenelse{\value{editor}>1\OR\ifandothers{editor}}
      {\bbx@edstringfont{\bbx@editorstring{\bibstring{\thefield{editortype}s}}}}
      {\bbx@edstringfont{\bbx@editorstring{\bibstring{\thefield{editortype}}}}}}}

\renewbibmacro*{editor+othersstrg}{%
  \iffieldundef{editortype}
    {\ifthenelse{\value{editor}>1\OR\ifandothers{editor}}
       {\def\abx@tempa{editors}}
       {\def\abx@tempa{editor}}}
    {\ifthenelse{\value{editor}>1\OR\ifandothers{editor}}
       {\edef\abx@tempa{\thefield{editortype}s}}
       {\edef\abx@tempa{\thefield{editortype}}}}%
  \let\abx@tempb=\empty
  \ifnamesequal{editor}{translator}
    {\appto\abx@tempa{tr}%
     \appto\abx@tempb{\clearname{translator}}}
    {}%
  \ifnamesequal{editor}{commentator}
    {\appto\abx@tempa{co}%
     \appto\abx@tempb{\clearname{commentator}}}
    {\ifnamesequal{editor}{annotator}
       {\appto\abx@tempa{an}%
	\appto\abx@tempb{\clearname{annotator}}}
       {}}%
  \ifnamesequal{editor}{introduction}
    {\appto\abx@tempa{in}%
     \appto\abx@tempb{\clearname{introduction}}}
    {\ifnamesequal{editor}{foreword}
       {\appto\abx@tempa{fo}%
	\appto\abx@tempb{\clearname{foreword}}}
       {\ifnamesequal{editor}{afterword}
          {\appto\abx@tempa{af}%
           \appto\abx@tempb{\clearname{afterword}}}
          {}}}%
  \ifbibxstring{\abx@tempa}
    {\bbx@edstringfont{\bbx@editorstring{\bibstring{\abx@tempa}}}%
     \abx@tempb}
    {\usebibmacro{editorstrg}}}

%% Übersetzer ('Übers.') je nach Option editorstring
\renewbibmacro*{translatorstrg}{%
  \ifthenelse{\value{translator}>1\OR\ifandothers{translator}}
    {\bbx@edstringfont{\bbx@editorstring{\bibstring{translators}}}}
    {\bbx@edstringfont{\bbx@editorstring{\bibstring{translator}}}}}

\renewbibmacro*{translator+othersstrg}{%
  \ifthenelse{\value{translator}>1\OR\ifandothers{translator}}
    {\def\abx@tempa{translators}}
    {\def\abx@tempa{translator}}%
  \ifnamesequal{translator}{commentator}
    {\appto\abx@tempa{co}%
     \clearname{commentator}}
    {\ifnamesequal{translator}{annotator}
       {\appto\abx@tempa{an}%
	\clearname{annotator}}
       {}}%
  \ifnamesequal{translator}{introduction}
    {\appto\abx@tempa{in}%
     \clearname{introduction}}
    {\ifnamesequal{translator}{foreword}
       {\appto\abx@tempa{fo}%
	\clearname{foreword}}
       {\ifnamesequal{translator}{afterword}
          {\appto\abx@tempa{af}%
           \clearname{afterword}}
          {}}}%
  \bbx@edstringfont{\bbx@editorstring{\bibstring{\abx@tempa}}}}
        
%% Option 'editorstring=brackets|parens|normal'
%% Option 'idembib=true|false'
\renewbibmacro*{editor}{%
  \ifthenelse{\ifuseeditor\AND\NOT\ifnameundef{editor}}
    {\ifbool{bbx:idembib}
      {\ifthenelse{\iffieldequals{fullhash}{\bbx@lasthash}\AND
                   \NOT\iffirstonpage}
         {\bibnamedash}
         {\printnames{editor}%
          \savefield{fullhash}{\bbx@lasthash}}}%
      {\printnames{editor}%
       \global\undef\bbx@lasthash}%
     \usebibmacro{editorstringpunct}%
     \usebibmacro{editorstrg}%
     \ifbool{bbx:idembib}
       {}
       {\labelnamepunct}%
     \clearname{editor}}
    {}}

\renewbibmacro*{editor+others}{%
  \ifthenelse{\ifuseeditor\AND\NOT\ifnameundef{editor}}
    {\ifbool{bbx:idembib}
      {\ifthenelse{\iffieldequals{fullhash}{\bbx@lasthash}\AND
                   \NOT\iffirstonpage}
         {\bibnamedash}
         {\printnames{editor}%
          \savefield{fullhash}{\bbx@lasthash}}}%
      {\printnames{editor}}%
     \usebibmacro{editorstringpunct}%
     \usebibmacro{editor+othersstrg}%
     \ifbool{bbx:idembib}
       {}
       {\labelnamepunct}%
     \clearname{editor}}
    {\global\undef\bbx@lasthash}}

\renewbibmacro*{translator}{%
  \ifthenelse{\ifusetranslator\AND\NOT\ifnameundef{translator}}
    {\ifbool{bbx:idembib}
      {\ifthenelse{\iffieldequals{fullhash}{\bbx@lasthash}\AND
                   \NOT\iffirstonpage}
         {\bibnamedash}
         {\printnames{translator}%
          \savefield{fullhash}{\bbx@lasthash}}}%
      {\printnames{translator}}%
     \usebibmacro{editorstringpunct}%
     \usebibmacro{translatorstrg}%
     \ifbool{bbx:idembib}
       {}
       {\labelnamepunct}%
     \clearname{translator}}
    {\global\undef\bbx@lasthash}}

\renewbibmacro*{translator+others}{%
  \ifthenelse{\ifusetranslator\AND\NOT\ifnameundef{translator}}
    {\ifbool{bbx:idembib}
      {\ifthenelse{\iffieldequals{fullhash}{\bbx@lasthash}\AND
                   \NOT\iffirstonpage}
         {\bibnamedash}
         {\printnames{translator}%
          \savefield{fullhash}{\bbx@lasthash}}}%
      {\printnames{translator}}%
     \usebibmacro{editorstringpunct}%
     \usebibmacro{translator+othersstrg}%
     \ifbool{bbx:idembib}
       {}
       {\labelnamepunct}%
     \clearname{translator}}
    {\global\undef\bbx@lasthash}}

\newbibmacro*{editor+others/translator+others}{%
  \ifboolexpr{
    test \ifuseeditor
    and
    not test {\ifnameundef{editor}}
  }
    {\usebibmacro{editor+others}}
    {\usebibmacro{translator+others}}}

%% Option 'idembib=true|false'
\renewbibmacro*{author}{%
  \ifbool{bbx:pseudoauthor}
    {\usebibmacro{author:pseudotrue}}
    {\usebibmacro{author:pseudofalse}}}

\newbibmacro*{author:pseudotrue}{%
  \ifbool{pseudoauthor}
    {\printtext{\bibleftpseudo}%
     \usebibmacro{author:output}%
     \printtext{\bibrightpseudo}}
    {\usebibmacro{author:output}}}

\newbibmacro*{author:pseudofalse}{%
  \ifbool{pseudoauthor}
    {}
    {\usebibmacro{author:output}}}

\newbibmacro*{author:output}{%
  \ifthenelse{\ifuseauthor\AND\NOT\ifnameundef{author}}
    {\ifbool{bbx:idembib}
      {\ifthenelse{\iffieldequals{fullhash}{\bbx@lasthash}\AND
                   \NOT\iffirstonpage}
        {\bibnamedash}
        {\printnames{author}%
         \savefield{fullhash}{\bbx@lasthash}}}
      {\printnames{author}%
       \global\undef\bbx@lasthash}%
  \iffieldundef{authortype}
    {}
    {\setunit{\addcomma\space}%
     \usebibmacro{authorstrg}}}
  {}}

%% 'Ders.' bei inbook, wenn gleicher Autor
\renewbibmacro*{bybookauthor}{%
  \ifnamesequal{author}{bookauthor}
    {\ifbool{bbx:edbyidem}
      {\midsentence*\bibstring[\mkidem]{idem\thefield{gender}}\addcolon}
      {\printnames[byauthor]{bookauthor}%
       \newunit\newblock}}
    {\printnames[byauthor]{bookauthor}%
     \newunit\newblock}}

%% Wenn Autor und Hrsg. gleich --> hg. v. dems./ders./dens.:
\renewbibmacro*{byeditor+others}{%
  \ifnameundef{editor}
    {}
    {\usebibmacro{byeditor+othersstrg}%
     \setunit{\addspace}%
     \ifboolexpr{
       ( ( ( not test {\ifentrytype{inbook}}% alle außer inbook: author und editor gleich? 
             and
             test {\ifnamesequal{editor}{author}} )
           or
           ( test {\ifentrytype{inbook}} 
             and
             ( test {\ifnameundef{bookauthor}}% inbook ohne bookauthor: author und editor gleich?
               and
               test {\ifnamesequal{editor}{author}} )
             or
               ( not test {\ifnameundef{bookauthor}}% inbook mit bookauthor: author und bookauthor gleich?
                 and
                 test {\ifnamesequal{editor}{bookauthor}} ) ) )
         or
         ( bool {xrefidem}
           and not 
           bool {cbx:authauthxref} ) )
       and
       bool {bbx:edbyidem}
     }
	     {\bibstring[\mkidem]{idemdat\thefield{gender}}}
       {\printnames[byeditor]{editor}}%
     \clearname{editor}%
     \newunit}%
  \usebibmacro{byeditorx}%
  \usebibmacro{bytranslator+others}}

\renewbibmacro*{bytranslator+others}{%
  \ifnameundef{translator}
    {}
    {\usebibmacro{bytranslator+othersstrg}%
     \setunit{\addspace}%
     \ifboolexpr{
       ( test {\ifnamesequal{translator}{author}}
         or
         bool {xrefidem} )
       and
       bool {bbx:edbyidem}
     }
	     {\bibstring[\mkidem]{idemdat\thefield{gender}}}
       {\printnames[bytranslator]{translator}}%
     \clearname{translator}%
     \newunit}%
  \usebibmacro{withothers}}

\newbibmacro*{ifuse:byeditor+others}{%
  \ifboolexpr{
    ( test \ifuseeditor
      and
      not test {\ifnameundef{editor}} )
    or
    ( test \ifusetranslator
      and
      not test {\ifnameundef{translator}} )
    or
    bool {xref:inbook}
  }
    {}
    {\usebibmacro{byeditor+others}}}

\newbibmacro*{ifuse:xrefidem}{%
  \ifboolexpr{
    test \ifuseeditor
    and
    not test {\ifnameundef{editor}}
  }
    {\printtext{\bibstring[\mkidem]{idem\thefield{gender}}%
                \addspace}%
     \usebibmacro{editor+othersstrg}%
     \setunit{\labelnamepunct}\newblock}
    {}%
  \ifboolexpr{
    test \ifusetranslator
    and
    not test {\ifnameundef{translator}}
    and 
      ( ( not test \ifuseeditor )
      or
        ( test \ifuseeditor
          and 
          test {\ifnameundef{editor}} ) )
  }
    {\printtext{\bibstring[\mkidem]{idem\thefield{gender}}%
                \addspace}%
     \usebibmacro{editor+othersstrg}%
     \setunit{\labelnamepunct}\newblock}
    {}}

%%%%% %%%%% %%%%% %%%%% %%%%% %%%%% %%%%% %%%%% %%%%%
%%%%% Makros aus authortitle.bbx (unverändert)  %%%%% 
%%%%% %%%%% %%%%% %%%%% %%%%% %%%%% %%%%% %%%%% %%%%% 

\setlength{\bibitemsep}{0pt}

\defbibenvironment{bibliography}
  {\list
     {}
     {\setlength{\leftmargin}{\bibhang}%
      \setlength{\itemindent}{-\leftmargin}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}}}
  {\endlist}
  {\item}

\endinput
