%%
%% This is file `leipzig.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% leipzig.dtx  (with options: `package')
%% This is a generated file.
%% 
%% ----------------------------------------------------------------
%% leipzig --- A package to typeset and index linguistic gloss abbreviations.
%% E-mail: natalie.a.weber@gmail.com
%% Released under the LaTeX Project Public License v1.3c or later
%% See http://www.latex-project.org/lppl.txt
%% ----------------------------------------------------------------
%% 
%% 
%% Copyright (C) 2013 by Natalie Weber
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%% 
%%   http://www.latex-project.org/lppl.txt
%% 
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%% 
%% This work has the LPPL maintenance status `maintained'.
%% 
%% The Current Maintainer of this work is Natalie Weber.
%% 
%% This work consists of the files leipzig.dtx,
%%                                 leipzig.ins
%%                                 leipzig.tex
%% 
%% and the derived files leipzig.sty and leipzig.pdf.
%% 
\NeedsTeXFormat{LaTeX2e}[1996/10/24]%
\ProvidesPackage{leipzig}%
    [2013/05/26 v1.0 Leipzig package for linguistic abbreviations]%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%  This is a simple list of newcommands which create shortcuts for   %%
%%  standard linguistic glosses (see the Leipzig Glossing rules,      %%
%%  http://www.eva.mpg.de/lingua/resources/glossing-rules.php         %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\long\def\tlist@if@empty@nTF #1{%
  \expandafter\ifx\expandafter\\\detokenize{#1}\\%
  \expandafter\@firstoftwo%
  \else%
  \expandafter\@secondoftwo%
  \fi%
}%
\newif\ifleipzig@glossaries\leipzig@glossariesfalse
\newif\ifleipzig@noglossaries\leipzig@noglossariesfalse
\newif\ifleipzig@donotindex\leipzig@donotindexfalse
\DeclareOption{glossaries}{\leipzig@glossariestrue}
\DeclareOption{noglossaries}{\leipzig@noglossariestrue}
\DeclareOption{nostandards}{\leipzig@donotindextrue}
\DeclareOption*{%
  \PassOptionsToPackage{\CurrentOption}{glossaries}%
}%
\ProcessOptions\relax
\@ifpackageloaded{glossaries}{% true text
  \ifleipzig@noglossaries\leipzig@glossariesfalse\relax
  \else\leipzig@glossariestrue\relax\fi
}{% false text
  \ifleipzig@glossaries\PackageWarning{leipzig}{%
    glossaries package not loaded. Load glossaries
    package at some point.}%
  \else\leipzig@glossariesfalse\relax\fi
}%
\@ifpackageloaded{glossary-inline}{% renew inline
\renewglossarystyle{inline}{%
  \renewenvironment{theglossary}%
    {%
      \def\gls@inlinesep{}%
      \def\gls@inlinesubsep{}%
      \def\gls@inlineshortlongsep{%
          \glsinlineshortlongseparator}% added this
    }%
    {\glspostinline}%
  \renewcommand*{\glossaryheader}{}%
  \renewcommand*{\glsgroupheading}[1]{}%
  \renewcommand*{\glossaryentryfield}[5]{%
    \gls@inlinesep
    \glsentryitem{##1}\glstarget{##1}{##2}%
    \def\glo@desc{##3}%
    \def\@no@post@desc{\nopostdesc}%
    \ifx\glo@desc\@no@post@desc
    \else
      \ifstrempty{##3}{}{\gls@inlineshortlongsep##3}%
    \fi
    \ifglshaschildren{##1}%
    {%
       \glsresetsubentrycounter
       \glsinlineparentchildseparator
       \def\gls@inlinesubsep{}%
    }%
    {}%
    \def\gls@inlinesep{\glsinlineseparator}%
  }%
  \renewcommand*{\glossarysubentryfield}[6]{%
    \gls@inlinesubsep%
    \glstarget{##2}{}%
    \glssubentryitem{##2}##4%
    \def\gls@inlinesubsep{\glsinlinesubseparator}%
  }%
  \renewcommand*{\glsgroupskip}{}%
}
\newcommand*{\glsinlineshortlongseparator}{\,=\,\linebreak[1]}% added this
\renewcommand*{\glsinlineseparator}{,\space}% changed from ;\space
\renewcommand*{\glsinlinesubseparator}{,\space}
\renewcommand*{\glsinlineparentchildseparator}{:\space}
\renewcommand*{\glspostinline}{.\space}% changed from .
\renewcommand{\glsnamefont}[1]{\textsc{#1}}% abbrv in glossary are \sc
\renewcommand*{\glossarysection}[2][]{}% no section name
}{\relax}% if glossary-inline not loaded
\newcommand{\leipzigfont}[1]{\textsc{#1}}%
\newcommand{\firstleipzigfont}[1]{\leipzigfont{#1}}%
\ifleipzig@glossaries %if glossaries package loaded
  \renewcommand*{\acrpluralsuffix}{\textup{\glspluralsuffix}}%
  \newcommand{\leipzigname}{Abbreviations}
  \newglossary{leipzig}{lzs}{lzo}{\leipzigname}
  \newcommand{\leipzigtype}{leipzig}
%% The following commands are based on the Custom Acronym commands in the glossaries package.
\newcommand*{\SetLeipzigDisplayStyle}[1]{%
  \defglsdisplay[#1]{\leipzigfont{##1}##4}%
  \defglsdisplayfirst[#1]{\firstleipzigfont{##1}##4}%
}
\newcommand*{\CustomLeipzigFields}{%
  name={\the\glsshorttok},%
  description={\the\glslongtok},%
  symbol={\the\glsshorttok},%
  first={\firstleipzigfont{\the\glsshorttok}},%
  firstplural={\firstleipzigfont{\the\glsshorttok}\noexpand\acrpluralsuffix},%
  text={\leipzigfont{\the\glsshorttok}},%
  plural={\leipzigfont{\the\glsshorttok}\noexpand\acrpluralsuffix}%
}
\newcommand*{\LeipzigAcronymDef}{%
  \protected@edef\@do@newglossaryentry{%
    \noexpand\newglossaryentry{\the\glslabeltok}%
    {%
      type=\leipzigtype,%
      short={\leipzigfont{\the\glsshorttok}},% used in e.g. \acrshort
      shortplural={\leipzigfont{\the\glsshorttok}\noexpand\acrpluralsuffix},%
      long={\the\glslongtok},%
      longplural={\the\glslongtok\noexpand\acrpluralsuffix},%
      user1={\the\glsshorttok},%
      user2={\the\glsshorttok\noexpand\acrpluralsuffix},%
      user3={\the\glslongtok},%
      user4={\the\glslongtok\noexpand\acrpluralsuffix},%
      \CustomLeipzigFields,%
      \the\glskeylisttok
    }%
  }%
  \@do@newglossaryentry
}
\newcommand*{\SetLeipzigStyle}{%
  \renewcommand{\newacronym}[4][]{%
    \ifx\@glsacronymlists\@empty
      \def\@glo@type{\leipzigtype}%
      \setkeys{glossentry}{##1}%
      \DeclareAcronymList{\@glo@type}%
      \SetLeipzigDisplayStyle{\@glo@type}%
    \fi
    \glskeylisttok{##1}%
    \glslabeltok{##2}%
    \glsshorttok{##3}%
    \glslongtok{##4}%
    \newacronymhook
    \LeipzigAcronymDef
  }%
%%  \@for\@gls@type:=\@glsacronymlists\do{% sets style for all acronymlists?
%%%%    \SetCustomDisplayStyle{\@gls@type}%
%%    \SetLeipzigDisplayStyle{\@gls@type}%
%%  }%
}%
\SetLeipzigStyle
%%Normally would have |\leipzigfont{#2}|, but I coded the leipzigfont directly into the short form. How else to do it?
\renewcommand{\acrfullformat}[2]{#1\space(#2)}
\newcommand{\newleipzig}[4][]{%
  \bgroup
    \tlist@if@empty@nTF{#1}%
      {\newacronym[type=\leipzigtype]{#2}{#3}{#4}}%
      {\newacronym[type=\leipzigtype,#1]{#2}{#3}{#4}}%
 %   \newacronym[type=\leipzigtype][#1]{n#2}{n#3}{Non-#4}
    \@newleipzig(#3)#2\@nil}%
  \def\@newleipzig(#1)#2#3\@nil{%
      \ifleipzig@donotindex
        \uppercase{\expandafter\gdef\csname #2}#3\endcsname{\leipzigfont{#1}}
      \else
        \uppercase{\expandafter\gdef\csname #2}#3\endcsname{\gls{#2#3}}
      \fi
      \egroup
    }% end if glossaries loaded
\else % if glossaries not loaded
  \newcommand{\newleipzig}[4][]{\@newleipzig(#3)#2\@nil}%
  \def\@newleipzig(#1)#2#3\@nil{%
    \uppercase{\expandafter\gdef\csname #2}#3\endcsname{\leipzigfont{#1}}
  }%
\fi
\input{leipzig.tex}
\ifleipzig@donotindex\leipzig@donotindexfalse\fi
