%% 
%% \iffalse ^^A we skip the debug setting
\IfFileExists{\string~/bin/gen_and_xela}{\errorcontextlines=1000 }{}
%% \fi
%% ^^A $Id: TheUltimateMaster.gmd,v 0.250 2010/10/24 14:42:35 natror Exp natror $
%% This is file “gmurl.sty” generated with the DocStrip utility.
%% 
%%
%% The original source files were:
%%
%% gmutils/gmutils.gmd  (with options: `url')
%%
%% 
%% Copyright ©  
%% by Grzegorz ‘Natror’ Murzynowski
%% natror (at) o2 (dot) pl
%% 
%% This program is subject to the LaTeX Project Public License.
%% See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html
%% for the details of that license.
%%
%% LPPL status: "author-maintained".
%%
%% 
%% 
%% For the documentation please refer to the file(s)
%% gmutils.{gmd,pdf}.
%% 
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{gmurl}
    [2010/10/24 v0.993 modifications to the url package (GM)]


%%
%%
%%     ^^A\typeout{\unexpanded{#4}}%%


\RequirePackage{gmcommand}


\def\urladdstar{%
  \AtBeginDocument{%
    \@ifpackageloaded{hyperref}{%
      \Store@Macro\url
      \pdef\url{\gmu@ifstar{\nolinkurl}{\storedcsname{url}}}%
    }{}}}

\@onlypreamble\urladdstar

\@ifXeTeX{%
  \pdef\UrlFix{\AtBeginDocument{%
      \@ifpackageloaded{url}{\gmu@UrlFix}{}}%
    \relaxen\UrlFix}%
  %
  \AtBeginDocument{%
    \pdef\UrlFix{%
      \@ifpackageloaded{url}{\gmu@UrlFix}{}%
      \relaxen\UrlFix}}%
}
{%
  \pdef\UrlFix{\PackageWarning{gmutils}{!!! The \string\UrlFix\space
      declaration works only with XeTeX}}%
}

\@ifXeTeX{}{%
  \edef\gmu@restoreUpUpUp{\catcode`\@nx\^^^=\the\catcode`\^^^}%
  \AtEndOfPackage\gmu@restoreUpUpUp
  \catcode`\^^^=9 }

\def\gmu@UrlFix{%
  % \stanza
  % default style assignments
  \def\UrlBreaks{\do\.\do\@\do\\\do\/\do\!\do\_\do\|\do\;\do\]%
    \do\)\do\,\do\?\do\'\do\"\do\+\do\=\do\#\do\%\do\~\do\_\do\|%
    \do\{\do\}\do\$}%
  \def\UrlBigBreaks{\do\:}%
  \def\UrlNoBreaks{\do\(\do\[\do\{}%
  \def\UrlSpecials{%
    \do\ {\hbox{\visiblespace}}\do\^^M{\hbox{\visiblespace}}}%
  % \stanza
  %
  % \stanza
  \def\Url@Format##1{%
    \UrlFont
    \ifdefined\verbatim@specials
      \catcode`\>\active
      \verbatim@specials
      \verbatim@mathhack
    \fi % setting of
    % the escape char, begin and end group and optionally math shift,
    % defined in \pk{gmverb}.
    \gmu@UrlSetup
    \UrlLeft
    \edef\gmu@theendlinechar{\the\endlinechar}%
    \endlinechar\m@ne
    \kern\z@% to forbid hyphenating the first word if the \ac{URL}
    % begins with a~word
    \hyphenchar\font=\UrlHyphenchar\relax
    \let\-\gmu@discretionaryhyphen
    \scantokens{##1}%
    \endlinechar\gmu@theendlinechar\relax
    \UrlRight
  }% of |\Url@Format|.
  % \stanza
  \edef\UrlHyphenchar{%
    \ifdefined\gmv@hyphenchar\gmv@hyphenchar
    \else"A6 \fi}% \label{UrlHyphenchar} broken bar, |¦| or the same as
  % provided in \pk{gmverb} for verbatims. You
  % can redefine it as you please. This char is used as the
  % hyphenation char in \ac{URL}s and therefore should be different
  % from |-| (hyphen), which is often a part of an \ac{URL}. The
  % broken bar seems to be quite unlikely in \ac{URL}s and/or file
  % names.
  % \stanza
  \def\verbatim@mathhack{%
    \ifdefined\verbatim@specials@list
      \@xa\verbatim@mathhack@\verbatim@specials@list
    \fi
  }%
  % \stanza
  \def\verbatim@mathhack@##1##2##3##4##5##6{%
    \IfValueT{##4}{%
      \edef\gmu@thinmuskip{\the\thinmuskip}%
      \edef\gmu@medmuskip{\the\medmuskip}%
      \edef\gmu@thickmuskip{\the\thickmuskip}%
      \begingroup
      \lccode`\~=`##4\lowercase{%
        \endgroup\def~####1~}%
      {$\thinmuskip\gmu@thinmuskip\relax
        \medmuskip\gmu@medmuskip\relax
        \thickmuskip\gmu@thickmuskip\relax
        ####1%
        $}%
      \catcode`##4\active
    }%
  }%
  %\stanza
  \def\gmu@UrlSetup{%
    \medmuskip\Urlmuskip \thickmuskip\medmuskip \thinmuskip0mu%
    \relpenalty\UrlBigBreakPenalty \binoppenalty\UrlBreakPenalty
    \def\do{\gmu@doUrlMath\UrlBreakPenalty}\UrlBreaks % bin
    % (\incs{hyphenpenalty} anyway)
    \def\do{\gmu@doUrlMath\UrlBigBreakPenalty}\UrlBigBreaks % rel
                                % (\incs{hyphenpenalty} anyway)
    \def\do{\gmu@doUrlMath\@M}\UrlNoBreaks % open (no break)
    \def\do{\gmu@doUrlMathAc\UrlBreakPenalty}% (\incs{hyphenpenalty})
    \UrlSpecials
    \if \iffontchar\font"2329 1\else0\fi\iffontchar\font"232A 1\else2\fi
    % \nostanza we check whether the font provides both left and right
    % angle brackets. \nostanza
      \gmu@measurewd{^^^^2329}%
      \edef\gmu@tempa{%
        \@nx\gmu@doUrlMathAc\@M\@nx\<{%
          \hbox to\gmu@tempb{\unexpanded{\hss\char"2329 \hss}}}%
        }\gmu@tempa
      \gmu@measurewd{^^^^232a}%
      \edef\gmu@tempa{%
        \@nx\do\@nx\>{%
          \hbox to\gmu@tempb{\unexpanded{\hss\char"232A \hss}}}%
        }\gmu@tempa
    \else
      \gmu@doUrlMathAc\@M\<{\langle}\do\>{\rangle}%
    \fi
    \iffontchar\font"22C6 % low star
      \do\*{\hbox{\char"22C6 }}%
    \else \do\**%
    \fi
    \ifx\do@url@hyp\@empty
      \gmu@measurewd{-}% this macro is defined in line \ref{@measurewd}.
      \edef\gmu@tempa{%
        \unexpanded{\gmu@doUrlMathAc\@M\-}%
        {\hbox to \gmu@tempb{\unexpanded{\hss-\hss}}%
          \@nx\-}% hyphen is a
        % good point for hyphenation, but the hyphenation char should
        % be sth. else, and it is indeed: |¦| (broken bar,
        % |\char"A6|). See also line \ref{UrlHyphenchar}
      }\gmu@tempa
    \fi
    \addfontfeature{Ligatures=NoCommon, Mapping=none}% instead of
    % ‘doing’ \incs{ver\+bat\+im\+@\+no\+lig\+@\+list}.
  }% of |\gmu@UrlSetup|.
  % \stanza
  %
  % \stanza
  \def\gmu@doUrlMath##1##2{%\
    % \begin{enumargs}
    % \item value of the penalty (used as a~Boolean: if $<$
    % \thous 10000, \nlperc\cs{hyphenpenalty} will be used anyway, if $\ge$
    % \thous10000, there will be no \incs{discretionary}),
    % \item the char, given as |\⁄<char>|.
    % \end{enumargs}
    \begingroup
    \lccode`\~=`##2\lowercase{%
      \endgroup\def~{\@ifnextchar~}%
      \@xa\addtomacro\@xa~}% of |\lowercase|.
    \ifnum##1<\@M
    {%
      {\char`##2\csname gmu@dbl\string##2kern\endcsname}% if next is  the same char
      {\ifmmode\char`##2% else
        \else\gmu@urlbreakable{##1}{##2}%
        \fi}%
    }% of |\addtomacro|'s argument |\ifnum| true.
    \else
    {%
      {\char`##2\csname gmu@dbl\string##2kern\endcsname}{\char`##2}%
    }% of |\addtomacro|'s argument |\ifnum| false.
    \fi
      \catcode`##2=\active
    }% of |\gmu@doUrlMath|.
  % \stanza
  \def\gmu@doUrlMathAc##1##2##3{%\
    % \begin{enumargs}
    % \item  (value of) a~penalty (see the remark to \inverb|##1| of
    % the previous macro),
    % \item the char (as |\⁄<char>|),
    % \item the definition.
    % \end{enumargs}
    \begingroup
    \lccode`\~=`##2\lowercase{%
      \endgroup\def~{\@ifnextchar~}%
      \@xa\addtomacro\@xa~}% of |\lowercase|.
    \ifnum ##1<\@M
    {%
      {\ifmmode\char`##2\else$##3\m@th$\fi}%
      {\ifmmode\char`##2%
        \else\discretionary{\hbox{$##3\m@th$}}{}{\hbox{$##3\m@th$}}%
        \fi}%
    }% of |\addtomacro|'s argument if num true.
    \else
    {%
      {\ifmmode\char`##2\else$##3\m@th$\fi}{\ifmmode\char`##2\else$##3\m@th$\fi}%
    }% of |\addtomacro|'s argument if num false.
    \fi
    \catcode`##2=\active
  }% of |\gmu@doUrlMathAc|.
  % \stanza
  \pdef\gmu@url@rigidbreak##1##2{\discretionary{\char`##2}{}{\char`##2}}%
  % \stanza
  \pdef\gmu@url@flexbreak##1##2{\penalty\@M \hskip\z@ plus0,03em
    \char`##2\penalty##1\hskip\z@ plus0,03em\relax}%
  % \stanza
  \let\gmu@urlbreakable\gmu@url@flexbreak
  % \stanza
  \def\Url@z##1{%
    %  Do any hyper referencing due to hyperref (or perform a url-def)
    \Url@HyperHook
    % Now do the formatting in a group (can also have \incs{Url@HyperHook} take
    % this as an argument). \nostanza
    {\Url@Format{##1}}%
    \endgroup}%
  % \stanza
  \DeclareUrlCommand\file{\urlstyle{sf}}%
  % \stanza
  \emptify\Url@moving% with our settings |\url| is pretty allowed in
  % moving arguments, I~hope.
}% of |\gmu@UrlFix|.

\DeclareCommand\UrlSlashKern{O{tt}m}%
{\AtBeginDocument{%
    \@nameedef{url@#1style}{\def\@nx\UrlFont{%
        \@xanxcs{#1family}%
        \def\@xanxcs{gmu@dbl\string\/kern}%
        {\kern#2\relax}%
      }% of |\UrlFont|
    }% of |\url#1style|
    \urlstyle{#1}%
  }% of |\AtBeginDocument|
}% of |\UrlSlashKern|

\def\DeclareUrlCommand#1#2{\pdef#1{\leavevmode\begingroup #2\Url}}

\foolc ~ : {%
  \@ifXeTeX{%
    \def\metaat~{%
      \penalty\@M \hskip\z@skip
      \meta{аt}% it's a Cyrillic »a«!
      \penalty\exhyphenpenalty
      \hskip\z@skip
    }%
    %
    \def\metadot~{%
      \penalty\@M \hskip\z@skip
      \meta{dоt}% it's a Cyrillic »o«!
      \penalty\exhyphenpenalty
      \hskip\z@skip
    }%
  }% of if \XeTeX
  {%
    \def\metaat~{\PackageError{gmurl}{Command \bslash metaat
        works only in XeTeX}@}%
    %
    \def\metadot~{\PackageError{gmurl}{Command \bslash metaat
        works only in XeTeX}.}%
  }% of if not XeTeX
}% of |\foolc|

%%% (For my GNU Emacs:)
%%% Local Variables:
%%% mode: doctex
%%% coding: utf-8
%%% End:
\endinput
%%
%% End of file `gmurl.sty'.
