%D \module

%D   [       file=bibl-ieee,

%D        version=2007.06.17,

%D          title=IEEE bibliography style,

%D       subtitle=IEEE Publications,

%D         author={Aditya Mahajan},

%D           date=\currentdate,

%D      copyright={Aditya Mahajan}]



\unprotect



%D The default mnemonics are not compatible with IEEE style.



\setuplabeltext [\s!en] [\v!january  :\s!mnem=Jan.]

\setuplabeltext [\s!en] [\v!february :\s!mnem=Feb.]

\setuplabeltext [\s!en] [\v!march    :\s!mnem=Mar.]

\setuplabeltext [\s!en] [\v!april    :\s!mnem=Apr.]

\setuplabeltext [\s!en] [\v!may      :\s!mnem=May]

\setuplabeltext [\s!en] [\v!june     :\s!mnem=Jun.]

\setuplabeltext [\s!en] [\v!july     :\s!mnem=Jul.]

\setuplabeltext [\s!en] [\v!august   :\s!mnem=Aug.]

\setuplabeltext [\s!en] [\v!september:\s!mnem=Sep.]

\setuplabeltext [\s!en] [\v!october  :\s!mnem=Oct.]

\setuplabeltext [\s!en] [\v!november :\s!mnem=Nov.]

\setuplabeltext [\s!en] [\v!december :\s!mnem=Dec.]



\setupbibtex          [sort=author]

\setuppublicationlist [maybeyear=off]



\setuplistalternative

  [ieee]

  [\c!distance=1em,

      \c!width=2em,

    \c!stretch=0em,

    \c!command=,

  ]



\setuppublicationlist 

  [\c!numbercommand=\!!ieee@brackets,

           \c!width=2em,

     \c!alternative=ieee,

      \c!samplesize={99},

  ]





\def\doverysimplebibnumref#1#2%

   {\refsep

    \ifcase#1\relax \unknownreference{#1}\else

      \def\tempa{#2}\ifx\empty\tempa#1\else#1\docommaordash{#1}{#2}#2\fi

    \fi}%



\def\docommaordash#1#2%

   {\doifelse{\the\numexpr#1+1-#2\relax}{0}%

     {\bibalternative\c!pubsep}%

     {\bibalternative\c!inbetween}}%



\setupcite

       [author,year]

       [\c!andtext={ and },

        \c!otherstext={ et al.},

        \c!pubsep={, },

        \c!lastpubsep={ and },

        \c!compress=\v!no,

        \c!inbetween={ },

        \c!left={(},

        \c!right={)}]



\setupcite

       [authoryear]

       [\c!andtext={ and },

        \c!otherstext={ et al.},

        \c!pubsep={, },

        \c!lastpubsep={ and },

        \c!compress=\v!no,

        \c!inbetween={ },

        \c!left={(},

        \c!right={)}]



\setupcite

       [authoryears]

       [\c!andtext={ and },

        \c!otherstext={ et al.},

        \c!pubsep={, },

        \c!lastpubsep={ and },

        \c!compress=\v!no,

        \c!inbetween={, },

        \c!left={(},

        \c!right={)}]



\setupcite

       [key,serial,authornum,page,short,type,doi,url]

       [\c!andtext={ and },

        \c!otherstext={ et al.},

        \c!pubsep={, },

        \c!lastpubsep={ and },

        \c!compress=\v!no,

        \c!inbetween={ },

        \c!left={[},

        \c!right={]}]



\setupcite

       [num]

       [\c!andtext={ and },

        \c!otherstext={ et al.},

        \c!pubsep={, },

        \c!lastpubsep={ and },

        \c!compress=\v!yes,

        \c!inbetween={]--[},

        \c!left={[},

        \c!right={]}]



%D This is the ugliest way to make sure that the number is right justified.

%D The trouble is that \filename{core-lst.tex} contains an explicit

%D \type|\hfill|.



\def\!!ieee@brackets#1%

  {\hbox \ifdim\!!widtha>\zeropoint to \!!widtha \fi

   {\hss[#1]\hskip 0.5em}}



\setuppublications

   [\c!sorttype=cite,

    \c!criterium=,

    \c!refcommand=num,

    \c!numbering=\v!yes,

    \c!numbercommand=\!!ieee@brackets,

    monthconversion=month:mnem]



\setuppublicationlist

   [\c!artauthor=\normalshortauthor,

    \c!editor=\normalshortauthor,

    \c!author=\normalshortauthor,

    \c!namesep={, },

    \c!lastnamesep={ and },

    \c!finalnamesep={, and },

    \c!firstnamesep={ },

    \c!juniorsep={ },

    \c!vonsep={ },

    \c!surnamesep={ },

    \c!authoretallimit=5,

    \c!editoretallimit=5,

    \c!artauthoretallimit=5,

    \c!authoretaldisplay=5,

    \c!editoretaldisplay=5,

    \c!artauthoretaldisplay=5,

    \c!authoretaltext={ et al.},

    \c!editoretaltext={ et al.},

    \c!artauthoretaltext={ et al.},

    artauthorcommand=\!!ieee@repeatedauthors,

    authorcommand=\!!ieee@repeatedauthors,

]



%D Just to be sure



\def\maybeyear#1{}

\def\etalchar#1{#1}



%D Show repeated authors by ------



\def\!!ieee@oldauthors{}



\def\!!ieee@repeatedauthors#1#2#3%

    {\xdef\!!ieee@newauthors{#3}%

      \ifx\!!ieee@oldauthors\!!ieee@newauthors

          ------%

       \else

         \dospecialbibinsert{#1}{#2}{#3}%

         \global\let\!!ieee@oldauthors\!!ieee@newauthors

       \fi}



\setuppublicationlayout[article]%

 {\insertartauthors {}                 {,} {\insertthekey{}{,}{}}%

  \insertarttitle   {\space\quotation\bgroup}

                                 {,\egroup} {}%

  \insertjournal    {\space\bgroup \it}

                        {\unskip\/\egroup} {}%

  \insertvolume     {,\space vol.~} 

        {\insertissue {,\space no.~} {} {}} {}%

  \insertpages      {,\space pp.\space}       {} {}%

  \insertpubyear    {,\space\insertmonth{}{\space}{}} 

                                         {} {}%

  \insertnote       {.\space}            {.} {.}}



\setuppublicationlayout[conference]%

 {\insertauthors    {}           {,} {\insertthekey{}{,}{}}%

  \insertarttitle   {\space\quotation\bgroup}

                                 {,\egroup} {}%

  \inserttitle      {\space in \bgroup \it}

                        {\unskip\/\egroup}  {}%

  \insertseries     {,\space ser.\space} {} {}%

  \inserteditors    {,\space ed.\space}  {} {}%

  \insertvolume     {,\space vol.~}  

           {\insertissue{,\space no.~}{}{}} {}%

  \insertpubyear    {,\space\insertmonth{}{,\space}{}}

                                         {} {}%

  \insertcity       {,\space}            {} {}%

  \insertpages      {,\space pp.\space}       {} {}%

  \insertnote       {.\space}            {.} {.}}



\setuppublicationlayout[inproceedings]%

 {\insertauthors    {}           {,} {\insertthekey{}{,}{}}%

  \insertarttitle   {\space\quotation\bgroup}

                                 {,\egroup} {}%

  \inserttitle      {\space in \bgroup \it}

                        {\unskip\/\egroup}  {}%

  \insertseries     {,\space ser.\space} {} {}%

  \inserteditors    {,\space ed.\space}  {} {}%

  \insertvolume     {,\space vol.~}  

           {\insertissue{,\space no.~}{}{}} {}%

  \insertpubyear    {,\space\insertmonth{}{,\space}{}}

                                         {} {}%

  \insertcity       {,\space}            {} {}%

  \insertpages      {,\space pp.\space}       {} {}%

  \insertnote       {.\space}            {.} {.}}





\setuppublicationlayout[incollection]%

 {\insertartauthors {}           {,} {\insertthekey{}{,}{}}%

  \insertarttitle   {\space\quotation\bgroup}

                                 {,\egroup} {}%

  \inserttitle      {\space in\space\bgroup\it} 

                                {\/\egroup} {}%

  \insertseries     {,\space ser.\space} {} {}%

  \inserteditors    {,\space ed.\space}  {} {}%

  \insertpubyear    {,\space\insertmonth{}{,\space}{}}

                                         {} {}%

  \insertpublisher  {,\space}            {} {}%

  \insertcity       {,\space}            {} {}%

  \insertpages      {,\space pp.\space}       {}  {}%

  \insertnote       {.\space}           {.} {.}}





\setuppublicationlayout[book]

 {\insertauthors    {}           {,} {\insertthekey{}{,}{}}%

  \inserttitle      {\space\bgroup\it}

                                 {\/\egroup} {}%

  \insertvolume     {,\space vol.~}  

           {\insertissue{,\space no.~}{}{}} {}%

  \insertseries     {,\space ser.\space} {} {}%

  \inserteditors    {,\space ed.\space}  {} {}%

  \insertpubname    {,\space} 

                 {\insertcity{,\space}{}{}} {}%

  \insertpubyear    {,\space\insertmonth{}{,\space}{}}

                                         {} {}%

  \insertnote       {.\space}            {.} {.}}



\setuppublicationlayout[unpublished]

  {\insertauthors    {}           {,} {\insertthekey{}{,}{}}%

   \inserttitle      {\space\bgroup\it}

                                 {\/\egroup} {}%

  \insertpubyear    {,\space\insertmonth{}{,\space}{}}

                                         {} {}%

  \insertnote       {.\space}            {.} {.}}



\setuppublicationlayout[phdthesis]%

 {\insertauthors {}                 {,} {\insertthekey{}{,}{}}%

  \inserttitle      {\space\quotation\bgroup}

                                 {,\egroup} {}%

  \inserttype       {\space}                 {} {\space Ph.D.\ Thesis}%

  \insertpubname    {,\space}                 {} {}%

  \insertcity       {,\space}                 {} {}%

  \insertpubyear    {,\space\insertmonth{}{\space}{}} 

                                         {} {}%

  \insertnote       {.\space}            {.} {.}}



% \setuppublicationlayout[phdthesis]{%

%   \insertauthors{}{}{}%

%   \inserttitle{``}{,''}{}%

%   \inserttype{}{,}{Ph.D.\ Thesis,}%

%   \insertpubname{}{,}{}%

%   \insertcity{}{,}{}%

%   \insertpubyear{\insertmonth{}{, }{}}{.}{.}%

%   \insertnote{}{.}{}%

% }%

%   

% TODO. The rest of this stuff



% \setuppublicationlayout[inbook]{%

%   \insertauthors{}{}{}%

%   \insertchapter{\bgroup \em}{\egroup,}{}%

%   \inserttitle{in }{,}{}%

%   \insertvolume{vol. }{,}{}%

%   \inserteditors{}{ ed%

%                          \ifnum\getvalue{editor@num}> 1 s\fi.,

%                              \ \global\editedbooktrue 

%                      }{}%

%   \insertseries{ser. }{,}{}%

%   \insertpages{pp. }{,}{}%

%   \insertpubname{}{,}{}%

%   \insertpubyear{}{.}{}%

%   \insertnote{}{.}{}%

% }%





% \setuppublicationlayout[unpublished]{%

%   \insertauthors{}{}{}%

%   \inserttitle{``}{,''}{}%

%   \insertpubyear{\insertmonth{}{, }{}}{,}{.}%

%   \insertnote{}{.}{}%

% }%



% \setuppublicationlayout[proceedings]{%

%   \inserttitle{\bgroup\em}{\egroup,}{}%

%   \insertseries{in }{,}{}%

%   \insertvolume{vol. }{,\insertissue{ no. }{,}{}}{}%

%   \insertpubyear{\insertmonth{}{, }{}}{.}{.}%

%   \insertnote{}{.}{}%

% }%

%   

% \setuppublicationlayout[techreport]{%

%   \insertauthors{}{}{}%

%   \inserttitle{``}{,''}{}%

%   \insertbibtype{}{\insertvolume{ }{}{\unskip},}{}%

%   \insertpubname{}{\unskip,\insertcity{ }{\unskip,}{\unskip}}{}%

%   \insertpubyear{\insertmonth{}{, }{}}{.}{}%

%   \insertnote{}{.}{}%

% }%

\protect

