\NeedsTeXFormat{LaTeX2e}[1994/12/01]
\ProvidesPackage{inputtrc}[2010/10/09 v0.2 input tracing (UL)]

%% Copyright (C) 2010 Uwe Lueck, 
%% http://www.contact-ednotes.sty.de.vu 
%% -- author-maintained in the sense of LPPL below -- 
%%
%% This file can be redistributed and/or modified under 
%% the terms of the LaTeX Project Public License; either 
%% version 1.3a of the License, or any later version.
%% The latest version of this license is in
%%     http://www.latex-project.org/lppl.txt
%% We did our best to help you, but there is NO WARRANTY. 
%%
%% Please report bugs, problems, and suggestions via 
%% 
%%   http://www.contact-ednotes.sty.de.vu 
%%
%% === Core Definitions ===
%% Initializations of indent, current filename, and filename stack: 
\gdef\IT@indent{\IT@indent@unit}
\xdef\IT@currfile{\jobname\space}
%% ... TODO: add `.tex' unless ...
\xdef\IT@filestack{\relax} 
%% ... `\relax' saves braces around job file name 
%% when the file stack is unbuilt. 
%%
%% |\IT@prim@input{<file>}| will replace \LaTeX's \cs{@@input}
%% (at certain places, see below).
\newcommand*{\IT@prim@input}[1]{%
  \typeout{\IT@indent\IT@currfile INPUTTING #1}%
%% ... TODO: option to write to `.log' only.
  \xdef\IT@filestack{{\IT@currfile}\IT@filestack}%
  \xdef\IT@currfile{#1}%
  \expandafter \gdef\expandafter \IT@indent\expandafter{%
    \IT@indent \IT@indent@unit}
  \@@input#1
  \expandafter\IT@pop@indent\IT@indent   \@nil
  \expandafter\IT@pop@file  \IT@filestack\@nil
  \IT@maybe@returnmessage                           %% v0.2
} 
\def\IT@pop@indent#1#2\@nil{\gdef\IT@indent{#2}}
\def\IT@pop@file  #1#2\@nil{%
  \gdef\IT@currfile{#1}\gdef\IT@filestack{#2}}
%% ... cf. LaTeX's `\@pushfilename'/`\@popfilename'.
\newcommand*{\IT@the@returnmessage}{%               %% v0.2
    \typeout{\IT@indent RETURNING TO \IT@currfile}}
%% ... the ``active" version of `\IT@maybe@returnmessage', 
%%     see below ...
%%
%% === Changing \LaTeX\ (Preparations) ===
%%
%% Changing \LaTeX's `\@@input' 
%% (that stores \TeX's primitive `\input')
%% is not easy 
%% (cf. Didier Verna on his 'fink' 
%%  package,\footnote{\url{http://ctan.org/pkg/fink}} 
%%  also 'inputfile'); 
%% but it should suffice to change two of the three
%% %% <- `the two' was wrong 2010/10/08b ->
%% \LaTeX\ commands that use `\@@input':
\newcommand\IT@InputIfFileExists[2]{%
  \IfFileExists{#1}%
    {#2\@addtofilelist{#1}\IT@prim@input\@filef@und}}
%% ... \LaTeX's version is `\long', as opposed to `\@input':
\newcommand*{\IT@input}[1]{%
  \IfFileExists{#1}{\IT@prim@input\@filef@und}%
                   {\typeout{No file #1.}}}
%% ... the third macro using `\@@input' is `\input'---too 
%% difficult for now. 
%%
%% Storing original \LaTeX:
\let\IT@ltx@InputIfFileExists\InputIfFileExists
\let\IT@ltx@input\@input
%%
%% === The User Commands ===
%% |\dotracinginputs| globally activates input tracing: 
\newcommand*{\dotracinginputs}{%
    \global \let \InputIfFileExists \IT@InputIfFileExists
    \global \let \@input            \IT@input}
%% |\notracinginputs| globally turns input tracing off: 
\newcommand*{\notracinginputs}{%
    \global \let \InputIfFileExists \IT@ltx@InputIfFileExists
    \global \let \@input            \IT@ltx@input}
%% |\setinputindentunit{<cmds>}| globally sets the ``indent unit"---the 
%% default setting is <cmds>~= `\space\space':
\newcommand*{\setinputindentunit}{\gdef\IT@indent@unit}
\setinputindentunit{\space\space}
%% |\dotracingreturns| activates the \texttt{RETURNING~TO} message--- 
\newcommand*{\dotracingreturns}{%
    \global \let \IT@maybe@returnmessage \IT@the@returnmessage} 
%% ---|\notracingreturns| turns it off---
\newcommand*{\notracingreturns}{%
    \global \let \IT@maybe@returnmessage \IT@the@returnmessage} 
%% ---\emph{not} activated is the default:
\notracingreturns
%% |\dotracinginputsreturns| activates \emph{both} `INPUTTING' and 
%% `RETURNING' messages:
\newcommand*{\dotracinginputsreturns}{%
    \dotracinginputs \dotracingreturns}
%%
\endinput
%%
%% == Coda ==
%% You can't overestimate my pride! 
%% \emph{That's one small step for a man---one giant leap for \TeX kind.}
%%
%% On the other hand, I probably exhausted the set of possible 
%% trials and errors (becoming euphoric when it suddenly worked).
%%
%% \bigskip \noindent \itshape
%% Dedicated to Koppa Aleph Rio Lord.
%% 
%% \bigskip \raggedleft 
%% Worms-Pfeddersheim~2010/10/08,~U.~L.

HISTORY

v0.1   2010/10/08   very first, installed on CTAN same day
v0.1a  2010/10/08   doc corrected: LaTeX commands using \@@input; 
                    manual page breaks -- installed on CTAN 2010/10/09 
v0.2   2010/10/09   \IT@maybe@returnmessage etc.
