summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/expl3/l3names.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-06-09 23:31:15 +0000
committerKarl Berry <karl@freefriends.org>2009-06-09 23:31:15 +0000
commit215b9a864d5829070bdc66ba736986eb72e5143e (patch)
treefe0882c81fc4ec945cee4b512f72eaa21ea5f791 /Master/texmf-dist/source/latex/expl3/l3names.dtx
parentdf90ec06321940c2f066b05e12f1b5ab099105da (diff)
expl3 1407 (9jun09)
git-svn-id: svn://tug.org/texlive/trunk@13686 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/expl3/l3names.dtx')
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3names.dtx705
1 files changed, 363 insertions, 342 deletions
diff --git a/Master/texmf-dist/source/latex/expl3/l3names.dtx b/Master/texmf-dist/source/latex/expl3/l3names.dtx
index 3bd4dbf2612..26148a4e7a2 100644
--- a/Master/texmf-dist/source/latex/expl3/l3names.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3names.dtx
@@ -1,5 +1,5 @@
% \iffalse
-%% File: l3names.dtx Copyright (C) 1990-2006 LaTeX3 project
+%% File: l3names.dtx Copyright (C) 1990-2006,2009 LaTeX3 project
%%
%% It may be distributed and/or modified under the conditions of the
%% LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -17,7 +17,7 @@
%%
%% The development version of the bundle can be found at
%%
-%% http://www.latex-project.org/cgi-bin/cvsweb.cgi/
+%% http://www.latex-project.org/svnroot/experimental/trunk/
%%
%% for those people who are interested.
%%
@@ -42,7 +42,18 @@
%</initex>
%<package>\begingroup
%<*initex|package>
-\def\GetIdInfo$#1 #2.#3 #4 #5 #6 #7${%
+\def\GetIdInfo$#1${%
+ \begingroup
+ \def\GetIdInfoString{#1}%
+ \def\IdInfoStringUnexp{Id}%
+ \ifx \GetIdInfoString \IdInfoStringUnexp
+ \def\next{\endgroup\GetIdInfoMissing}
+ \else
+ \def\next{\endgroup\GetIdInfoFull$#1$}
+ \fi
+ \next
+}
+\def\GetIdInfoFull$#1 #2.#3 #4 #5 #6 #7${%
\GetIdInfoAux #5\relax{#2}#5\relax{#4}%
}
\def\GetIdInfoAux #1#2#3#4#5#6\relax{%
@@ -60,6 +71,12 @@
\def\GetIdInfoAuxSVN #1#2-#3-#4\relax#5#6{%
\immediate\write-1{#1; #2/#3/#4 v#5 #6}%
}
+\def\GetIdInfoMissing#1{%
+ \gdef\fileversion{000}%
+ \gdef\filedate{0000/00/00}%
+ \gdef\filedescription{#1}%
+ \immediate\write-1{[Loading unknown package: #1]}%
+}
%</initex>
%<*package>
\def\GetIdInfoAuxCVS #1#2\relax#3#4{%
@@ -74,12 +91,18 @@
\gdef\filedescription{#6}%
\ProvidesPackage{#1}[#2/#3/#4 v#5 #6]
}
+\def\GetIdInfoMissing#1{%
+ \gdef\fileversion{000}%
+ \gdef\filedate{0000/00/00}%
+ \gdef\filedescription{#1}%
+ \ProvidesPackage{[unknown package]}[0000/00/00 v0.0 #1]
+}
%</package>
%<*driver>
\RequirePackage{l3names}
%</driver>
%\fi
-\GetIdInfo$Id: l3names.dtx 621 2007-09-01 20:14:19Z morten $
+\GetIdInfo$Id: l3names.dtx 1362 2009-05-28 20:19:21Z joseph $
{L3 Experimental Naming Scheme for TeX Primitives}
%
%
@@ -90,7 +113,7 @@
\ProvidesFile{l3names.dtx}
[\filedate\space v\fileversion\space\filedescription]
%\iffalse
-\documentclass{l3doc}
+\documentclass[full]{l3doc}
\begin{document}
\DocInput{l3names.dtx}
\end{document}
@@ -105,215 +128,30 @@
% \date{\filedate}
% \maketitle
%
-% \changes{v2.0a}{1997/08/04}
-% {new consistent tex module name for \TeX\ primitives}
-%
-% \begin{abstract}
-% This package sets up an experimental naming scheme for
-% \LaTeX\ commands. It allows the \LaTeX\ programmer to systematically
-% name functions and variables, and specify the argument types of
-% functions.
-%
-% The \TeX\ primitives are all given a new name according to these
-% conventions.
-%
-% \begin{bfseries}
-% Warning: This package, and all packages using it should be regarded as
-% \emph{expermiental}!
-%
-% The names of these packages, and the names and syntax of any commands
-% defined in them might change at any time.
-%
-% These conventions are being distributed in this form to encourage
-% discussion and experimentation. It is \emph{not} intentended that
-% these packages be used in `real' documents at this stage.
-% \end{bfseries}
-% \end{abstract}
-%
-%
-% \section{Conventions}
-%
-% This section gives an overview of the syntax for \LaTeX\ commands
-% that is set up for use in these `experimental' pacages.
-%
-% Commands in \LaTeX3 are either functions or parameters. All
-% primitive commands of \TeX{} have private names.
-%
-% \subsection{Functions}
-%
-% Functions have the following general syntax:
-% \begin{quote}
-% |\|\m{module}|_|\m{description}|:|\m{arg-spec}
-% \end{quote}
-% where \m{module} is one of the (to be) chosen module names and
-% \m{description} is a verbal description of the functionality.
-% \m{arg-spec} finally describes the type of arguments that the
-% function takes and is left empty if it is a function without
-% arguments.
-%
-% All three parts consists of letters only \m{description} is allowed
-% to take further |_| characters to separate words is necessary.
-%
-% Currently there exists some functions which don't have a proper
-% \m{module} name.
-%
-% As a semi-formalized concept the letter |g| is sometimes used to
-% prefix the \m{module} name and certain parts of the \m{description}
-% to mark the function as ``globally acting''.
-%
-% The \m{arg-spec} currently supports the following types of
-% arguments:
-% \begin{description}
-%
-% \item[n] Unexpanded token (or token-list if in braces) braces.
-%
-% \item[o] One time expanded token or token-list. In the latter case,
-% effectively only the first token in the list gets expanded. Since
-% the expansion might result in more than one token, the result is
-% surrounded for further processing with braces.
-%
-% \item[x] Fully expanded token or token-list. Like |o| but the
-% argument is expanded using |\def:Npx| before it is passed on.
-%
-% \item[c] A character string or a token-list that expands to
-% characters of catcode 11 or 12. This string (after expansion) is
-% used to construct a command name that is eventually passed on.
-%
-% \item[N,O,X] Like |n|, |o|, |x| but the argument must be a single
-% token without any braces around it.
-%
-% \item[w] One or more arguments with ``weird'' syntax that one has
-% to know by heart or better leave it alone.
-%
-% \item[p] Denotes parameter text specification part, e.g.\^^M
-% |#1#2\q_stop#3|.
-%
-% \item[T,F] denotes the ``true'' or the ``false'' case in a
-% functional predicate.
-%
-% \end{description}
-%
-% Especially for the new names of \TeX{} primitives there are is one
-% more character to denote arguments. It implies that these
-% functions should not be used outside this bootstrapping file.
-% \begin{description}
-%
-% \item[D] Zero or more arguments with ``weird'' syntax. Uppercase
-% ``D'' means (DON'T USE IT), i.e.,
-% that this is a primitive \TeX{} command that should
-% not show up in code except in the very basic functions of \LaTeX3
-% that provide a more sensible interface.
-%
-% \end{description}
-%
-% One could perhaps envisage an extended system which allocated
-% letters to denote the various primitive argument types available in
-% \TeX, however it seems that this just complicates the system
-% without adding any real benefit, as these primitives would never be
-% used in production code, as higher level packages should offer a
-% better interface. Thus the following letters, although they were
-% considered have not been used. ``D'' is used in most cases in
-% preference.
-% \begin{description}
-% \item[i] Denotes an integer in \TeX{} notation (which might be a
-% register or \dots).
-%
-% \item[d] Denotes a dimension in \TeX{} notation.
-%
-% \item[g] Denotes a glue in \TeX{} notation.
-%
-% \item[m] Denotes an muglue or mukern in \TeX{} notation.
-%
-% \item[b] Denotes a box specification in \TeX{} notation (again
-% something pretty arbitrary).
-%
-% \item[r] Denotes a rule specification in \TeX{} notation.
-%
-% \end{description}
-%
-% Some of the primitive functions below are flagged ``D'' even if
-% they actually might be useful in average code. So certainly there
-% are some adjustments necessary. It all depends whether or not we
-% provide some safer interface or leave them alone.
-%
-% \subsection{Parameters}
+% \begin{documentation}
%
-% Parameter names have the following general syntax:
-% \begin{quote}
-% |\|\m{access}|_|\m{module}|_|\m{description}|_|\m{type}
-% \end{quote}
+% \section{Setting up the \LaTeX3 programming language}
%
-% \m{module} and \m{description} is as above. \m{type} should denote
-% the type of parameter if this helps in using it. The currently used
-% types are:
-% \begin{description}
+% This module is at the core of the \LaTeX3 programming language. It
+% performs the following tasks:
+% \begin{itemize}
+% \item defines new names for all \TeX{} primitives;
+% \item defines catcode regimes for programming;
+% \item provides settings for when the code is used in a format;
+% \item provides tools for when the code is used as a package within a
+% \LaTeXe\ context.
+% \end{itemize}
%
-% \item[int] Integer valued.
+% \section{Using the modules}
%
-% \item[factor] Another integer value type. Used for things where the
-% parameter is used as a factor for something else.
+% The modules documented in \file{source3} are designed to be used on top of
+% \LaTeXe\ and are loaded all as one with the usual "\usepackage{expl3}" or
+% "\RequirePackage{expl3}" instructions. These modules will also form the
+% basis of the \LaTeX3 format, but work in this area is incomplete and not
+% included in this documentation.
%
-% \item[status] The sort of boolean stuff \TeX{} provides. Essentially
-% an integer with the meaning |0| = `off' and other values may or may
-% not have sensible meanings.
-%
-% \item[pen] Another integer describing penalties.
-%
-% \item[dem] The demerits.
-%
-% \item[dim] A dimension.
-%
-% \item[skip] A glue value.
-%
-% \item[toks] A toks register (sort of).
-%
-% \item[char] An integer denoting a character.
-%
-% \item[muskip] A math unit.
-%
-% \end{description}
-%
-% \m{access} describes how the parameter can be accessed. The
-% following characters are possible:
-% \begin{description}
-%
-% \item[c] A constant. Should not be set in the code except with
-% special functions to define the value for the whole processing.
-%
-% \item[C] A constant according to \TeX's rules. Can not be changed at
-% all.
-%
-% \item[l] A local variable which therefore should not be changed
-% globally.
-%
-% \item[L] A local variable that is usually set (and/or reset) by
-% \TeX{} itself.
-%
-% \item[g] A global variable.
-%
-% \item[G] A global variable that is usually set (and/or reset by \TeX.
-%
-% \item[R] A variable that is set (and changed) by \TeX{} and can not
-% be changed by in the code (read-only).
-%
-% \end{description}
-%
-%
-%
-% \section{Modules}
-%
-% Nearly all operations of \LaTeX3 are carried out by calling control
-% sequences. For better programming concepts many types of functions are
-% identified and gathered in modules. Functions in such modules starts
-% with special prefixes, for example "\tlp_" is the prefix for functions
-% dealing with token list pointers.
-%
-% \subsection{Using the modules}
-%
-% Most of the modules can be used on top of \LaTeX\ and are loaded
-% with the usual "\usepackage" or "\RequirePackage" instructions. As
-% the packages use a coding syntax different from standard \LaTeX\ it
-% provides a few functions for setting it up.
+% As the modules use a coding syntax different from standard
+% \LaTeX\ it provides a few functions for setting it up.
%
% \begin{function}{
% \ExplSyntaxOn |
@@ -323,18 +161,28 @@
% "\ExplSyntaxOn" <code> "\ExplSyntaxOff"
% \end{syntax}
% Issues a catcode regime where spaces are ignored and colon and
-% underscore are letters.
+% underscore are letters. A space character may by input with "~" instead.
+% \end{function}
+%
+% \begin{function}{
+% \ExplSyntaxNamesOn |
+% \ExplSyntaxNamesOff
+% }
+% \begin{syntax}
+% "\ExplSyntaxNamesOn" <code> "\ExplSyntaxNamesOff"
+% \end{syntax}
+% Issues a catcode regime where colon and underscore are letters, but
+% spaces remain the same.
% \end{function}
%
% \begin{function}{
-% l3names |
% \ProvidesExplPackage |
% \ProvidesExplClass
% }
% \begin{syntax}
-% "\RequirePackage{l3names}" \\
-% "\ProvidesExplPackage" "{"<package>"}"
-% "{"<date>"}" "{"<version>"}" "{"<description>"}"
+% "\RequirePackage{expl3}" \\
+% "\ProvidesExplPackage" \Arg{package}
+% \Arg{date} \Arg{version} \Arg{description}
% \end{syntax}
% The package "l3names" (this module) provides
% "\ProvidesExplPackage" which is a wrapper for "\ProvidesPackage"
@@ -351,13 +199,14 @@
% \filedate |
% \fileversion |
% \filetimestamp |
-% \fileauthor
+% \fileauthor |
+% \filedescription
% }
% \begin{syntax}
% "\RequirePackage{l3names}" \\
-% "\GetIdInfo" "$Id:" <cvs or svn info field> "$" "{"<description>"}"
+% "\GetIdInfo" "$Id:" <cvs or svn info field> "$" \Arg{description}
% \end{syntax}
-% Extracts all information from a cvs or svn field. Spaces are not
+% Extracts all information from a CVS or SVN field. Spaces are not
% ignored in these fields. The information pieces are stored in
% separate control sequences with "\filename" for the part of the
% file name leading up to the period, "\filenameext" for the
@@ -377,33 +226,79 @@
% \end{verbatim}
%
%
+% \end{documentation}
%
+% \begin{implementation}
%
-% \StopEventually{}
-%
-% \section{Starters}
+% \section{\pkg{l3names} implementation}
%
% This is the base part of \LaTeX3 defining things like |catcode|s
-% and redefining the \TeX{} primitives.
+% and redefining the \TeX{} primitives, as well as setting up the code
+% to load \pkg{expl3} modules in \LaTeXe.
+%
+% \subsection{Internal functions}
%
-% We start by setting up |\catcode|s that we need to define new
-% commands. These are the ones for begin-group and end-group
-% characters.\footnote{Well not needed while this file is running
-% as a package on top of \LaTeXe, so omitted from the package code}
+% \begin{function}{ \ExplSyntaxStatus | \ExplSyntaxPopStack | \ExplSyntaxStack }
+% Functions used to track the state of the catcode regime.
+% \end{function}
+%
+% \begin{function}{\@pushfilename | \@popfilename}
+% Re-definitions of \LaTeX's file-loading functions to support "\ExplSyntax".
+% \end{function}
+%
+% \subsection{Package loading}
+%
+% Before anything else, check that we're using \eTeX;
+% no point continuing otherwise.
% \begin{macrocode}
-%<*initex>
-\catcode`\{=1 % left brace is begin-group character
-\catcode`\}=2 % right brace is end-group character
-\catcode`\#=6 % hash mark is macro parameter character
-\catcode`\^=7 %
-\catcode`\^^I=10 % ascii tab is a blank space
-%</initex>
+%<*initex|package>
+\begingroup
+\def\firstoftwo#1#2{#1}
+\def\secondoftwo#1#2{#2}
+\def\etexmissingerror{Not running under e-TeX}
+\def\etexmissinghelp{%
+ This package requires e-TeX.^^J%
+ Try compiling the document with `elatex' instead of `latex'.^^J%
+ When using pdfTeX, try `pdfelatex' instead of `pdflatex'%
+}%
+\expandafter\ifx\csname eTeXversion\endcsname\relax
+ \expandafter\secondoftwo\else\expandafter\firstoftwo\fi
+ {\endgroup}{%
+%<initex> \expandafter\errhelp\expandafter{\etexmissinghelp}%
+%<initex> \expandafter\errmessage\expandafter{\etexmissingerror}%
+%<package> \PackageError{l3names}{\etexmissingerror}{\etexmissinghelp}%
+ \endgroup
+ \endinput
+ }
+%</initex|package>
% \end{macrocode}
+%
+% \subsection{Catcode assignments}
+%
+% Catcodes for begingroup, endgroup, macro parameter, superscript, and tab,
+% are all assigned before the start of the documented code. (See the beginning
+% of \file{l3names.dtx}.)
+%
% Reason for |\endlinechar=32| is that a line ending with a backslash
% will be interpreted as the token \verb*|\ | which seems most natural
% and since spaces are ignored it works as we intend elsewhere.
+%
+% Before we do this we must however record the settings for the
+% catcode regime as it was when we start changing it.
% \begin{macrocode}
%<*initex|package>
+\edef\ExplSyntaxOff{
+ \unexpanded{\ifodd \ExplSyntaxStatus\relax
+ \def\ExplSyntaxStatus{0}
+ }
+ \catcode 126=\the \catcode 126 \relax
+ \catcode 32=\the \catcode 32 \relax
+ \catcode 9=\the \catcode 9 \relax
+ \endlinechar =\the \endlinechar \relax
+ \catcode 95=\the \catcode 95 \relax
+ \catcode 58=\the \catcode 58 \relax
+ \noexpand\fi
+}
\catcode126=10\relax % tilde is a space char.
\catcode32=9\relax % space is ignored
\catcode9=9\relax % tab also ignored
@@ -412,8 +307,7 @@
\catcode58=11\relax % colon letter
% \end{macrocode}
%
-%
-% \section{Setting up primitive names}
+% \subsection{Setting up primitive names}
%
% Here is the function that renames \TeX{}'s primitives.
%
@@ -477,7 +371,7 @@
}
% \end{macrocode}
%
-% \subsection{Assignments}
+% \subsection{Reassignment of primitives}
%
% In the current incarnation of this package, all \TeX\ primitives
% are given a new name of the form |\tex_|\emph{oldname}|:D|.
@@ -819,7 +713,7 @@
%
%
%
-% Since \LaTeX3 will require at least the \eTeX{} extensions,
+% Since \LaTeX3 requires at least the \eTeX{} extensions,
% we also rename the additional primitives. These are all
% given the prefix |\etex_|.
% \begin{macrocode}
@@ -892,8 +786,7 @@
% \end{macrocode}
%
%
-% All major distributions\footnote{At the time of writing MiK\TeX\
-% does not but I have a gut feeling that will change.} use
+% All major distributions use
% pdf\eTeX{} as engine so we add these names as well. Since the
% pdf\TeX{} team has been very good at prefixing most primitives
% with |pdf| (so far only five do not start with |pdf|) we do not
@@ -1003,14 +896,29 @@
\name_primitive:NN \pdfnoligatures \pdf_noligatures:D
% \end{macrocode}
%
-% What about Omega and Aleph? The status of both are unclear but let's
-% start by adding a single primitive which we can use for testing if
-% we have one of these engines.
+% We're ignoring XeTeX and LuaTeX right
+% now except for a check whether they're in use:
+% \begin{macrocode}
+\name_primitive:NN \XeTeXversion \xetex_version:D
+\name_primitive:NN \directlua \luatex_directlua:D
+% \end{macrocode}
+%
+% XeTeX adds \cs{strcmp} to the set of primitives, with the same
+% implementation as \cs{pdfstrcmp} but a different name. To avoid
+% having to worry about this later, the same internal name is used.
% \begin{macrocode}
-\name_primitive:NN \textdir \aleph_textdir:D
+\etex_ifdefined:D \strcmp
+ \etex_ifdefined:D \xetex_version:D
+ \name_primitive:NN \strcmp \pdf_strcmp:D
+ \tex_fi:D
+\tex_fi:D
% \end{macrocode}
-% \begin{macro}{\CodeStart}
-% \begin{macro}{\CodeStop}
+%
+% \subsection{\pkg{expl3} code switches}
+%
+% \begin{macro}{\ExplSyntaxOn}
+% \begin{macro}{\ExplSyntaxOff}
+% \begin{macro}{\ExplSyntaxStatus}
% Here we define functions that are used to turn on and off the
% special conventions used in the kernel of \LaTeX3.
%
@@ -1019,48 +927,63 @@
% to a space instead. When space characters are needed in \LaTeX3
% code the |~| character will be used for that purpose.
%
+% Specification of the desired behavior:
+% \begin{itemize}
+% \item ExplSyntax can be either On or Off.
+% \item The On switch is \meta{null} if ExplSyntax is on.
+% \item The Off switch is \meta{null} if ExplSyntax is off.
+% \item If the On switch is issued and not \meta{null}, it records
+% the current catcode scheme just prior to it being issued.
+% \item An Off switch restores the catcode scheme to what it was just
+% prior to the previous On switch.
+% \end{itemize}
+%
% \begin{macrocode}
\tex_def:D\ExplSyntaxOn{
- \tex_def:D\ExplSyntaxStatus{00}
- \tex_catcode:D 126=10 \tex_relax:D % tilde is a space char.
- \tex_catcode:D 32=9 \tex_relax:D % space is ignored
- \tex_catcode:D 9=9 \tex_relax:D % tab also ignored
- \tex_endlinechar:D =32 \tex_relax:D % endline is space
- \tex_catcode:D 95=11 \tex_relax:D % underscore letter
- \tex_catcode:D 58=11 \tex_relax:D % colon letter
-}
-% \end{macrocode}
-%
-% \begin{macrocode}
-\tex_def:D\ExplSyntaxOff{
- \tex_def:D\ExplSyntaxStatus{01}
- \tex_catcode:D 126=13 \tex_relax:D
- \tex_catcode:D 32=10 \tex_relax:D
- \tex_catcode:D 9=10 \tex_relax:D
- \tex_endlinechar:D =13 \tex_relax:D
- \tex_catcode:D 95=8 \tex_relax:D
- \tex_catcode:D 58=12 \tex_relax:D
+ \tex_ifodd:D \ExplSyntaxStatus \tex_relax:D
+ \tex_else:D
+ \tex_edef:D\ExplSyntaxOff{
+ \etex_unexpanded:D{
+ \tex_ifodd:D \ExplSyntaxStatus \tex_relax:D
+ \tex_def:D \ExplSyntaxStatus{0}
+ }
+ \tex_catcode:D 126=\tex_the:D \tex_catcode:D 126 \tex_relax:D
+ \tex_catcode:D 32=\tex_the:D \tex_catcode:D 32 \tex_relax:D
+ \tex_catcode:D 9=\tex_the:D \tex_catcode:D 9 \tex_relax:D
+ \tex_endlinechar:D =\tex_the:D \tex_endlinechar:D \tex_relax:D
+ \tex_catcode:D 95=\tex_the:D \tex_catcode:D 95 \tex_relax:D
+ \tex_catcode:D 58=\tex_the:D \tex_catcode:D 58 \tex_relax:D
+ \tex_noexpand:D \tex_fi:D
+ }
+ \tex_def:D\ExplSyntaxStatus{1}
+ \tex_catcode:D 126=10 \tex_relax:D % tilde is a space char.
+ \tex_catcode:D 32=9 \tex_relax:D % space is ignored
+ \tex_catcode:D 9=9 \tex_relax:D % tab also ignored
+ \tex_endlinechar:D =32 \tex_relax:D % endline is space
+ \tex_catcode:D 95=11 \tex_relax:D % underscore letter
+ \tex_catcode:D 58=11 \tex_relax:D % colon letter
+ \tex_fi:D
}
% \end{macrocode}
-% Temporary while names change.
+% At this point we better set the status.
% \begin{macrocode}
-\tex_let:D \CodeStart \ExplSyntaxOn
-\tex_let:D \CodeStop \ExplSyntaxOff
+\tex_def:D\ExplSyntaxStatus{1}
% \end{macrocode}
% \end{macro}
% \end{macro}
+% \end{macro}
%
-% \begin{macro}{\NamesStart}
-% \begin{macro}{\NamesStop}
+% \begin{macro}{\ExplSyntaxNamesOn}
+% \begin{macro}{\ExplSyntaxNamesOff}
% Sometimes we need to be able to use names from the kernel of
% \LaTeX3 without adhering it's conventions according to space
% characters. These macros provide the necessary settings.
% \begin{macrocode}
-\tex_def:D \NamesStart{
+\tex_def:D \ExplSyntaxNamesOn{
\tex_catcode:D `\_=11\tex_relax:D
\tex_catcode:D `\:=11\tex_relax:D
}
-\tex_def:D \NamesStop{
+\tex_def:D \ExplSyntaxNamesOff{
\tex_catcode:D `\_=8\tex_relax:D
\tex_catcode:D `\:=12\tex_relax:D
}
@@ -1068,11 +991,21 @@
% \end{macro}
% \end{macro}
%
+% \subsection{Package loading}
+%
+%
% \begin{macro}{\GetIdInfo}
-% \begin{macro}{\GetIdInfoAuxi:w}
-% \begin{macro}{\GetIdInfoAuxii:w}
-% \begin{macro}{\GetIdInfoAuxCVS:w}
-% \begin{macro}{\GetIdInfoAuxSVN:w}
+% \begin{macro}{ \filedescription ,
+% \filename ,
+% \fileversion ,
+% \fileauthor ,
+% \filedate ,
+% \filenameext ,
+% \filetimestamp }
+% \begin{macro}[aux]{\GetIdInfoAuxi:w}
+% \begin{macro}[aux]{\GetIdInfoAuxii:w}
+% \begin{macro}[aux]{\GetIdInfoAuxCVS:w}
+% \begin{macro}[aux]{\GetIdInfoAuxSVN:w}
% Extract all information from a cvs or svn field. The
% formats are slightly different but at least the information is in
% the same positions so we check in the date format so see if it
@@ -1083,8 +1016,33 @@
\tex_def:D\GetIdInfo{
\tex_begingroup:D
\tex_catcode:D 32=10 \tex_relax:D % needed? Probably for now.
- \GetIdInfoAuxi:w
+ \GetIdInfoMaybeMissing:w
}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\tex_def:D\GetIdInfoMaybeMissing:w$#1$#2{
+ \tex_def:D \l_tmpa_tl {#1}
+ \tex_def:D \l_tmpb_tl {Id}
+ \tex_ifx:D \l_tmpa_tl \l_tmpb_tl
+ \tex_def:D \l_tmpa_tl {
+ \tex_endgroup:D
+ \tex_def:D\filedescription{#2}
+ \tex_def:D\filename {[unknown~name]}
+ \tex_def:D\fileversion {000}
+ \tex_def:D\fileauthor {[unknown~author]}
+ \tex_def:D\filedate {0000/00/00}
+ \tex_def:D\filenameext {[unknown~ext]}
+ \tex_def:D\filetimestamp {[unknown~timestamp]}
+ }
+ \tex_else:D
+ \tex_def:D \l_tmpa_tl {\GetIdInfoAuxi:w$#1${#2}}
+ \tex_fi:D
+ \l_tmpa_tl
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
\tex_def:D\GetIdInfoAuxi:w$#1~#2.#3~#4~#5~#6~#7~#8$#9{
\tex_endgroup:D
\tex_def:D\filename{#2}
@@ -1094,6 +1052,9 @@
\GetIdInfoAuxii:w #5\tex_relax:D
#3\tex_relax:D#5\tex_relax:D#6\tex_relax:D
}
+% \end{macrocode}
+%
+% \begin{macrocode}
\tex_def:D\GetIdInfoAuxii:w #1#2#3#4#5#6\tex_relax:D{
\tex_ifx:D#5/
\tex_expandafter:D\GetIdInfoAuxCVS:w
@@ -1101,6 +1062,9 @@
\tex_expandafter:D\GetIdInfoAuxSVN:w
\tex_fi:D
}
+% \end{macrocode}
+%
+% \begin{macrocode}
\tex_def:D\GetIdInfoAuxCVS:w #1,v\tex_relax:D
#2\tex_relax:D#3\tex_relax:D{
\tex_def:D\filedate{#2}
@@ -1128,11 +1092,10 @@
% \end{macro}
% \end{macro}
% \end{macro}
+% \end{macro}
%
% Finally some corrections in the case we are running over \LaTeXe.
%
-%
-%
% We want to set things up so that experimental packages and regular
% packages can coexist with the former using the \LaTeX3 programming
% catcode settings. Since it cannot be the task of the end user to
@@ -1147,7 +1110,7 @@
% as the packages in this distribution do like this:
% \begin{verbatim}
% \RequirePackage{l3names}
-% \GetIdInfo$Id: l3names.dtx 621 2007-09-01 20:14:19Z morten $
+% \GetIdInfo$Id: l3names.dtx 1362 2009-05-28 20:19:21Z joseph $
% {L3 Experimental Box module}
% \ProvidesExplPackage
% {\filename}{\filedate}{\fileversion}{\filedescription}
@@ -1156,7 +1119,8 @@
%
% \begin{macro}{\ProvidesExplPackage}
% \begin{macro}{\ProvidesExplClass}
-% First up is the identification. Rather trivial
+% First up is the identification. Rather trivial as we don't allow for
+% options just yet.
% \begin{macrocode}
%<*package>
\tex_def:D \ProvidesExplPackage#1#2#3#4{
@@ -1172,58 +1136,106 @@
% \end{macro}
%
%
-% \begin{macro}{\org@onefilewithoptions}
-% \begin{macro}{\@onefilewithoptions}
+% \begin{macro}{\@pushfilename}
% \begin{macro}{\@popfilename}
% The idea behind the code is to record whether or not the \LaTeX3
% syntax is on or off when about to load a file with class or
% package extension. This status stored in the parameter
% |\ExplSyntaxStatus| and set by |\ExplSyntaxOn| and
-% |\ExplSyntaxOff| to |00| and |01| respectively is puched onto the
+% |\ExplSyntaxOff| to |1| and |0| respectively is pushed onto the
% stack |\ExplSyntaxStack|. Then the catcodes are set back to
% normal, the file loaded with its options and finally the stack is
-% popped again.
-%
-% |\@popfilename| is appended with a preamble check. If the catcode
-% of "@" is being reset it is a fair assumption that we are back in
-% the usual preamble and so we switch off our syntax as well.
+% popped again. The whole thing is a bit problematical. So let's
+% take a look at what the desired behavior is: A package or class
+% which declares itself of Expl type by using |\ProvidesExplClass|
+% or |\ProvidesExplPackage| should automatically ensure the correct
+% catcode scheme as soon as the identification part is
+% over. Similarly, a package or class which uses the traditional
+% |\ProvidesClass| or |\ProvidesPackage| commands should go back to
+% the traditional catcode scheme. An example:
+% \begin{verbatim}
+% \RequirePackage{l3names}
+% \ProvidesExplPackage{foobar}{2009/05/07}{0.1}{Foobar package}
+% \cs_new:Nn \foo_bar:nn {#1,#2}
+% ...
+% \RequirePackage{array}
+% ...
+% \cs_new:Nn \foo_bar:nnn {#3,#2,#1}
+% \end{verbatim}
+% Inside the \pkg{array} package, everything should behave as normal
+% under traditional \LaTeX\ but as soon as we are back at the top
+% level, we should use the new catcode regime.
+%
+%
+% Whenever \LaTeX\ inputs a package file or similar, it calls upon
+% |\@pushfilename| to push the name, the extension and the catcode
+% of @ of the file it was currently processing onto a file name
+% stack. Similarly, after inputting such a file, this file name
+% stack is popped again and the catcode of @ is set to what it was
+% before. If it is a package within package, @ maintains catcode 11
+% whereas if it is package within document preamble @ is reset to
+% what it was in the preamble (which is usually catcode 12). We wish
+% to adopt a similar technique. Every time an Expl package or class
+% is declared, they will issue an ExplSyntaxOn. Then whenever we are
+% about to load another file, we will first push this status onto a
+% stack and then turn it off again. Then when done loading a file,
+% we pop the stack and if ExplSyntax was On right before, so should
+% it be now. The only problem with this is that we cannot guarantee
+% that we get to the file name stack very early on. Therefore, if
+% the ExplSyntaxStack is empty when trying to pop it, we ensure to
+% turn ExplSyntax off again.
+%
+% |\@pushfilename| is prepended with a small function pushing the
+% current ExplSyntaxStatus (true/false) onto a stack. Then the
+% current catcode regime is recorded and ExplSyntax is switched off.
+%
+% |\@popfilename| is appended with a function for popping the
+% ExplSyntax stack. However, chances are we didn't get to hook into
+% the file stack early enough so \LaTeX\ might try to pop the file
+% name stack while the ExplSyntaxStack is empty. If the latter is
+% empty, we just switch off ExplSyntax.
% \begin{macrocode}
-\tex_let:D \org@onefilewithoptions\@onefilewithoptions
-\tex_def:D \@onefilewithoptions#1[#2][#3]#4{
- \tex_edef:D \ExplSyntaxStack{ \ExplSyntaxStatus\ExplSyntaxStack }
- \ExplSyntaxOff
- \org@onefilewithoptions{#1}[{#2}][{#3}]{#4}
- \tex_expandafter:D\ExplSyntaxPopStack\ExplSyntaxStack\tex_relax:D
-}
-\g@addto@macro\@popfilename{%
- \tex_ifnum:D\tex_the:D\tex_catcode:D`\@=12\tex_relax:D
+\tex_edef:D \@pushfilename{
+ \etex_unexpanded:D{
+ \tex_edef:D \ExplSyntaxStack{ \ExplSyntaxStatus \ExplSyntaxStack }
\ExplSyntaxOff
- \tex_fi:D
+ }
+ \etex_unexpanded:D\tex_expandafter:D{\@pushfilename }
+}
+\tex_edef:D \@popfilename{
+ \etex_unexpanded:D\tex_expandafter:D{\@popfilename
+ \tex_if:D 2\ExplSyntaxStack 2
+ \ExplSyntaxOff
+ \tex_else:D
+ \tex_expandafter:D\ExplSyntaxPopStack\ExplSyntaxStack\q_nil
+ \tex_fi:D
+ }
}
% \end{macrocode}
% \end{macro}
% \end{macro}
-% \end{macro}
%
% \begin{macro}{\ExplSyntaxPopStack}
% \begin{macro}{\ExplSyntaxStack}
-% Popping the stack is simple: Take the first two tokens which are
-% either the sequence "00" or "01" and use them in an if test. The
-% stack is initially empty.
+% Popping the stack is simple: Take the first token which is either
+% 0 (false) or 1 (true) and test if it is odd. Save the rest. The
+% stack is initially empty set to 0 signalling that before
+% \pkg{l3names} was loaded, the ExplSyntax was off.
% \begin{macrocode}
-\tex_def:D\ExplSyntaxPopStack#1#2#3\tex_relax:D{
- \tex_def:D\ExplSyntaxStack{#3}
- \tex_if:D#1#2
+\tex_def:D\ExplSyntaxPopStack#1#2\q_nil{
+ \tex_def:D\ExplSyntaxStack{#2}
+ \tex_ifodd:D#1\tex_relax:D
\ExplSyntaxOn
\tex_else:D
\ExplSyntaxOff
\tex_fi:D
}
-\tex_def:D\ExplSyntaxStack{}
+\tex_def:D \ExplSyntaxStack{0}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
+% \subsection{Finishing up}
%
% A few of the `primitives' assigned above have already been stolen
% by \LaTeX, so assign them by hand to the saved real primitive.
@@ -1243,18 +1255,11 @@
\tex_let:D\par \tex_par:D
% \end{macrocode}
%
-%
+% This is the end for \file{l3names} when used on top of \LaTeXe:
%
% \begin{macrocode}
\tex_ifx:D\name_undefine:N\@gobble
-% \end{macrocode}
-%
-% \begin{macrocode}
- \AtEndOfPackage{\ExplSyntaxOff}
\tex_def:D\name_pop_stack:w{}
-% \end{macrocode}
-%
-% \begin{macrocode}
\tex_else:D
% \end{macrocode}
%
@@ -1282,8 +1287,8 @@
% \end{macrocode}
%
% In this case the catcode preserving stack is not maintained and
-% |\CodeStart| conventions stay in force once on. You'll need
-% to turn then off explicitly with |\CodeStop| (although as currently
+% |\ExplSyntaxOn| conventions stay in force once on. You'll need
+% to turn then off explicitly with |\ExplSyntaxOff| (although as currently
% built on 2e, nothing except very experimental code will run in
% this mode!) Also note that |\RequirePackage| is a simple definition, just for
% one file, with no options.
@@ -1322,39 +1327,55 @@
% token is in fact |\let| and that may be undefined.)
% \begin{macrocode}
\tex_futurelet:D\name_tmp:\name_pop_stack:w
-%</package>
% \end{macrocode}
%
-% \endinput
-%
-% $Log$
-% Revision 1.17 2006/01/15 07:55:48 morten
-% Fixed minor typo
-%
-% Revision 1.16 2006/01/15 07:17:43 morten
-% Imported \NamesStart and \NamesStop from l3messages.
-%
-% Revision 1.15 2005/12/27 10:00:03 morten
-% Changed RCS information retrieval, code to run as package under 2e
-% changed slightly to not set special catcodes directly.
+% \paragraph{\pkg{expl3} dependency checks}
+% We want the \pkg{expl3} bundle to be loaded `as one'; this command is
+% used to ensure that one of the "l3" packages isn't loaded on its own.
+% \begin{macrocode}
+%<*!initex>
+\tex_def:D \package_check_loaded_expl: {
+ \@ifpackageloaded{expl3}{}{
+ \PackageError{expl3}{Cannot~load~the~expl3~modules~separately}{
+ The~expl3~modules~cannot~be~loaded~separately;\MessageBreak
+ please~\protect\usepackage{expl3}~instead.
+ }
+ }
+}
+%</!initex>
+% \end{macrocode}
%
-% Revision 1.14 2005/12/01 22:58:16 morten
-% Added pdfTeX primitives
+% \begin{macrocode}
+%</package>
+% \end{macrocode}
%
-% Revision 1.13 2005/03/26 21:04:19 morten
-% Fix typo.
+% \subsection{Showing memory usage}
%
-% Revision 1.12 2005/03/22 23:23:57 morten
-% Added an Aleph primitive
+% This section is from some old code from 1993; it'd be good to work out
+% how it should be used in our code today.
%
-% Revision 1.11 2005/03/15 23:16:21 braams
-% Some tweaking with the docstrip guards to get the documentation to
-% come out right.
+% During the development of the \LaTeX3 kernel we need to be able
+% to keep track of the memory usage. Therefore we generate empty
+% pages while loading the kernel code, just to be able to check the
+% memory usage.
%
-% Revision 1.10 2005/03/15 22:48:31 braams
-% Made it possible to load this as the very first file with initex
+% \begin{macrocode}
+%<*showmemory>
+\g_trace_statistics_status=2\scan_stop:
+\cs_set_nopar:Npn\showMemUsage{
+ \if_horizontal_mode:
+ \tex_errmessage:D{Wrong~ mode~ H:~ something~ triggered~
+ hmode~ above}
+ \else:
+ \tex_message:D{Mode ~ okay}
+ \fi:
+ \tex_shipout:D\hbox:w{}
+}
+\showMemUsage
+%</showmemory>
+% \end{macrocode}
%
-% Revision 1.9 2005/03/11 21:29:56 braams
-% Fixed the use of RCS information; moved definition of \eTeX
-% to l3doc.cls
+% \end{implementation}
+% \PrintIndex
%
+% \endinput