% TODO: MAKE default

%D \module
%D   [       file=publ-imp-author,
%D        version=2014.06.23,
%D          title=\CONTEXT\ Publication Support,
%D       subtitle=Authors,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

\unprotect

% these can be used instead of the macros and they accept manipulator prefixes
%
% \currentbtxinitials   : \btxauthorfield{initials}
% \currentbtxfirstnames : \btxauthorfield{firstnames}
% \currentbtxvons       : \btxauthorfield{vons}
% \currentbtxsurnames   : \btxauthorfield{surnames}
% \currentbtxjuniors    : \btxauthorfield{juniors}

\starttexdefinition unexpanded \s!btx:\s!cite:\s!author:\s!de
    \ifx\currentbtxlanguage\s!de
      \setmode{\s!btx:\s!de}
    \fi
\stoptexdefinition

\startsetups \s!btx:\s!cite:\s!author:concat
    \ifcase\currentbtxoverflow
        \btxparameter{\c!separator:names:\number\currentbtxconcat}
    \else\ifnum\currentbtxauthorindex>\plusone
        \btxparameter{\c!separator:names:2}
    \fi\fi
\stopsetups

\startsetups \s!btx:\s!cite:\s!author:others
    \ifcase\currentbtxoverflow \else
        \btxparameter\c!otherstext
    \fi
\stopsetups

\startsetups \s!btx:\s!cite:\s!author:normal
    \fastsetup{\s!btx:\s!cite:\s!author:concat}
    \ifx\currentbtxfirstnames\empty \else
        \currentbtxfirstnames
        \btxparameter{\c!separator:firstnames}
    \fi
    \ifx\currentbtxvons\empty \else
        \currentbtxvons
        \ifx\currentbtxsurnames\empty \else
            \btxparameter{\c!separator:vons}
        \fi
    \fi
    \ifx\currentbtxsurnames\empty \else
        \currentbtxsurnames
        \ifx\currentbtxjuniors\empty \else
            \btxparameter{\c!separator:juniors}
            \currentbtxjuniors
        \fi
    \fi
    \fastsetup{\s!btx:\s!cite:\s!author:others}
\stopsetups

\startsetups \s!btx:\s!cite:\s!author:normalshort
    \fastsetup{\s!btx:\s!cite:\s!author:concat}
    \ifx\currentbtxinitials\empty \else
        \currentbtxinitials
        \btxparameter{\c!separator:initials}
    \fi
    \ifx\currentbtxvons\empty \else
        \currentbtxvons
        \ifx\currentbtxsurnames\empty \else
            \btxparameter{\c!separator:vons}
        \fi
    \fi
    \ifx\currentbtxsurnames\empty \else
        \currentbtxsurnames
        \ifx\currentbtxjuniors\empty \else
            \btxparameter{\c!separator:juniors}
            \currentbtxjuniors
        \fi
    \fi
    \fastsetup{\s!btx:\s!cite:\s!author:others}
\stopsetups

\startsetups \s!btx:\s!cite:\s!author:inverted
    \fastsetup{\s!btx:\s!cite:\s!author:concat}
    \ifx\currentbtxvons\empty \else
        \texdefinition{\s!btx:\s!cite:\s!author:\s!de}
        \doifmode {\s!btx:\s!de} {
            \currentbtxvons
            \btxparameter{\c!separator:vons}
        }
    \fi
    \ifx\currentbtxsurnames\empty \else
        \currentbtxsurnames
        \ifx\currentbtxjuniors\empty \else
            \btxparameter{\c!separator:juniors}
            \currentbtxjuniors
        \fi
    \fi
    \ifx\currentbtxfirstnames\empty
        % firstnames are optional
    \else
        \btxparameter{\c!separator:invertedfirstnames}
        \currentbtxfirstnames
    \fi
    \ifx\currentbtxvons\empty \else
        \doifnotmode {\s!btx:\s!de} {
            \btxparameter{\c!separator:vons}
            \currentbtxvons
        }
    \fi
    \fastsetup{\s!btx:\s!cite:\s!author:others}
\stopsetups

\startsetups \s!btx:\s!cite:\s!author:invertedshort
    \fastsetup{\s!btx:\s!cite:\s!author:concat}
    \ifx\currentbtxvons\empty \else
        \texdefinition{\s!btx:\s!cite:\s!author:\s!de}
        \doifnotmode {\s!btx:\s!de} {
            \currentbtxvons
            \btxparameter{\c!separator:vons}
        }
    \fi
    \ifx\currentbtxsurnames\empty \else
        \currentbtxsurnames
        \ifx\currentbtxjuniors\empty \else
            \btxparameter{\c!separator:juniors}
            \currentbtxjuniors
        \fi
    \fi
    \ifx\currentbtxinitials\empty
        % initials are optional
    \else
        \btxparameter{\c!separator:invertedinitials}
        \currentbtxinitials
    \fi
    \ifx\currentbtxvons\empty \else
        \doifmode {\s!btx:\s!de} {
            \btxparameter{\c!separator:vons}
            \currentbtxvons
        }
    \fi
    \fastsetup{\s!btx:\s!cite:\s!author:others}
\stopsetups

\startsetups \s!btx:\s!cite:\s!author:name
    \fastsetup{\s!btx:\s!cite:\s!author:concat}
    % is this treated differently in german?
    \ifx\currentbtxvons\empty \else
        \currentbtxvons
        \btxparameter{\c!separator:vons}
    \fi
    \currentbtxsurnames
    \ifcase\currentbtxauthorstate \else
        % potential clash of names so we force initials
        \ifx\currentbtxinitials\empty \else
            \btxparameter{\c!separator:invertedinitials}
            \currentbtxinitials
        \fi
    \fi
    \fastsetup{\s!btx:\s!cite:\s!author:others}
\stopsetups

% list (mostly the same)

\startsetups \s!btx:\s!list:\s!author:concat
    \ifcase\currentbtxoverflow
        \btxparameter{\c!separator:names:\number\currentbtxconcat}
    \else\ifnum\currentbtxauthorindex>\plusone
        \btxparameter{\c!separator:names:2}
    \fi\fi
\stopsetups

\startsetups \s!btx:\s!list:\s!author:others
    \ifcase\currentbtxoverflow \else
        \btxparameter\c!otherstext
    \fi
\stopsetups

\startsetups \s!btx:\s!list:\s!author:normal
    \fastsetup{\s!btx:\s!list:\s!author:concat}
    \ifx\currentbtxfirstnames\empty \else
        \currentbtxfirstnames
        \btxparameter{\c!separator:firstnames}
    \fi
    \ifx\currentbtxvons\empty \else
        \currentbtxvons
        \ifx\currentbtxsurnames\empty \else
            \btxparameter{\c!separator:vons}
        \fi
    \fi
    \ifx\currentbtxsurnames\empty \else
        \currentbtxsurnames
        \ifx\currentbtxjuniors\empty \else
            \btxparameter{\c!separator:juniors}
            \currentbtxjuniors
        \fi
    \fi
    \fastsetup{\s!btx:\s!list:\s!author:others}
\stopsetups

\startsetups \s!btx:\s!list:\s!author:normalshort
    \fastsetup{\s!btx:\s!list:\s!author:concat}
    \ifx\currentbtxinitials\empty \else
        \currentbtxinitials
        \btxparameter{\c!separator:initials}
    \fi
    \ifx\currentbtxvons\empty \else
        \currentbtxvons
        \ifx\currentbtxsurnames\empty \else
            \btxparameter{\c!separator:vons}
        \fi
    \fi
    \ifx\currentbtxsurnames\empty \else
        \currentbtxsurnames
        \ifx\currentbtxjuniors\empty \else
            \btxparameter{\c!separator:juniors}
            \currentbtxjuniors
        \fi
    \fi
    \fastsetup{\s!btx:\s!list:\s!author:others}
\stopsetups

\startsetups \s!btx:\s!list:\s!author:inverted
    \fastsetup{\s!btx:\s!list:\s!author:concat}
    \ifx\currentbtxvons\empty \else
        \texdefinition{\s!btx:\s!cite:\s!author:\s!de}
        \doifnotmode {\s!btx:\s!de} {
            \currentbtxvons
            \btxparameter{\c!separator:vons}
        }
    \fi
    \ifx\currentbtxsurnames\empty \else
        \currentbtxsurnames
        \ifx\currentbtxjuniors\empty \else
            \btxparameter{\c!separator:juniors}
            \currentbtxjuniors
        \fi
    \fi
    \ifx\currentbtxfirstnames\empty
        % firstnames are optional
    \else
        \btxparameter{\c!separator:invertedfirstnames}
        \currentbtxfirstnames
    \fi
    \ifx\currentbtxvons\empty \else
        \doifmode {\s!btx:\s!de} {
            \btxparameter{\c!separator:vons}
            \currentbtxvons
        }
    \fi
    \fastsetup{\s!btx:\s!list:\s!author:others}
\stopsetups

\startsetups \s!btx:\s!list:\s!author:invertedshort
    \fastsetup{\s!btx:\s!list:\s!author:concat}
    \ifx\currentbtxvons\empty \else
        \texdefinition{\s!btx:\s!cite:\s!author:\s!de}
        \doifnotmode {\s!btx:\s!de} {
            \currentbtxvons
            \btxparameter{\c!separator:vons}
        }
    \fi
    \ifx\currentbtxsurnames\empty \else
        \currentbtxsurnames
        \ifx\currentbtxjuniors\empty \else
            \btxparameter{\c!separator:juniors}
            \currentbtxjuniors
        \fi
    \fi
    \ifx\currentbtxinitials\empty
        % initials are optional
    \else
        \btxparameter{\c!separator:invertedinitials}
        \currentbtxinitials
    \fi
    \ifx\currentbtxvons\empty \else
        \doifmode {\s!btx:\s!de} {
            \btxparameter{\c!separator:vons}
            \currentbtxvons
        }
    \fi
    \fastsetup{\s!btx:\s!list:\s!author:others}
\stopsetups

\startsetups \s!btx:\s!list:\s!author:name
    \fastsetup{\s!btx:\s!list:\s!author:concat}
    % is this treated differently in german?
    \ifx\currentbtxvons\empty \else
        \currentbtxvons
        \btxparameter{\c!separator:vons}
    \fi
    \currentbtxsurnames
    \fastsetup{\s!btx:\s!list:\s!author:others}
\stopsetups

\protect
