% \iffalse meta-comment
% http://www.texdev.net/2009/10/06/a-model-dtx-file/
% !TEX program  = pdfLaTeX
%<*internal>
\iffalse
%</internal>
%<*internal>
\fi
\def\nameofplainTeX{plain}
\ifx\fmtname\nameofplainTeX\else
  \expandafter\begingroup
\fi
%</internal>
%<*install>
\input docstrip.tex
\keepsilent
\askforoverwritefalse
\preamble
\endpreamble
\ifx\fmtname\nameofplainTeX
\generate{
  \file{\jobname.sty}{\from{\jobname.dtx}{package}}
}
\fi
%</install>
%<install>\endbatchfile
%<*internal>
\ifx\fmtname\nameofplainTeX
  \expandafter\endbatchfile\else
  \expandafter\endgroup\fi
%</internal>
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{lmacs}
%<package> [2012/05/30 v1.1 Imports local macro files]
%<*driver>
\documentclass{ltxdoc}
%\usepackage{\jobname}
%\usepackage[numbered]{hypdoc}
%\EnableCrossrefs
%\CodelineIndex
%\RecordChanges
\begin{document}
  \DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
%
%\GetFileInfo{\jobname.sty}
%
%\title{The  \textsf{\jobname} Package}
%\author{D. P. Story}
%\date{Released \today}
%
%\maketitle
%
%\StopEventually{^^A
%  \PrintChanges
%  \PrintIndex
%}
%
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
% \paragraph*{Description.} This package is used to clean up the
% preamble of {\LaTeX} files. Some preambles have a (large) number of definitions
% in them. To clean up the preamble, move the definitions in the preamble into a separate file, and
% use this package in import them into your preamble. Normally,
% \textsf{lmacs} would have a position that follows all packages for the
% document.
%
% \textsf{lmacs} stands for \underbar{l}ocal \underbar{mac}ro\underbar{s}. Normally, the files referenced are in the same folder
% as the main source file; they should not (but can) be in the search path of {\LaTeX}.
%
% \paragraph*{Demo files:} \texttt{lmacs\_tst.tex} (a simple latex source)
% and \texttt{lmacs\_aeb.tex} (a file that uses the \textsf{web} and \textsf{exerquiz} packages).
% These are found in the \texttt{examples} folder.
%
% \paragraph*{Documentation and Code.}
% We begin by requiring \texttt{kvoptions}, this package does not test for the presence
% of a class file, so we can use it. It allows us to define key-values as options of the
% package.
%    \begin{macrocode}
\RequirePackage{kvoptions}[2009/07/21]
%    \end{macrocode}
%    \begin{macrocode}
%    \end{macrocode}
%    \begin{macro}{cfg}
%    \begin{macro}{def}
%    \begin{macro}{js}
%    With these keys, you can specify the file with the specified extension be imported.
%    For example, the following line
%\begin{verbatim}
%   \usepackage[cfg=myconf,def=mydef,js=myjs]{lmacs}
%\end{verbatim}
% will import (using \cs{InputIfFileExists}) the files \texttt{myconf.cfg},
% \texttt{mydef.def}, and \texttt{myjs.js}. Multiple specifications of the same
% extension is permitted, for example,
%\begin{verbatim}
%   \usepackage[def=mydef1,def=mydef2]{lmacs}
%\end{verbatim}
%    \begin{macrocode}
\let\LM@inputlist\@empty
%    \end{macrocode}
% \cmd{\LM@input} inputs \texttt{\#1.\#2}, while \cmd{\LM@warning} issues
% a package warning if \texttt{\#1.\#2} is not found.
%    \begin{macrocode}
\newcommand{\LM@input}[2]{\InputIfFileExists{#1.#2}{}%
    {\LM@warning{#1}{#2}}}
\newcommand{\LM@warning}[2]{\PackageWarning{lmacs}
            {The file #1.#2 cannot be found}}
%    \end{macrocode}
% \DescribeMacro{!cfg}\DescribeMacro{!def}\DescribeMacro{!js}For each of these options, we add the specified file to
% \cs{LM@inputlist}, this will be executed at the end of the package. The three options
% \texttt{!cfg}, \texttt{!def}, \texttt{!js} do nothing, making it easy to include, or
% not include a file.
%    \begin{macrocode}
\define@key{lmacs}{cfg}{\g@addto@macro\LM@inputlist{\LM@input{#1}{cfg}}}
\define@key{lmacs}{!cfg}{}
\define@key{lmacs}{def}{\g@addto@macro\LM@inputlist{\LM@input{#1}{def}}}
\define@key{lmacs}{!def}{}
\define@key{lmacs}{js}{\g@addto@macro\LM@inputlist{\LM@input{#1}{js}}}
\define@key{lmacs}{!js}{}
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \begin{macrocode}
\ProcessKeyvalOptions{lmacs}
%    \end{macrocode}
%    Once the options have been process, we execute the command
%    \cs{LM@inputlist} which contains a list of the files to be input.
%    \begin{macrocode}
\LM@inputlist
%    \end{macrocode}
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%\Finale
