diff options
author | Karl Berry <karl@freefriends.org> | 2010-03-31 00:04:47 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2010-03-31 00:04:47 +0000 |
commit | 3ab55a61f6f8d2218a8f3175bc7481ce162b60d3 (patch) | |
tree | f606e0c2117a8058213441400e50ba25400ba94a /Master/texmf-dist/source/latex/expl3/l3final.dtx | |
parent | 035ea73193af75f6ade46e306603e61d82b24950 (diff) |
expl3 1881 (30mar10)
git-svn-id: svn://tug.org/texlive/trunk@17631 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/expl3/l3final.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/expl3/l3final.dtx | 199 |
1 files changed, 166 insertions, 33 deletions
diff --git a/Master/texmf-dist/source/latex/expl3/l3final.dtx b/Master/texmf-dist/source/latex/expl3/l3final.dtx index b9f61d473b2..d5ceed0477a 100644 --- a/Master/texmf-dist/source/latex/expl3/l3final.dtx +++ b/Master/texmf-dist/source/latex/expl3/l3final.dtx @@ -37,7 +37,7 @@ %</driver|package> %<*-ini> %\fi -\GetIdInfo$Id: l3final.dtx 1670 2009-11-01 22:34:54Z will $ +\GetIdInfo$Id: l3final.dtx 1857 2010-03-21 21:32:09Z joseph $ {L3 Experimental final module} %\iffalse %</-ini> @@ -56,32 +56,155 @@ %\section{Finalising \textsf{expl3}} % % This module is the end of \pkg{expl3}, and finishes off the -% format. It also contains the loading code for the rest of \LaTeX3. +% format. It also contains the loading code for the rest of \LaTeX3, +% along with those parts of the document structure which need to be +% in place for the rest of \LaTeX3 to load successfully. % -%\begin{function}{\par} +%\begin{function}{ +% \execute_at_document_begin:n | +% \execute_at_document_end:n | +% \execute_at_text_begin:n | +% \execute_at_text_end:n | +%} % \begin{syntax} -% "\par" +% "\execute_at_document_begin:n" \marg{code} % \end{syntax} -% \cs{par} needs to be defined, as \TeX\ uses it in some runaway -% situtations. +% Executes \meta{code} at the stated place in the document. +% \cs{execute_at_document_begin:n} code is executed at the +% beginning of |\begin{document}|, while \cs{execute_at_text_begin:n} +% is at the end of |\begin{document}|, \emph{i.e}.~the start of the +% text. In the same way, \cs{execute_at_text_end:n} code is run +% by |\end{document}| immediately, while +% \cs{execute_at_document_end:n} is the final part of the document +% before calling \cs{tex_end:D}. +% \begin{texnote} +% \cs{execute_at_text_begin:n} is similar to \cs{AtBeginDocument} +% in \LaTeXe, while \cs{execute_at_text_end:n} is similar to +% \cs{AtEndDocument}. +% \end{texnote} %\end{function} +% +%\begin{variable}{ +% \g_execute_document_begin_tl | +% \g_execute_document_end_tl | +% \g_execute_text_begin_tl | +% \g_execute_text_end_tl | +%} +% The \meta{code} stored by the \cs{execute_at\ldots} functions is +% stored in these token registers. +%\end{variable} % -%\begin{function}{\latex_format_dump:} +%\begin{function}{\par} % \begin{syntax} -% "\latex_format_dump:" +% "\par" % \end{syntax} -% Dumps the format, settting category codes back to user space and -% undefines itself (as it can only every be used once). +% \cs{par} needs to be defined, as \TeX\ uses it in some runaway +% situations. %\end{function} % +%\subsection{Minimal document support} +% +% Some temporary material to allow testing of the \pkg{xpackages} in +% \texttt{initex} mode. +% +%\begin{macro}{\g_execute_document_begin_tl} +%\begin{macro}{\g_execute_document_end_tl} +%\begin{macro}{\g_execute_text_begin_tl} +%\begin{macro}{\g_execute_text_end_tl} +% Token registers to hold material to be executed at the start +% and end of the document. +% \begin{macrocode} +%<*initex> +\tl_new:N \g_execute_document_begin_tl +\tl_new:N \g_execute_document_end_tl +\tl_new:N \g_execute_text_begin_tl +\tl_new:N \g_execute_text_end_tl +% \end{macrocode} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +% +%\begin{macro}{\execute_at_document_begin:n} +%\begin{macro}{\execute_at_document_end:n} +%\begin{macro}{\execute_at_text_begin:n} +%\begin{macro}{\execute_at_text_end:n} +% Four commands which add material to the token registers. In each +% case, the commands are set up to self-deactivate as the first thing +% that will happen when the hooks are executed. +% \begin{macrocode} +\cs_new_protected:Npn \execute_at_document_begin:n #1 { + \tl_gput_right:Nn \g_execute_document_begin_tl {#1} +} +\cs_new_protected:Npn \execute_at_document_end:n #1 { + \tl_gput_right:Nn \g_execute_document_end_tl {#1} +} +\cs_new_protected:Npn \execute_at_text_begin:n #1 { + \tl_gput_right:Nn \g_execute_text_begin_tl {#1} +} +\cs_new_protected:Npn \execute_at_text_end:n #1 { + \tl_gput_right:Nn \g_execute_text_end_tl {#1} +} +\execute_at_document_begin:n { + \tl_gclear:N \g_execute_document_begin_tl + \cs_set_eq:NN \execute_at_document_begin:n \use:n +} +\execute_at_document_end:n { + \tl_gclear:N \g_execute_document_end_tl + \cs_set_eq:NN \execute_at_document_end:n \use:n +} +\execute_at_text_begin:n { + \tl_gclear:N \g_execute_text_begin_tl + \cs_set_eq:NN \execute_at_text_begin:n \use:n +} +\execute_at_text_end:n { + \tl_gclear:N \g_execute_text_end_tl + \cs_set_eq:NN \execute_at_text_end:n \use:n +} +% \end{macrocode} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +% +% Two \emph{temporary} functions to allow testing: these are +% very basic and just do enough for things to work! The real +% implementation of the document environment will end up somewhere +% else in the end. +% \begin{macrocode} +\cs_new_protected_nopar:Npn \document { + \tl_use:N \g_execute_document_begin_tl + % Code will go here + \tl_use:N \g_execute_text_begin_tl +} +\cs_new_protected_nopar:Npn \enddocument { + \tl_use:N \g_execute_text_end_tl + % Code will go here + \tl_use:N \g_execute_document_end_tl + \tex_end:D +} +% \end{macrocode} +% +% No-ops for \cs{begin} and \cs{end}, so that they can be used in +% error messages, \emph{etc}. +% \begin{macrocode} +\cs_new_protected_nopar:Npn \begin #1 { } +\cs_new_protected_nopar:Npn \end #1 { } +% \end{macrocode} +% %\subsection{Higher-level \LaTeX3} % % Here, the rest of \LaTeX3 is loaded in a `chain'. % \begin{macrocode} -\clist_map_inline:nn { - xparse , - xtemplate , -} { \file_input_no_record:n { #1 .ltx } } +\clist_map_inline:nn + { + xparse , + xtemplate , + } + { + \file_if_exist:nT { #1 .ltx } + { \tex_input:D #1 .ltx ~ } + } % \end{macrocode} % %\subsection{Dumping the format} @@ -90,45 +213,55 @@ % \TeX\ has a nasty habit of inserting a command with the name \cs{par} % so we had better make sure that that command at least has a definition. % \begin{macrocode} -%<*initex> \cs_set_eq:NN \par \tex_par:D % \end{macrocode} %\end{macro} % +% Until the start of the document, \cs{tex_everypar:D} is set up to +% print an error if there is any text. Using \cs{tex_nullfont:D} means +% that whitespace is not important between material in the preamble. +% \begin{macrocode} +\msg_kernel_new:nnnn { document } { missing-begin-document } + {Missing \begin{document}.} + { + You've tried to print something before \begin{document}\\% + This probably means there's a mistake somewhere in your source.% + } +\tex_everypar:D { + \msg_kernel_error:nn { document } { missing-begin-document } +} +\tex_nullfont:D +% \end{macrocode} +% %\begin{macro}{\ExplSyntaxOff} % We re-define \cs{ExplSyntaxOff} as the version that comes through % from \pkg{l3names} is defined using \TeX\ primitives, which we no % longer have! Here, we can also make a fixed decision about the % category codes to fix. % \begin{macrocode} -%<*initex> -\cs_set_nopar:Npn \ExplSyntaxOff { - \intexpr_if_odd:nT { \ExplSyntaxStatus } { - \tl_set:Nn \ExplSyntaxStatus { 0 } - \char_set_catcode:nn { 126 } { 13 } - \char_set_catcode:nn { 32 } { 10 } - \char_set_catcode:nn { 9 } { 10 } - \char_set_catcode:nn { 95 } { 8 } - \char_set_catcode:nn { 58 } { 12 } - \tex_endlinechar:D = 13 \scan_stop: - } +\cs_set_protected_nopar:Npn \ExplSyntaxOff { + \intexpr_if_odd:nT { \ExplSyntaxStatus } + { + \tl_set:Nn \ExplSyntaxStatus { 0 } + \char_set_catcode:nn { 126 } { 13 } + \char_set_catcode:nn { 32 } { 10 } + \char_set_catcode:nn { 9 } { 10 } + \char_set_catcode:nn { 95 } { 8 } + \char_set_catcode:nn { 58 } { 12 } + \tex_endlinechar:D = 13 \scan_stop: + } } % \end{macrocode} %\end{macro} % %\begin{macro}{\latex_format_dump:} -% The last action to take is to dump the format. So that the document -% starts with user category codes, \cs{ExplSyntaxOff} is called along -% with tokenizing \cs{tex_dump:D} before actually calling it. +% The last action to take is to dump the format. % \begin{macrocode} -\cs_new_nopar:Npn \latex_format_dump: { +\use:n { \ExplSyntaxOff - \cs_gundefine:N \latex_format_dump: \tex_dump:D } -\latex_format_dump: %</initex> % \end{macrocode} -%\end{macro} % %\endinput |