%%
%% This is file `cmdtrack.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% cmdtrack.dtx 
%% 
%%% ====================================================================
%%%  @LaTeX-file{
%%%     filename        = "cmdtrack.sty",
%%%     version         = "1.06",
%%%     date            = "2012/12/18",
%%%     author          = "Michael John Downes",
%%%     copyright       = "Copyright 1999 Michael John Downes.
%%%                        Copyright 2012 TeX Users Group.
%%% This work may be distributed and/or modified under the
%%% conditions of the LaTeX Project Public License, either version 1
%%% 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 2003/12/01 or later.
%%%                        ",
%%%  }
%%% ====================================================================
%% Self-documenting section
\ifcat ?$\relax{\catcode37=7 \catcode127=9 \def\0{\@sanitize\catcode}\fi
%%? \endlinechar125\catcode127=13\def%%?{\typeout}\037=7
%%?{====================================================================
%%?{ With the cmdtrack package, all commands and environments defined
%%?{ between \usepackage{cmdtrack} and \begin{document} will be marked
%%?{ for logging. A report on the usage of the marked commands will be
%%?{ printed in the LaTeX log file. Standard LaTeX methods must be used
%%?{ for defining the commands (things defined with \def, for example,
%%?{ won't be logged). Use \untrack{\cmd,\othercmd,...} just before
%%?{ \begin{document} to turn off tracking for selected commands.
%%?{
%%?{ Package options:
%%?{
%%?{ ?       Causes this information to be shown on-screen.
%%?{
%%?{ morose  Opposite of verbose: causes the brief message about the ?
%%?{         option to be suppressed.
%%?{
%%?{ Support for the following is not [yet] provided:
%%?{ \DeclareTextSymbol, \DeclareMathRadical, \DeclareMathAlphabet, and
%%?{ some others.
%%?{
%%?{ More comprehensive documentation for cmdtrack.sty may be found in
%%?{ cmdtrack.dtx.
%%?{====================================================================
%%?{}}\endinput\bgroup
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{cmdtrack}[2012/12/18 v1.06]
\let\commandlist\@empty
\AtEndDocument{\report@command@usage}
\edef\@quotechar{\string"}
\newcommand{\untrack}[1]{%
  \begingroup
  \def\logcmd##1##2{\global\let##1=##2%
    \xdef##2{\@percentchar\the\inputlineno}%
  }%
  \untrack@a#1{,\@gobble}\endgroup
}
\def\untrack@a#1{%
  \ifx,#1\@gobbletwo\expandafter\@gobble
  \else \expandafter\untrack@b\meaning#1\@nil#1%
  \fi
  \untrack@a
}
\def\untrack@b#1->#2#3#4#5#6#7#8#9\@nil{%
  \expandafter\ifx\csname #3#4#5@#6#7#8\endcsname\log@cmd
  \else
    \def\@tempa##1{%
      \PackageWarningNoLine{cmdtrack}{%
Command \protect##1 does not have tracking turned on}%
    }%
    \expandafter\@tempa
  \fi
}
\def\@isreserved@a#1\reserved@a#2#3@{#2}
\let\@hash@\relax
\def\log@cmd#1#2{%
  \if\@isreserved@a#2T\reserved@a F@T%
    \endgroup
  \else
    \toks@\expandafter{\commandlist#1}%
    \xdef\commandlist{\the\toks@}%
    \endgroup
    \def#2{\logcmd#2#1}%
  \fi
  \let\@hash@##%
  \l@ngrel@x\expandafter\def\expandafter#1\reserved@a
}
\def\logcmd#1#2{%
  \ifx\protect\@typeset@protect
    \global\let#1#2%
    \xdef#2{\@percentchar\the\inputlineno}%
  \else
    \expandafter\protect
  \fi
  #1%
}
\begingroup \catcode`\"=12
\gdef\cmd@check#1->#2#3-#4\@nil#5{%
  \if\@percentchar#2\typeout{\string#5" was used on line #3}%
  \else\typeout{\string#5" was never used}%
  \fi
}
\endgroup
\def\report@command@usage{%
  \def\@tempa{\typeout{=========================================}}%
  \@tempa
  \begingroup \escapechar\m@ne
  \def\do##1{%
    \ifx\advance##1\expandafter\@gobbletwo\fi
    {\expandafter\cmd@check\meaning##1->@-\@nil##1}%
    \do
  }%
  \expandafter\do\commandlist \advance\z@\z@
  \endgroup
  \@tempa
}
\def\testthm#1{%
  \expandafter\testthm@a\csname#1\expandafter\endcsname
    \csname\@quotechar#1\endcsname
}
\let\old@newtheorem\newtheorem
\def\newtheorem#1{%
  \AtBeginDocument{\testthm{#1}}%
  \old@newtheorem{#1}%
}
\def\testthm@a#1#2{%
  \begingroup
  \toks@\expandafter{\commandlist#2}%
  \xdef\commandlist{\the\toks@}%
  \endgroup
  \let#2#1%
  \def#1{\logcmd#1#2}%
}
\def\set@mathchar#1#2#3#4{%
  \expandafter\set@mathchar@a
  \csname\@quotechar math character \string#2\expandafter\endcsname
  \expandafter{\number`#2}{#1}{#3}{#4}%
}%
\def\set@mathchar@a#1#2#3#4#5{%
  \global\mathcode#2=\@quotechar 8000
  \global\mathchardef#1\@quotechar\mathchar@type#4\hexnumber@#3#5\relax
  \toks@\expandafter{\commandlist#1}%
  \xdef\commandlist{\the\toks@}%
  \begingroup \lccode`\.=#2\lccode`\~=#2\lowercase{\endgroup
    \gdef~{\global\mathcode#2=#1\logcmd#1#1}}%
}
\def\set@mathsymbol#1#2#3#4{%
  \begingroup \escapechar=`\"\relax
  \global\expandafter\mathchardef
    \csname\string#2\endcsname
    \@quotechar\mathchar@type#3\hexnumber@#1#4\relax
  \expandafter\log@cmd@a\csname\string#2\endcsname#2%
}
\def\set@mathaccent#1#2#3#4{%
  \xdef#2{\mathaccent\@quotechar\mathchar@type#3\hexnumber@#1#4\relax}%
  \begingroup \escapechar`\"\relax
  \expandafter\log@cmd@a\csname\string#2\endcsname#2%
}
\def\log@cmd@a#1#2{%
  \toks@\expandafter{\commandlist#1}%
  \xdef\commandlist{\the\toks@}%
  \endgroup
  \gdef#2{\logcmd#2#1}%
}
\DeclareOption{?}{\AtEndOfPackage{\ShowPackageInfo{cmdtrack}}}
\DeclareOption{morose}{}
\DeclareOption{simple}{%
  \def\logcmd#1#2{%
    \ifx\protect\@typeset@protect
      \global\let#1#2%
      \begingroup \escapechar\m@ne
      \typeout{\string#2\string" was used on line \the\inputlineno}%
      \endgroup
    \else
      \expandafter\protect
    \fi
    #1%
  }%
  \AtBeginDocument{\global\let\commandlist\@empty}%
  \global\let\report@command@usage\relax
}
\ProcessOptions\relax
\begingroup
\catcode`\%=9 \catcode`\&=14 \catcode`\"=12
\@ifpackagewith{cmdtrack}{morose}{\catcode`\%=14 }{}
\@ifpackagewith{cmdtrack}{?}{\catcode`\%=14 }{}
%%\typeout{&
%%Try "\string\usepackage[\string ?]{cmdtrack}"
%%to see information on using this package^^J&
%%[including how to turn off this "helpful" message].&
%%}
\endgroup
\newcommand{\ShowPackageInfo}[1]{%
  \begingroup \catcode`\?=3
  \input{#1.\@pkgextension}%
  \endgroup
}
\let\@@yargdef\@yargdef
\AtBeginDocument{\let\@yargdef\@@yargdef}
\let\@hash@\relax
\def\@yargdef #1#2#3{%
  \@tempcnta#3\relax \advance\@tempcnta\@ne \let\@hash@\relax
  \edef\reserved@a{\ifx#2\tw@ [\@hash@ 1]\fi}%
  \@tempcntb#2%
  \@whilenum\@tempcntb<\@tempcnta\do{%
    \edef\reserved@a{\reserved@a\@hash@\the\@tempcntb}%
    \advance\@tempcntb\@ne
  }%
  \begingroup \escapechar=`\"\relax
  \expandafter\log@cmd\csname\string#1\endcsname#1%
}
\endinput
%%
%% End of file `cmdtrack.sty'.
