summaryrefslogtreecommitdiff
path: root/Master/texmf-dist
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2014-05-13 22:14:10 +0000
committerKarl Berry <karl@freefriends.org>2014-05-13 22:14:10 +0000
commit64e8cd35199c3cfdc156487e9cc4b41c3fa86e21 (patch)
tree21112117fb03b7bd9e6223404dc47f4709ee105b /Master/texmf-dist
parent8ed901e81f474c7cf2946183f99b5836d40ffcd7 (diff)
pkgloader (10may14)
git-svn-id: svn://tug.org/texlive/trunk@34019 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r--Master/texmf-dist/doc/latex/pkgloader/README4
-rw-r--r--Master/texmf-dist/doc/latex/pkgloader/pkgloader-packagedoc.cls4
-rw-r--r--Master/texmf-dist/doc/latex/pkgloader/pkgloader.pdfbin427828 -> 454292 bytes
-rw-r--r--Master/texmf-dist/doc/latex/pkgloader/pkgloader.tex101
-rw-r--r--Master/texmf-dist/doc/latex/pkgloader/test1.sty3
-rw-r--r--Master/texmf-dist/doc/latex/pkgloader/test2.sty3
-rw-r--r--Master/texmf-dist/doc/latex/pkgloader/test3.sty3
-rw-r--r--Master/texmf-dist/tex/latex/pkgloader/pkgloader-cls-pkg.sty (renamed from Master/texmf-dist/tex/latex/pkgloader/pkgloader-test-rules.sty)12
-rw-r--r--Master/texmf-dist/tex/latex/pkgloader/pkgloader-error.sty8
-rw-r--r--Master/texmf-dist/tex/latex/pkgloader/pkgloader-false.sty3
-rw-r--r--Master/texmf-dist/tex/latex/pkgloader/pkgloader-recommended.sty4
-rw-r--r--Master/texmf-dist/tex/latex/pkgloader/pkgloader.sty341
12 files changed, 323 insertions, 163 deletions
diff --git a/Master/texmf-dist/doc/latex/pkgloader/README b/Master/texmf-dist/doc/latex/pkgloader/README
index 0fccd0a2173..e90a6bb1aa4 100644
--- a/Master/texmf-dist/doc/latex/pkgloader/README
+++ b/Master/texmf-dist/doc/latex/pkgloader/README
@@ -1,9 +1,9 @@
latex-pkgloader
===============
-LaTeX Package : latex-pkgloader 0.1.0
+LaTeX Package : latex-pkgloader 0.2.0
-Last Modified : 2014-01-29
+Last Modified : 2014-05-10
Author : Michiel Helvensteijn (www.mhelvens.net)
diff --git a/Master/texmf-dist/doc/latex/pkgloader/pkgloader-packagedoc.cls b/Master/texmf-dist/doc/latex/pkgloader/pkgloader-packagedoc.cls
index 25cc215c359..be82b57e9f9 100644
--- a/Master/texmf-dist/doc/latex/pkgloader/pkgloader-packagedoc.cls
+++ b/Master/texmf-dist/doc/latex/pkgloader/pkgloader-packagedoc.cls
@@ -108,7 +108,9 @@
alsoletter={_,:},
morekeywords={before,after,late,early,if,
error,always,because,loaded},
- moretexcs={RequirePackage,RequirePackageWithOptions,Load,LoadPackagesNow},
+ moretexcs={RequirePackage,RequirePackageWithOptions,%
+ LoadClass,LoadClassWithOptions,%
+ Load,LoadPackagesNow},
mathescape,
texcsstyle=*\bfseries
}
diff --git a/Master/texmf-dist/doc/latex/pkgloader/pkgloader.pdf b/Master/texmf-dist/doc/latex/pkgloader/pkgloader.pdf
index 0d788800559..c2768ffce6b 100644
--- a/Master/texmf-dist/doc/latex/pkgloader/pkgloader.pdf
+++ b/Master/texmf-dist/doc/latex/pkgloader/pkgloader.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/pkgloader/pkgloader.tex b/Master/texmf-dist/doc/latex/pkgloader/pkgloader.tex
index 1e186cf1ce1..420453ad6a7 100644
--- a/Master/texmf-dist/doc/latex/pkgloader/pkgloader.tex
+++ b/Master/texmf-dist/doc/latex/pkgloader/pkgloader.tex
@@ -32,6 +32,10 @@
\changes{0.1.0}{2014/01/29}
{initial version}
+
+\changes{0.2.0}{2014/05/10}
+ {an important release, which implements most features described in
+ the pkgloader TUGBoat article, and fixes a ton of bugs}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document} %
@@ -42,12 +46,16 @@
\section {Introduction} % % % % % % % % % % % % % % % % % % % % % % % % % % % %
\LaTeX\ can be extended by loading packages
-using a \lstinline+\usepackage+, \lstinline+\RequirePackage+ or \lstinline+\RequirePackageWithOptions+ command.
-Packages can add definitions, change existing ones, or otherwise extend functionality of the language.
-
-While the Turing-complete power of the \TeX\ family is quite useful at times, it does
-make it all too easy for independent package authors to step on each others
-toes. CTAN is full of conceptually independent packages that cannot be
+using a \lstinline+\usepackage+, \lstinline+\RequirePackage+
+or \lstinline+\RequirePackageWithOptions+ command. Similarly, documents load
+a document class using \lstinline+\documentclass+, \lstinline+\LoadClass+
+or \lstinline+\LoadClassWithOptions+.
+Packages and classes can add definitions, change existing ones,
+or otherwise extend functionality of the language.
+
+While the Turing-complete power of the \TeX\ language is quite useful at times,
+it does make it all too easy for independent package authors to step on each
+others toes. CTAN is full of conceptually independent packages that cannot be
loaded together, or break if they are not loaded in a specific order.
Yet, until now, there has been no automated package management to speak of.
@@ -68,31 +76,48 @@ Enter \lstinline+pkgloader+.
Here is an example of main file for a \LaTeX\ document
which uses \lstinline+pkgloader+:
+\newcommand{\morecode}{\hbox{\vphantom{\LARGE(}\smash{\ \small\vdots}}}
+\newcommand{\anyorder}{
+ \smash{\small\hbox{
+ \(
+ \qquad\left.\vrule height 1em depth 1.4em width 0pt\right\}
+ \hbox{\textit{\rmfamily any order}}
+ \)
+} } }
+\newcommand{\optional}{
+ \smash{\small\raisebox{-.7\baselineskip}{
+ \(
+ \qquad\left.
+ \begin{array}{l}\\[.8em]\end{array}
+ \right\}
+ \hbox{\textit{\rmfamily optional}}
+ \)
+} } }
\begin{latex}
-\documentclass{article}
-
\RequirePackage{pkgloader}
- \usepackage{xltxtra}
- \usepackage[xetex]{graphicx}
- $\smash{\raisebox{-1pt}{\small\vdots}}$
-\LoadPackagesNow
-
-\begin{document} $\ldots$ \end{document}
+ \documentclass{article}
+ \usepackage{algorithm}
+ \usepackage{hyperref} $\anyorder$
+ \usepackage{float}
+\LoadPackagesNow $\hskip44.3pt\optional$
+$\morecode$
+\begin{document} $\hdots$ \end{document}
\end{latex}
-The idea is to load \lstinline+pkgloader+ before loading any other package.
-It can then intercept all package loading requests, analyze them
+The idea is to load \lstinline+pkgloader+ before loading any other
+package or class.
+It can then intercept all loading requests, analyze them
and load them properly, taking this burden off the shoulders of
the average document author.
-Between the second and sixth lines, the loading of all packages
-is postponed. The \lstinline+\LoadPackagesNow+ command then
-loads the packages in some valid order. During this process,
+Between the second and fifth line, the loading of all packages
+and classes is postponed. The \lstinline+\LoadPackagesNow+ command then
+loads the packages in some valid order. This also happens automatically
+upon reaching the end of the preamble. During this process,
`conflict resolving' code may also be run, meant specifically to make
other packages work together properly. If the above code were
-compiled without \lstinline+pkgloader+ (using the \XeTeX\ engine, as of this writing),
-the given order between \lstinline+xltxtra+ and \lstinline+graphicx+ would
-cause an error.
+compiled without \lstinline+pkgloader+,
+the given package order would cause errors.
%%
The main advantage to this approach is that the complexity of dealing
with package conflicts is moved to the \lstinline+pkgloader+ package and handled
@@ -138,18 +163,27 @@ instead.
-\subsection {Package Loading Requests} % % % % % % % %
+\subsection {Package / Class Loading Requests} % % % % % % % %
\marginnote{\ttfamily\bfseries\textbackslash usepackage\\
\textbackslash RequirePackage\\
- \textbackslash RequirePackageW{\ldots}s}\noindent
-For requesting specific packages inside the |pkgloader| area,
-just use the three commands always used
-for this purpose: \lstinline+\usepackage+, \lstinline+\RequirePackage+ and
-\lstinline+\RequirePackageWithOptions+. Their syntax and effective semantics
+ \textbackslash RequirePackageW{\ldots}s
+ \textbackslash documentclass\\
+ \textbackslash LoadClass\\
+ \textbackslash LoadClassW{\ldots}s}\noindent
+For requesting specific packages or classes inside the
+|pkgloader| area, just use the commands always used
+for this purpose:
+ \lstinline+\usepackage+,
+ \lstinline+\RequirePackage+ and
+ \lstinline+\RequirePackageWithOptions+, as well as
+ \lstinline+\documentclass+,
+ \lstinline+\LoadClass+ and
+ \lstinline+\LoadClassWithOptions+.
+Their syntax and effective semantics
are the same as they have always been. Their effects are just delayed,
-reordered and perhaps modified by the active rules.
+reordered and perhaps modified by the active \emph{package loading rules}.
@@ -157,7 +191,7 @@ reordered and perhaps modified by the active rules.
\marginnote{\ttfamily\bfseries\textbackslash Load}\noindent
Each invocation if the \lstinline+\Load+ command sets up a rule about
-a package or packages, which are not necessarily ever loaded.
+a class, package or packages, which are not necessarily ever loaded.
These rules can come from any number of different sources.
A central registry will be maintained together with \lstinline+pkgloader+ itself
in the form of |pkgloader-recommended.sty|,
@@ -173,6 +207,7 @@ The \lstinline+\Load+ command expects the following syntax:
\centering
\begin{tabular}{r@{\ \ \ \ }r@{\ \ \ \ }l}
\nt{load} &$::=$& \lstinline+\Load+$\ \nt{package}\ \ \nt{clause}_1\ \ldots\ \nt{clause}_i$ \\
+ &$ \|$& \lstinline+\Load class+$\ \nt{package}\ \ \nt{clause}_1\ \ldots\ \nt{clause}_i$ \\
&$ \|$& \lstinline+\Load error+ $\ \ \ \,\nt{clause}_1\ \ldots\ \nt{clause}_i$ \\[2mm]
\nt{package} &$::=$& \lstinline+[+$\;\nt{options}\;$\lstinline+] {+$\;\nt{pkg}\;$\lstinline+} [+$\;\nt{version}\;$\lstinline+]+ \\[2mm]
@@ -200,7 +235,7 @@ The \lstinline+\Load+ command expects the following syntax:
\vskip\belowdisplayskip
\noindent
-\nt{pkg} represents a package name.
+\nt{pkg} represents a package or class name.
\nt{token{-}list} should expand to a human-readable text without formatting.
\marginnote{\ttfamily\bfseries if}\noindent
@@ -317,8 +352,8 @@ I hope that, with feedback and community collaboration,
use of this package will become widespread and package
authors will be able to work in a more modular fashion.
-\emph{Future versions} of |pkgloader| will be able to deal with
-document classes, to intelligently merge package options
+\emph{Future versions} of |pkgloader| will be able to
+intelligently merge package options
and to track packages loaded by other packages in order
to better inform the user --- perhaps even fix problems
by carrying information into the next run through auxiliary files.
diff --git a/Master/texmf-dist/doc/latex/pkgloader/test1.sty b/Master/texmf-dist/doc/latex/pkgloader/test1.sty
deleted file mode 100644
index 2a01c6236e4..00000000000
--- a/Master/texmf-dist/doc/latex/pkgloader/test1.sty
+++ /dev/null
@@ -1,3 +0,0 @@
-\xdef\PackageOrderLog{\PackageOrderLog\quad test1[\csname opt@test1.sty\endcsname]}
-\DeclareOption*{}
-\ProcessOptions\relax
diff --git a/Master/texmf-dist/doc/latex/pkgloader/test2.sty b/Master/texmf-dist/doc/latex/pkgloader/test2.sty
deleted file mode 100644
index b817cf49be9..00000000000
--- a/Master/texmf-dist/doc/latex/pkgloader/test2.sty
+++ /dev/null
@@ -1,3 +0,0 @@
-\xdef\PackageOrderLog{\PackageOrderLog\quad test2[\csname opt@test2.sty\endcsname]}
-\DeclareOption*{}
-\ProcessOptions\relax
diff --git a/Master/texmf-dist/doc/latex/pkgloader/test3.sty b/Master/texmf-dist/doc/latex/pkgloader/test3.sty
deleted file mode 100644
index 933106879fe..00000000000
--- a/Master/texmf-dist/doc/latex/pkgloader/test3.sty
+++ /dev/null
@@ -1,3 +0,0 @@
-\xdef\PackageOrderLog{\PackageOrderLog\quad test3[\csname opt@test3.sty\endcsname]}
-\DeclareOption*{}
-\ProcessOptions\relax
diff --git a/Master/texmf-dist/tex/latex/pkgloader/pkgloader-test-rules.sty b/Master/texmf-dist/tex/latex/pkgloader/pkgloader-cls-pkg.sty
index 842d73a4679..695921beb88 100644
--- a/Master/texmf-dist/tex/latex/pkgloader/pkgloader-test-rules.sty
+++ b/Master/texmf-dist/tex/latex/pkgloader/pkgloader-cls-pkg.sty
@@ -11,12 +11,14 @@
% and version 1.3 or later is part of all distributions of LaTeX %
% version 2005/12/01 or later. %
% %
-% This work has the LPPL maintenance status `author-maintained'. %
+% This work has the LPPL maintenance status `maintained'. %
% %
% The Current Maintainer of this work is Michiel Helvensteijn. %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \fi %%%%
-
-
-\Load [option=true] {test2} if {test1} before {test1}
-\Load error if {test1 && test3} because {I don't like this combination}
+% %
+% This file is always loaded before the '\usepackage' %
+% requested packages and after all classes. It's %
+% really just a stub in the dependency graph. %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/Master/texmf-dist/tex/latex/pkgloader/pkgloader-error.sty b/Master/texmf-dist/tex/latex/pkgloader/pkgloader-error.sty
index f685e7bcb39..cb626e7d2aa 100644
--- a/Master/texmf-dist/tex/latex/pkgloader/pkgloader-error.sty
+++ b/Master/texmf-dist/tex/latex/pkgloader/pkgloader-error.sty
@@ -45,12 +45,12 @@
%%% package combination is illegal. None of them are
%%% critical or fatal errors; we terminate the run manually.
%
-\int_step_inline:nnvn {1} {1} {g__pkgloader_count_(pkgloader-error)_int} {
- \bool_if:cT {g__pkgloader_used_(pkgloader-error)_(#1)_bool} {
+\int_step_inline:nnvn {1} {1} {g__pkgloader_count_(pkgloader-error.sty)_int} {
+ \bool_if:cT {g__pkgloader_used_(pkgloader-error.sty)_(#1)_bool} {
\msg_error:nnvv
{pkgloader} {illegal-combination}
- {g__pkgloader_condition_(pkgloader-error)_(#1)_tl}
- {g__pkgloader_reason_ (pkgloader-error)_(#1)_tl}
+ {g__pkgloader_condition_(pkgloader-error.sty)_(#1)_tl}
+ {g__pkgloader_reason_ (pkgloader-error.sty)_(#1)_tl}
}
}
diff --git a/Master/texmf-dist/tex/latex/pkgloader/pkgloader-false.sty b/Master/texmf-dist/tex/latex/pkgloader/pkgloader-false.sty
index 0112ef148e8..ad55557ff2d 100644
--- a/Master/texmf-dist/tex/latex/pkgloader/pkgloader-false.sty
+++ b/Master/texmf-dist/tex/latex/pkgloader/pkgloader-false.sty
@@ -19,6 +19,7 @@
% %
% This file is never loaded by pkgloader, and that's its %
% only function: to be 'false' in loading conditions. %
-% Basically, it reserves the name 'pkgloader-false'. %
+% Basically, the file exists to reserve the name %
+% 'pkgloader-false'. %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/Master/texmf-dist/tex/latex/pkgloader/pkgloader-recommended.sty b/Master/texmf-dist/tex/latex/pkgloader/pkgloader-recommended.sty
index f557f91ee59..b1afd9753bf 100644
--- a/Master/texmf-dist/tex/latex/pkgloader/pkgloader-recommended.sty
+++ b/Master/texmf-dist/tex/latex/pkgloader/pkgloader-recommended.sty
@@ -20,6 +20,10 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
+% This is a preliminary list of recommended rules,
+% gathered from a number of sources. It should be
+% expanded.
+%
% \begin{macrocode}
\Load {fixltx2e} early always
\Load {fancyhdr} before {hyperref} if loaded
diff --git a/Master/texmf-dist/tex/latex/pkgloader/pkgloader.sty b/Master/texmf-dist/tex/latex/pkgloader/pkgloader.sty
index 593e8d9c987..e8a1f9f9962 100644
--- a/Master/texmf-dist/tex/latex/pkgloader/pkgloader.sty
+++ b/Master/texmf-dist/tex/latex/pkgloader/pkgloader.sty
@@ -17,7 +17,7 @@
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \fi %%%%
-% \CheckSum{414}
+% \CheckSum{528}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -48,7 +48,7 @@
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{expl3}
-\ProvidesExplPackage{pkgloader}{2014/01/29}{0.1.0}
+\ProvidesExplPackage{pkgloader}{2014/05/10}{0.2.0}
{managing the options and loading order of LaTeX packages}
% \end{macrocode}
%
@@ -110,16 +110,24 @@
\cs_gset_eq:NN \__pkgloader_usepkg:wnw \usepackage
\cs_gset_eq:NN \__pkgloader_RPkg:wnw \RequirePackage
\cs_gset_eq:NN \__pkgloader_RPkgWithOptions:wnw \RequirePackageWithOptions
+\cs_gset_eq:NN \__pkgloader_doccls:wnw \documentclass
+\cs_gset_eq:NN \__pkgloader_LCls:wnw \LoadClass
+\cs_gset_eq:NN \__pkgloader_LClsWithOptions:wnw \LoadClassWithOptions
% \end{macrocode}
%
-% And we define a command to restore the commands back to
-% their pristine versions:
+% And we define a command to clean up any and all commands
+% that we change or introduce. It will be called when they
+% are not needed anymore:
%
% \begin{macrocode}
-\cs_new_protected:Nn \__pkgloader_restore_commands: {
+\tl_new:N \__pkgloader_cleanup_commands:
+\tl_put_right:Nn \__pkgloader_cleanup_commands: {
\cs_gset_eq:NN \usepackage \__pkgloader_usepkg:wnw
\cs_gset_eq:NN \RequirePackage \__pkgloader_RPkg:wnw
\cs_gset_eq:NN \RequirePackageWithOptions \__pkgloader_RPkgWithOptions:wnw
+ \cs_gset_eq:NN \documentclass \__pkgloader_doccls:wnw
+ \cs_gset_eq:NN \LoadClass \__pkgloader_LCls:wnw
+ \cs_gset_eq:NN \LoadClassWithOptions \__pkgloader_LClsWithOptions:wnw
}
% \end{macrocode}
%
@@ -131,11 +139,11 @@
%
% This function globally registers a package loading rule,
% which can be created with either the |\Load| command or
-% any of the three hijacked |\usepackage| commands:
+% any of the hijacked |\usepackage|-like commands:
%
% \begin{macrocode}
\cs_new_protected:Nn \__pkgloader_register_rule:nnnnnnnnn {
- % #1: package name
+ % #1: package or class name
% #2: options
% #3: version
% #4: condition
@@ -146,8 +154,8 @@
% #9: command
% \end{macrocode}
%
-% If this package hasn't been seen before, register
-% it and create a rule-counter for it:
+% If this package or class hasn't been seen before,
+% register it and create a rule-counter for it:
%
% \begin{macrocode}
\prop_if_in:NnF \g__pkgloader_known_pkg_prop {#1} {
@@ -186,34 +194,52 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% These three functions are redefined to just register
-% the package loading information rather than load the
-% package immediately:
+% These six macros are redefined to just register
+% the loading information rather than load the
+% package or class immediately. The distinction between
+% package and class is made by prefixing the name
+% with either |.sty| or |.cls| (which will be stripped
+% off before the file is actually loaded):
%
% \begin{macrocode}
\RenewDocumentCommand {\usepackage} { o m o }
- { \__pkgloader_usepackage_cmd:nnnn
- {\__pkgloader_usepkg:wnw} {#1} {#2} {#3} }
+ { \__pkgloader_usepackage_cmd:nnnnnn
+ {\usepackage} {#1} {#2.sty} {#3}
+ {pkgloader-cls-pkg.sty} {} }
\RenewDocumentCommand {\RequirePackage} { o m o }
- { \__pkgloader_usepackage_cmd:nnnn
- {\__pkgloader_RPkg:wnw} {#1} {#2} {#3} }
+ { \__pkgloader_usepackage_cmd:nnnnnn
+ {\RequirePackage} {#1} {#2.sty} {#3}
+ {} {} }
\RenewDocumentCommand {\RequirePackageWithOptions} { o m o }
- { \__pkgloader_usepackage_cmd:nnnn
- {\__pkgloader_RPkgWithOptions:wnw} {#1} {#2} {#3} }
+ { \__pkgloader_usepackage_cmd:nnnnnn
+ {\RequirePackageWithOptions} {#1} {#2.sty} {#3}
+ {} {} }
+\RenewDocumentCommand {\documentclass} { o m o }
+ { \__pkgloader_usepackage_cmd:nnnnnn
+ {\documentclass} {#1} {#2.cls} {#3}
+ {} {pkgloader-cls-pkg.sty} }
+\RenewDocumentCommand {\LoadClass} { o m o }
+ { \__pkgloader_usepackage_cmd:nnnnnn
+ {\LoadClass} {#1} {#2.cls} {#3}
+ {} {pkgloader-cls-pkg.sty} }
+\RenewDocumentCommand {\LoadClassWithOptions} { o m o }
+ { \__pkgloader_usepackage_cmd:nnnnnn
+ {\LoadClassWithOptions} {#1} {#2.cls} {#3}
+ {} {pkgloader-cls-pkg.sty} }
% \end{macrocode}
%
% Storing this information is delegated to the
% |\__pkgloader_register_rule:nnnnnnnnn| function:
%
% \begin{macrocode}
-\cs_new:Nn \__pkgloader_usepackage_cmd:nnnn {
+\cs_new:Nn \__pkgloader_usepackage_cmd:nnnnnn {
\__pkgloader_register_rule:nnnnnnnnn
- {#3} {#2} {#4} % package name, options, version
- {pkgloader-true} % condition
- {\c_true_bool} % compiled condition
- {} {} % predecessors, successors
- {it~is~loaded~by~the~user} % reason
- {#1} % command
+ {#3} {#2} {#4} % package name, options, version
+ {pkgloader-true.sty} % condition
+ {\c_true_bool} % compiled condition
+ {#5} {#6} % predecessors, successors
+ {it~is~requested~by~the~author} % reason
+ {#1} % command
}
% \end{macrocode}
%
@@ -225,7 +251,8 @@
%
% This is a sophisticated user-level command for manipulating
% package loading order and conditions. It has a `non-standard'
-% but convenient syntax, not showing any standard-
+% but convenient syntax, which scans for clauses rather than
+% taking standard parameters:
%
% \begin{macrocode}
\NewDocumentCommand {\Load} {} {
@@ -234,6 +261,7 @@
% Initialize the variables used for storing given data:
%
% \begin{macrocode}
+ \tl_clear:N \l__pkgloader_load_extension_tl
\tl_clear:N \l__pkgloader_load_options_tl
\tl_clear:N \l__pkgloader_load_name_tl
\tl_clear:N \l__pkgloader_load_version_tl
@@ -241,13 +269,14 @@
\clist_clear:N \l__pkgloader_load_succ_clist
\tl_clear:N \l__pkgloader_load_cond_tl
\tl_clear:N \l__pkgloader_load_because_tl
+ \tl_clear:N \l__pkgloader_load_cmd_tl
\bool_set_false:N \l__pkgloader_early_late_used_bool
% \end{macrocode}
%
% Start scanning for input:
%
% \begin{macrocode}
- \__pkgloader_load_scan_pkg_:w
+ \__pkgloader_load_scan_ext_:w
% \end{macrocode}
% \uninteresting\begin{macrocode}
}
@@ -255,9 +284,41 @@
%
% %%%%%%%%%
%
-% This function starts scanning for the name of the package
+% This function checks if the |class| keyword is given.
+%
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \__pkgloader_load_scan_ext_:w {
+ \peek_charcode_remove_ignore_spaces:NTF c {% % % class
+ \__pkgloader_load_scan_ext_c:w
+ }{ % % % % % % % % % % % % % % % % % % % % % % % package details
+ \tl_set:Nn \l__pkgloader_load_extension_tl {.sty}
+ \tl_set:Nn \l__pkgloader_load_cmd_tl {\RequirePackage}
+ \__pkgloader_load_scan_pkg_:w
+ }
+}
+% \end{macrocode}
+%
+% %%%%%%%%%
+%
+% The |class| keyword indicates that this is a document
+% class loading rule, rather than a package loading rule.
+% We record this and then goes on to scan the details:
+%
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \__pkgloader_load_scan_ext_c:w lass {
+ \tl_set:Nn \l__pkgloader_load_extension_tl {.cls}
+ \tl_set:Nn \l__pkgloader_load_cmd_tl {\LoadClass}
+ \clist_put_right:Nn \l__pkgloader_load_succ_clist {pkgloader-cls-pkg.sty}
+ \__pkgloader_load_scan_pkg_:w
+}
+% \end{macrocode}
+%
+% %%%%%%%%%
+%
+% The following function starts scanning for the name of the package
% central to this rule, as well as the options and minimum
-% version proposed for it.
+% version proposed for it. It also checks if the |error|
+% keyword is given.
%
% \begin{macrocode}
\cs_new_protected_nopar:Npn \__pkgloader_load_scan_pkg_:w {
@@ -279,7 +340,7 @@
%
% \begin{macrocode}
\cs_new_protected_nopar:Npn \__pkgloader_load_scan_pkg_e:w rror {
- \tl_set:Nn \l__pkgloader_load_name_tl {pkgloader-error}
+ \tl_set:Nn \l__pkgloader_load_name_tl {pkgloader-error.sty}
\__pkgloader_load_scan_clause_:w
}
% \end{macrocode}
@@ -297,12 +358,16 @@
%
% %%%%%%%%%
%
-% This scans the package name, peeks ahead for a minimum
-% version, and otherwise goes on to scanning for clauses:
+% This scans the package name (and adds the proper extension),
+% peeks ahead for a minimum version, and otherwise goes on to
+% scanning for clauses:
%
% \begin{macrocode}
\cs_new_protected_nopar:Npn \__pkgloader_load_scan_pkg_:nw #1 {
\tl_set:Nn \l__pkgloader_load_name_tl {#1}
+ \tl_put_right:NV
+ \l__pkgloader_load_name_tl
+ \l__pkgloader_load_extension_tl
\peek_charcode_remove_ignore_spaces:NTF [ {% % % % package version
\__pkgloader_load_scan_version:nw
}{ % % % % % % % % % % % % % % % % % % % % % % % % clauses
@@ -324,7 +389,7 @@
%
% %%%%%%%%%
%
-% This is the starting- and return-point used to scan
+% This is the start- and return-point used to scan
% for (additional) |\Load| clauses:
%
% \begin{macrocode}
@@ -363,7 +428,9 @@
%
% %%%%%%%%%
%
-% This processes the ``|always|'' clause:
+% This processes the ``|always|'' clause, which loads this
+% package conditional on the ``|pkgloader-true|'' package being
+% loaded (which always is):
%
% \begin{macrocode}
\cs_new_protected_nopar:Npn \__pkgloader_load_scan_clause_al:w ways {
@@ -378,7 +445,9 @@
%
% \begin{macrocode}
\cs_new_protected_nopar:Npn \__pkgloader_load_scan_clause_af:w ter #1 {
- \clist_put_right:Nn \l__pkgloader_load_pred_clist {#1}
+ \clist_map_inline:nn {#1} {
+ \clist_put_right:Nn \l__pkgloader_load_pred_clist {##1.sty}
+ }
\__pkgloader_load_scan_clause_:w
}
% \end{macrocode}
@@ -400,7 +469,9 @@
%
% \begin{macrocode}
\cs_new_protected_nopar:Npn \__pkgloader_load_scan_clause_bef:w ore #1 {
- \clist_put_right:Nn \l__pkgloader_load_succ_clist {#1}
+ \clist_map_inline:nn {#1} {
+ \clist_put_right:Nn \l__pkgloader_load_succ_clist {##1.sty}
+ }
\__pkgloader_load_scan_clause_:w
}
% \end{macrocode}
@@ -413,7 +484,7 @@
% \begin{macrocode}
\cs_new_protected_nopar:Npn \__pkgloader_load_scan_clause_e:w arly {
\bool_set_true:N \l__pkgloader_early_late_used_bool
- \clist_put_right:Nn \l__pkgloader_load_succ_clist {pkgloader-early}
+ \clist_put_right:Nn \l__pkgloader_load_succ_clist {pkgloader-early.sty}
\__pkgloader_load_scan_clause_:w
}
% \end{macrocode}
@@ -448,9 +519,7 @@
%
% %%%%%%%%%
%
-% This processes the ``|always|'' clause, which loads this
-% package conditional on the ``|pkgloader-true|'' package being
-% loaded (which always is):
+% This processes the ``|if|'' clause with a manual condition:
%
% \begin{macrocode}
\cs_new_protected_nopar:Npn \__pkgloader_load_scan_clause_if_:nw #1 {
@@ -467,12 +536,12 @@
% \begin{macrocode}
\cs_new_protected_nopar:Npn \__pkgloader_load_scan_clause_l:w ate {
\bool_set_true:N \l__pkgloader_early_late_used_bool
- \clist_put_right:Nn \l__pkgloader_load_pred_clist {pkgloader-late}
+ \clist_put_right:Nn \l__pkgloader_load_pred_clist {pkgloader-late.sty}
\__pkgloader_load_scan_clause_:w
}
% \end{macrocode}
%
-% %%%%%%%%%
+% %%%%%%%%% %%%%%%%%% %%%%%%%%% %%%%%%%%% %%%%%%%%% %%%%%%%%%
%
% This function processes the collected data and registers it:
%
@@ -480,20 +549,6 @@
\cs_new_protected_nopar:Nn \__pkgloader_load_end: {
% \end{macrocode}
%
-% If this package should not specifically go early or late,
-% it goes inbetween the two:
-%
-% \begin{macrocode}
- \bool_if:NF \l__pkgloader_early_late_used_bool {
- \tl_if_eq:VnF \l__pkgloader_load_name_tl {pkgloader-early} {
- \tl_if_eq:VnF \l__pkgloader_load_name_tl {pkgloader-late} {
- \clist_put_right:Nn \l__pkgloader_load_pred_clist {pkgloader-early}
- \clist_put_right:Nn \l__pkgloader_load_succ_clist {pkgloader-late }
- }
- }
- }
-% \end{macrocode}
-%
% We remove the leading ``\texttt{\ \textbar\textbar\ }'' from the condition:
%
% \begin{macrocode}
@@ -508,7 +563,7 @@
% \end{macrocode}
%
% We now take the condition and compile it to a |\bool_if:|
-% kind of syntax. The user-syntax is preserved to use in
+% kind of syntax. The original syntax is preserved to use in
% error messages and such:
%
% \begin{macrocode}
@@ -516,12 +571,12 @@
\regex_replace_all:nnN
{ [^\&\|\(\)\!\s]+ }
{ (\c{graph_if_vertex_exist_p:Nn}
- \c{g__pkgloader_pkg_graph}\cB\{\0\cE\}) }
+ \c{g__pkgloader_pkg_graph}\cB\{\0\.sty\cE\}) }
\l__pkgloader_load_compd_cond_tl
% \end{macrocode}
%
% If no reason was given for this rule, it was obviously
-% still because of reasons:
+% `because of reasons':
%
% \begin{macrocode}
\tl_if_empty:NT \l__pkgloader_load_because_tl
@@ -532,7 +587,7 @@
% registered:
%
% \begin{macrocode}
- \__pkgloader_register_rule:VVVVVVVVn
+ \__pkgloader_register_rule:VVVVVVVVV
\l__pkgloader_load_name_tl
\l__pkgloader_load_options_tl
\l__pkgloader_load_version_tl
@@ -541,25 +596,16 @@
\l__pkgloader_load_pred_clist
\l__pkgloader_load_succ_clist
\l__pkgloader_load_because_tl
- \__pkgloader_RPkg:wnw % TODO: make configurable
+ \l__pkgloader_load_cmd_tl
% \end{macrocode}
% \uninteresting\begin{macrocode}
}
-% \end{macrocode}
-%
-% The scanning functions need the following variants:
-%
-% \begin{macrocode}
\cs_generate_variant:Nn \tl_if_eq:nnF {VnF}
\cs_generate_variant:Nn \graph_gput_vertex:Nn {NV}
\cs_generate_variant:Nn \graph_gput_edge:Nnn {NnV,NVn}
\cs_generate_variant:Nn \seq_gput_right:Nn {NV}
-\cs_generate_variant:Nn \__pkgloader_register_rule:nnnnnnnnn {VVVVVVVVn}
-% \end{macrocode}
-%
-% And they need the following local variables:
-%
-% \begin{macrocode}
+\cs_generate_variant:Nn \__pkgloader_register_rule:nnnnnnnnn {VVVVVVVVV}
+\tl_new:N \l__pkgloader_load_extension_tl
\tl_new:N \l__pkgloader_load_options_tl
\tl_new:N \l__pkgloader_load_name_tl
\tl_new:N \l__pkgloader_load_version_tl
@@ -567,8 +613,19 @@
\clist_new:N \l__pkgloader_load_succ_clist
\tl_new:N \l__pkgloader_load_cond_tl
\tl_new:N \l__pkgloader_load_because_tl
+\tl_new:N \l__pkgloader_load_cmd_tl
\bool_new:N \l__pkgloader_early_late_used_bool
% \end{macrocode}
+%
+% %%%%%%%%% %%%%%%%%% %%%%%%%%% %%%%%%%%% %%%%%%%%% %%%%%%%%%
+%
+% And here's the instruction to clean up the
+% |\Load| command-name at the end:
+%
+% \begin{macrocode}
+\tl_put_right:Nn \__pkgloader_cleanup_commands:
+ { \cs_undefine:N \Load }
+% \end{macrocode}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -672,28 +729,49 @@
}
% \end{macrocode}
%
-% Finally, we put the applicable proposed orderings into the
+% We put the applicable proposed orderings into the
% graph of selected packages:
%
% \begin{macrocode}
\graph_gput_edges_from:NN \g__pkgloader_pkg_graph \l__pkgloader_order_graph
% \end{macrocode}
-% \uninteresting\begin{macrocode}
-}
-% \end{macrocode}
%
-% This function needs the following variations:
+% If there is a cycle in the derived package loading order: ERROR
%
% \begin{macrocode}
+ \graph_if_cyclic:NT \g__pkgloader_pkg_graph
+ { \msg_fatal:nn {pkgloader} {cyclic-order} }
+% \end{macrocode}
+%
+% Finally, we apply some default orderings where needed:
+% \begin{itemize}
+% \item If a package should not specifically
+% go early or late, it goes inbetween; and
+% \item if a package should not specifically
+% go before a class, it goes after.
+% \end{itemize}
+%
+% \begin{macrocode}
+ \graph_map_vertices_inline:Nn \g__pkgloader_pkg_graph {
+ \seq_if_in:NnF \g__pkgloader_system_packages_seq {##1} {
+ \graph_acyclic_if_path_exist:NnnF \g__pkgloader_pkg_graph
+ {##1} {pkgloader-early.sty} {
+ \graph_acyclic_if_path_exist:NnnF \g__pkgloader_pkg_graph
+ {pkgloader-late.sty} {##1} {
+ \graph_put_edge:Nnn \g__pkgloader_pkg_graph {pkgloader-early.sty} {##1}
+ \graph_put_edge:Nnn \g__pkgloader_pkg_graph {##1} {pkgloader-late.sty}
+ } }
+ \graph_acyclic_if_path_exist:NnnF \g__pkgloader_pkg_graph
+ {##1} {pkgloader-cls-pkg.sty} {
+ \graph_put_edge:Nnn \g__pkgloader_pkg_graph {pkgloader-cls-pkg.sty} {##1}
+ } } }
+% \end{macrocode}
+% \uninteresting\begin{macrocode}
+}
\cs_generate_variant:Nn \int_step_inline:nnnn {nncn}
\cs_generate_variant:Nn \bool_if:nT {vT}
\cs_generate_variant:Nn \withargs:nnn {vvn}
\cs_generate_variant:Nn \graph_gput_vertex:Nnn {Nnf}
-% \end{macrocode}
-%
-% And it needs the following local variables:
-%
-% \begin{macrocode}
\graph_new:N \l__pkgloader_order_graph
\tl_new:N \l__pkgloader_used_configs_tl
\bool_new:N \l__pkgloader_selection_changed_bool
@@ -705,8 +783,9 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% Now follows the user command to consolidate all package loading
-% requests and do the `right thing' (tm).
+% Now follows the user command to consolidate all package
+% loading requests and do the `right thing' (tm). Invoking
+% this command ends the work of |pkgloader|.
%
% \begin{macrocode}
\NewDocumentCommand {\LoadPackagesNow} {} {
@@ -718,18 +797,11 @@
\__pkgloader_select_packages:
% \end{macrocode}
%
-% We then restore |\usepackage|, |\RequirePackage| and
-% |\RequirePackageWithOptions| to their normal definitions.
+% Now to clean up after |pkgloader|, restoring
+% and removing various command-names.
%
% \begin{macrocode}
- \__pkgloader_restore_commands:
-% \end{macrocode}
-%
-% Now, if there is a cycle in the derived package loading order: ERROR
-%
-% \begin{macrocode}
- \graph_if_cyclic:NT \g__pkgloader_pkg_graph
- { \msg_fatal:nn {pkgloader} {cyclic-order} }
+ \__pkgloader_cleanup_commands:
% \end{macrocode}
%
% Then, for all used packages, in topological order\ldots
@@ -741,16 +813,16 @@
% \ldots load that package. Though note that this code is still quite
% incomplete, because it loads the first viable configuration. It should:
% \begin{enumerate}
-% \item use |\RequirePackageWithOptions| if necessary,
-% |\RequirePackage| otherwise,
+% \item use the |WithOptions| version of the command
+% if necessary,
% \item allow custom merging schemes for options, and
% \item use the latest required version.
% \end{enumerate}
% \begin{macrocode}
\withargs:xn { \clist_item:nn{##2}{1} } {
- \withargs:vvnvn {g__pkgloader_command_(##1)_(####1)_tl}
+ \withargs:vvfvn {g__pkgloader_command_(##1)_(####1)_tl}
{g__pkgloader_options_(##1)_(####1)_tl}
- {##1}
+ {\__pkgloader_strip_extension:f{##1}}
{g__pkgloader_version_(##1)_(####1)_tl} {
\IfValueTF {########2}
{ \IfValueTF {########4}
@@ -765,13 +837,51 @@
}
}
}
+\cs_generate_variant:Nn \withargs:nn {xn}
+\cs_generate_variant:Nn \withargs:nnnnn {vvfvn}
% \end{macrocode}
%
-% The above function needs the following function variations:
+% And it needs the following auxiliary function to strip
+% filenames from their four character extension:
%
% \begin{macrocode}
-\cs_generate_variant:Nn \withargs:nn {xn}
-\cs_generate_variant:Nn \withargs:nnnnn {vvnvn}
+\cs_new:Nn \__pkgloader_strip_extension:f {
+ \tl_reverse:f{
+ \tl_tail:f{\tl_tail:f{\tl_tail:f{\tl_tail:f{
+ \tl_reverse:n{#1}
+ }}}}
+ }
+}
+\cs_generate_variant:Nn \tl_reverse:n {f}
+% \end{macrocode}
+%
+% It's a bit clunky. Is there a substring function
+% in |expl3| we could use that I don't know about?
+%
+% And here's the instruction to clean up the
+% |\LoadPackagesNow| command-name at the end:
+%
+% \begin{macrocode}
+\tl_put_right:Nn \__pkgloader_cleanup_commands:
+ { \cs_undefine:N \LoadPackagesNow }
+% \end{macrocode}
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%
+%
+% \begin{macrocode}
+\cs_gset_eq:NN \__pkgloader_begin_env:n \begin
+\RenewDocumentCommand {\begin} {m} {
+ \tl_if_eq:nnT {#1} {document} {\LoadPackagesNow}
+ \__pkgloader_begin_env:n {#1}
+}
+\tl_put_right:Nn \__pkgloader_cleanup_commands:
+ { \cs_gset_eq:NN \begin \__pkgloader_begin_env:n }
% \end{macrocode}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -785,19 +895,34 @@
% with rules, possibly using the |always| clause.
%
% \begin{macrocode}
-\graph_gput_vertex:Nn \g__pkgloader_pkg_graph {pkgloader-true}
+\graph_gput_vertex:Nn \g__pkgloader_pkg_graph {pkgloader-true.sty}
+% \end{macrocode}
+%
+% We keep a list of all pkgloader dummy packages:
+%
+% \begin{macrocode}
+\seq_new:N \g__pkgloader_system_packages_seq
+\cs_generate_variant:Nn \seq_gset_from_clist:Nn {Nx}
+\seq_gset_from_clist:Nx \g__pkgloader_system_packages_seq
+ {\tl_to_str:n
+ {pkgloader-true.sty,
+ pkgloader-false.sty,
+ pkgloader-early.sty,
+ pkgloader-late.sty,
+ pkgloader-cls-pkg.sty}}
% \end{macrocode}
%
% We then register the core logical rules of |pkgloader|,
-% regarding such basics as |pkgmanager-false|,
-% |pkgloader-error|, |pkgloader-early| and |pkgloader-late|.
+% regarding fundamental package `stubs' like |pkgloader-false|,
+% |pkgloader-error|, |pkgloader-early|, and so on.
%
% \begin{macrocode}
\withargs:nn {of~the~mandatory~core~rules~of~pkgloader} {
\Load error if {pkgloader-false} because {#1}
- \Load {pkgloader-true} always because {#1}
- \Load {pkgloader-early} always because {#1}
- \Load {pkgloader-late} always because {#1}
+ \Load {pkgloader-true} always because {#1}
+ \Load {pkgloader-early} always because {#1}
+ \Load {pkgloader-late} always because {#1}
+ \Load {pkgloader-cls-pkg} always because {#1}
\Load {pkgloader-early} before {pkgloader-late} because {#1}
}
% \end{macrocode}
@@ -885,7 +1010,7 @@
\\\\\ \ \ \ #1\\\\
This~is~an~error~because~#2. }
{ A~pkgloader~rule~was~requested~that~prohibits~the~logical~
- combination~above~for~the~specified~reason.~It~is~probably~
+ combination\\above~for~the~specified~reason.~It~is~probably~
a~good~reason. }
% \end{macrocode}
%