%% This is file `aeguill.sty' 
% This file gives french guillemets (and not guillemots!)
% built with the LatinModern fonts (default),
% the Polish CMR fonts, WNCYR fonts, the LASY fonts 
% or with the EC fonts. 
% This is useful in conjunction with the ae package
% (this package loads the ae package in case it has not been loaded)
%  and with or without the french(le) package.
%
% In order to get the guillemets, it is necessary to either type
% \guillemotleft and \guillemotright, or to use an 8 bit encoding
% (such as ISO-Latin1) which selects these two commands, 
% or, if you use the french package (but not the frenchle package), 
% to type << or >>.
%
% By default, you get the LatinModern guillemets; if this package is loaded
% with the `pl' option, you get the Polish guillemets;
% with the `cm' option, you get the LASY guillemets; with `ec' you
% get the EC guillemets, and with `cyr' you get the cyrillic guillemets.
%
% In verbatim mode, you always get the EC/TT guillemets.
%
% The default option is interesting in conjunction with PDF,
% because LatinModern is a Type 1 font close to CMR
% and whose guillemets are very close in shape to the EC guillemets.
% 
%
% Support for Polish CMR guillemets was kindly provided by 
% Rolf Niepraschk <niepraschk@ptb.de> in version 0.99 (2000/05/22).
% Bernd Raichle provided extensive simplifications to the code
% for version 1.00.
%
% This package is released under the LPPL.
%
% Changes:
%   Date        version
%   2001/04/12  1.01    the frenchle and french package are now distinguished.
%   2003/08/02  1.02    support for the new LatinModern fonts (suggested by Daniel Flipo)
%                       the default has been changed to LatinModern guillemets
%                       (this is an unfortunate, but in my view necessary, incompatibility)
%                       (I do not plan to change this default ever, as LatinModern is
%                       supposed to become standard, and eventually make ae/ec obsolete)
%
\def\fileversion{1.02}
\def\filedate{2003/08/02}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{aeguill}[2003/08/02 1.02 %
AE fonts with french guillemets (D. Roegel)]
\RequirePackage{ae}

\newcommand{\@ae@switch}[5]{#5}
\DeclareOption{ec}{\renewcommand\@ae@switch[5]{#1}}
\DeclareOption{cm}{\renewcommand\@ae@switch[5]{#2}}
\DeclareOption{cyr}{\renewcommand\@ae@switch[5]{#3}}
\DeclareOption{pl}{\renewcommand\@ae@switch[5]{#4}}
\DeclareOption{lm}{\renewcommand\@ae@switch[5]{#5}}
\ExecuteOptions{lm}
\ProcessOptions

%
% Load necessary packages
%
\@ae@switch{% ec
  % do nothing
}{% cm
  \RequirePackage{latexsym}%
}{% cyr
  \RequirePackage[OT2,T1]{fontenc}%
}{% pl
  \RequirePackage[OT4,T1]{fontenc}%
}{% lm
  % do nothing
}

% The following command will be compared to \frenchname,
% as defined in french.sty and frenchle.sty.
\def\aeguillfrenchdefault{french}%

\let\guill@verbatim@font\verbatim@font
\def\verbatim@font{\guill@verbatim@font\ecguills{cmtt}%
                   \let\guillemotleft\@oguills\let\guillemotright\@fguills}

\begingroup \catcode`\<=13 \catcode`\>=13
\def\x{\endgroup
 \def\ae@lfguill{<<}%
 \def\ae@rfguill{>>}%
}\x

\newcommand{\ecguills}[1]{%
  \def\selectguillfont{\fontencoding{T1}\fontfamily{#1}\selectfont}%
  \def\@oguills{{\selectguillfont\symbol{19}}}%
  \def\@fguills{{\selectguillfont\symbol{20}}}%
  } 

\newcommand{\aeguills}{%
  \ae@guills
  % We redefine \guillemotleft and \guillemotright
  % in order to catch them when they are used 
  % with \DeclareInputText (in latin1.def for instance)
  % We use \auxWARNINGi as a safe indicator that french.sty is used.
  \gdef\guillemotleft{\ifx\auxWARNINGi\undefined
                         \@oguills % neither french.sty nor frenchle.sty
                      \else
                         \ifx\aeguillfrenchdefault\frenchname
                           \ae@lfguill  % french.sty
                         \else
                           \@oguills    % frenchle.sty
                         \fi
                      \fi}%
  \gdef\guillemotright{\ifx\auxWARNINGi\undefined
                         \@fguills % neither french.sty nor frenchle.sty
                       \else
                         \ifx\aeguillfrenchdefault\frenchname
                           \ae@rfguill  % french.sty
                         \else
                           \@fguills    % frenchle.sty
                         \fi
                       \fi}%
  }

%
% Depending on the class option
% define the internal command \ae@guills
\@ae@switch{% ec
  \newcommand{\ae@guills}{%
    \ecguills{cmr}}%
}{% cm
  \newcommand{\ae@guills}{%
    \def\selectguillfont{\fontencoding{U}\fontfamily{lasy}%
            \fontseries{m}\fontshape{n}\selectfont}%
    \def\@oguills{\leavevmode\nobreak
                \hbox{\selectguillfont (\kern-.20em(\kern.20em}\nobreak}%
    \def\@fguills{\leavevmode\nobreak
                \hbox{\selectguillfont \kern.20em)\kern-.2em)}%
                \ifdim\fontdimen\@ne\font>\z@\/\fi}}%
}{% cyr
  \newcommand{\ae@guills}{%
    \def\selectguillfont{\fontencoding{OT2}\fontfamily{wncyr}\selectfont}%
    \def\@oguills{{\selectguillfont\symbol{60}}}%
    \def\@fguills{{\selectguillfont\symbol{62}}}}
}{% pl
  \newcommand{\ae@guills}{%
    \def\selectguillfont{\fontencoding{OT4}\fontfamily{cmr}\selectfont}%
    \def\@oguills{{\selectguillfont\symbol{174}}}%
    \def\@fguills{{\selectguillfont\symbol{175}}}}
}{% lm
  \newcommand{\ae@guills}{%
    \ecguills{lmr}}%
}


\AtBeginDocument{%
  \ifx\GOfrench\undefined
    \aeguills
  \else
    \let\aeguill@GOfrench\GOfrench
    \gdef\GOfrench{\aeguill@GOfrench \aeguills}%
  \fi
  }

\endinput