summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/xpackages/template.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/xpackages/template.dtx')
-rw-r--r--Master/texmf-dist/source/latex/xpackages/template.dtx468
1 files changed, 241 insertions, 227 deletions
diff --git a/Master/texmf-dist/source/latex/xpackages/template.dtx b/Master/texmf-dist/source/latex/xpackages/template.dtx
index c50a1c1f7dd..6c5fd2a686a 100644
--- a/Master/texmf-dist/source/latex/xpackages/template.dtx
+++ b/Master/texmf-dist/source/latex/xpackages/template.dtx
@@ -1,6 +1,6 @@
% \iffalse
%% File: template.dtx (C) Copyright 1999-2001 David Carlisle, Frank Mittelbach
-%% (C) Copyright 2004-2008 Frank Mittelbach, LaTeX3 Project
+%% (C) Copyright 2004-2009 Frank Mittelbach, 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
@@ -34,10 +34,10 @@
%% -----------------------------------------------------------------------
%%
%<*driver|package>
-\RequirePackage{l3names}
+\RequirePackage{expl3}
%</driver|package>
%\fi
-\GetIdInfo$Id: template.dtx 749 2008-08-03 19:01:36Z morten $
+\GetIdInfo$Id: template.dtx 1295 2009-05-06 08:32:25Z will $
{template}
%\iffalse
%<*driver>
@@ -392,7 +392,7 @@
% As far as specifying instances the |l| and |L| type behave
% identically. They differ only in the type of internal storage-bin
% they need: |l| expects a length register while |L| expects an
-% ordinary macro name and assigns its value via |\def:Npn |.
+% ordinary macro name and assigns its value via |\cs_set_nopar:Npn |.
%\begin{verbatim}
% pre-sep =l \topsep,
% post-sep =L \botsep,
@@ -456,7 +456,7 @@
% run-time at the point where |\DoParameterAssignments| is seen.
%\begin{verbatim}
% item-implicit-boolean =s
-% { \def:Npn \item@implicit@code{\item\relax} }{},
+% { \cs_set_nopar:Npn \item@implicit@code{\item\relax} }{},
% numbered-boolean =b [true] @heading@nums,
%\end{verbatim}
%
@@ -654,8 +654,8 @@
%\begin{verbatim}
% {
% \IfNoValueTF{#2}
-% { \def:Npn \caption@start{#1:~} }
-% { \def:Npn \caption@start{#1~#2:~} }
+% { \cs_set_nopar:Npn \caption@start{#1:~} }
+% { \cs_set_nopar:Npn \caption@start{#1~#2:~} }
%\end{verbatim}
% Having dealt with the prelims we now run |\DoParameterAssigments| at
% which point the keys of the template are made available, e.g., at
@@ -861,8 +861,8 @@
%\begin{verbatim}
% {
% \IfNoValueTF{#2}
-% { \def:Npn \caption@start{\caption@number@format{#1}{#2}} }
-% { \def:Npn \caption@start{\caption@nonumber@format{#1}} }
+% { \cs_set_nopar:Npn \caption@start{\caption@number@format{#1}{#2}} }
+% { \cs_set_nopar:Npn \caption@start{\caption@nonumber@format{#1}} }
% \DoParameterAssigments
% \vskip \caption@above@skip \relax
%\end{verbatim}
@@ -1126,8 +1126,8 @@
% \end{macrocode}
%
% \begin{macrocode}
+\RequirePackage{expl3}
\RequirePackage{ldcsetup,xparse}
-\RequirePackage{l3toks,l3tlp,l3skip,l3int,l3clist,l3token,l3calc}
% \end{macrocode}
%
%
@@ -1149,11 +1149,11 @@
% |#2| template type/template name\\
% |#3| key value assignments for parameters of |#2|
% \begin{macrocode}
-\def_new:NNn \TP_declare_instance:Nnn 3{
+\cs_new_nopar:Nn \TP_declare_instance:Nnn {
\group_begin:
\TP_instdecl_generate_assignments:nn {#2}{#3}
- \gdef:Npx #1 {
- \tlp_if_eq:cNTF { TP>/#2 } \c_TP_doparameterassignments_tlp
+ \cs_gset_nopar:Npx #1 {
+ \tl_if_eq:cNTF { TP>/#2 } \c_TP_doparameterassignments_tl
% \end{macrocode}
% If the body of the template consists only of the token
% |\DoParameterAssignments|, then we insert the list of parameter
@@ -1169,14 +1169,14 @@
}
}
\group_end:}
-\def_new:Npn \TP_declare_instance:cnn{\exp_args:Nc\TP_declare_instance:Nnn}
+\cs_generate_variant:Nn \TP_declare_instance:Nnn {cnn}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
-% \begin{macro}{\c_TP_doparameterassignments_tlp}
+% \begin{macro}{\c_TP_doparameterassignments_tl}
% \begin{macrocode}
-\tlp_set:Nn \c_TP_doparameterassignments_tlp {\DoParameterAssignments}
+\tl_set:Nn \c_TP_doparameterassignments_tl {\DoParameterAssignments}
% \end{macrocode}
% \end{macro}
%
@@ -1190,10 +1190,10 @@
% |#2| name of a template.\\
% |#3| key value assignments for parameters of |#1|.
% \begin{macrocode}
-\def_new:NNn \UseTemplate 3{
+\cs_new_nopar:Npn \UseTemplate #1#2#3{
\TP_instdecl_generate_assignments:nn {#1/#2}{#3}
\TP_push_assignments:
- \cs_use:c { TP>/#1/#2 }
+ \use:c { TP>/#1/#2 }
}
% \end{macrocode}
% \end{macro}
@@ -1203,8 +1203,8 @@
% |\l_TP_KV_assignments_toks| and then moved onto the
% |\g_TP_assignments_stack_toks|.
% \begin{macrocode}
-\def_new:Npn \DoParameterAssignments{
- \exp_after:NN
+\cs_new_nopar:Npn \DoParameterAssignments{
+ \exp_after:wN
\TP_pop_and_execute_assignments:nw
\toks_use:N \g_TP_assignments_stack_toks \q_stop
}
@@ -1214,7 +1214,7 @@
%
% \begin{macro}{\TP_pop_and_execute_assignments:nw}
% \begin{macrocode}
-\def_new:Npn \TP_pop_and_execute_assignments:nw#1#2\q_stop{
+\cs_new_nopar:Npn \TP_pop_and_execute_assignments:nw#1#2\q_stop{
\toks_gset:Nn \g_TP_assignments_stack_toks {#2}
#1}
% \end{macrocode}
@@ -1235,13 +1235,13 @@
% registers |#|s need no doubling. |\TP_push_assignments:| expects
% it to be |\l_TP_KV_assignments_toks| (needs fixing).
% \begin{macrocode}
-\def_long_new:Npn \TP_push_assignments:n#1{
+\cs_new:Npn \TP_push_assignments:n#1{
\toks_gput_left:Nn\g_TP_assignments_stack_toks{{#1}}
}
-\def_new:Npn \TP_push_assignments:{
+\cs_new_nopar:Npn \TP_push_assignments:{
\toks_gset:No \g_TP_assignments_stack_toks
- {\exp_after:NN
- {\toks_use:N\exp_after:NN\l_TP_KV_assignments_toks\exp_after:NN}
+ {\exp_after:wN
+ {\toks_use:N\exp_after:wN\l_TP_KV_assignments_toks\exp_after:wN}
\toks_use:N\g_TP_assignments_stack_toks}
}
% \end{macrocode}
@@ -1252,8 +1252,8 @@
% \begin{macro}{\DeclareTemplateType}
% |{type}{nofarg}|
% \begin{macrocode}
-\def_new:NNn \DeclareTemplateType 2{
- \tlp_set:cn {TP@<#1>} {{}#2}}
+\cs_new_nopar:Npn \DeclareTemplateType #1#2{
+ \tl_set:cn {TP@<#1>} {{}#2}}
% \end{macrocode}
% \end{macro}
%
@@ -1262,9 +1262,9 @@
% |{type}| returns prefix for csnames for template type,
% based on current collection.
% \begin{macrocode}
-\def_new:Npn \TP_get_csname_prefix:n#1{
- <\exp_after:NN\exp_after:NN\exp_after:NN
- \use_arg_i:nn
+\cs_new_nopar:Nn \TP_get_csname_prefix:n {
+ <\exp_after:wN\exp_after:wN\exp_after:wN
+ \use_i:nn
\cs:w TP@<#1>\cs_end:>#1/
}
% \end{macrocode}
@@ -1274,9 +1274,9 @@
% \begin{macro}{\TP_get_arg_count:n}
% |{type}| returns arg count for the template type.
% \begin{macrocode}
-\def_new:Npn \TP_get_arg_count:n#1{
- \exp_after:NN\exp_after:NN\exp_after:NN
- \use_arg_ii:nn
+\cs_new_nopar:Nn \TP_get_arg_count:n {
+ \exp_after:wN\exp_after:wN\exp_after:wN
+ \use_ii:nn
\cs:w TP@<#1>\cs_end:
}
% \end{macrocode}
@@ -1286,55 +1286,69 @@
% \begin{macro}{\DeclareTemplate}
% |{type}{templatename}{nofarg}{keywordspec}{code}|
% \begin{macrocode}
-\def_long_new:NNn\DeclareTemplate 5{
+\cs_new:Npn\DeclareTemplate #1#2#3#4#5{
\cs_if_free:cTF{TP@<#1>}
{\undefinedtype\DeclareTemplateType{#1}#3}
{
- \int_compare:nNnF{#3}={\TP_get_arg_count:n{#1}}
+ \intexpr_compare:nNnF{#3}={\TP_get_arg_count:n{#1}}
{ \BadArgCount }
}
% \end{macrocode}
% Parse the key declaration, and execute the list with a suitable
% definition of |\KV@elt|.
% \begin{macrocode}
- \let:NN \KV_elt:nn \TP_templdecl_process_KV:nn
- \def:Npn \KV_default_elt:n##1{
+ \cs_set_eq:NN \KV_elt:nn \TP_templdecl_process_KV:nn
+ \cs_set_nopar:Npn \KV_default_elt:n##1{
\PackageError{template}{Missing~ =~ after~ ##1}\@ehd}
- \let:NN\KV@elt\KV_elt:nn
- \let:NN\KV@default@elt\KV_default_elt:n
- \tlp_set:Nn \l_TP_curr_name_tlp {#1/#2}
+ \cs_set_eq:NN\KV@elt\KV_elt:nn
+ \cs_set_eq:NN\KV@default@elt\KV_default_elt:n
+ \tl_set:Nn \l_TP_curr_name_tl {#1/#2}
\toks_clear:N\l_TP_default_assignments_toks
% \end{macrocode}
% At this point there should be a test for which catcode regime we are
% in. We just test if spaces are ignored.
% \begin{macrocode}
- %\int_compare:nNnTF{\char_value_catcode:n{`\ }}=\c_nine
+ %\intexpr_compare:nNnTF{\char_value_catcode:n{`\ }}=\c_nine
%\KV_parse_picky_no_space_removal_no_sanitize:n
%\KV_parse_picky_space_removal_no_sanitize:n
\KV@parse{#4}
% \end{macrocode}
%
-% Define the defaults: the setting for |TPD>/\l_TP_curr_name_tlp| is a
+% Define the defaults: the setting for |TPD>/\l_TP_curr_name_tl| is a
% tricky since |\l_TP_default_assignments_toks| may contain |#|. We
% have to use an |x| expansion rather than
% |o| since that will hide those during the assignment.
+% FIX THIS (see below)!
% \begin{macrocode}
- \tlp_set:cx { TPD>/\l_TP_curr_name_tlp }
+ \cs_set_nopar:cpx { TPD>/\l_TP_curr_name_tl }
{\toks_use:N\l_TP_default_assignments_toks}
- \tlp_clear:c {TPR>/\l_TP_curr_name_tlp}
+ \tl_clear:c {TPR>/\l_TP_curr_name_tl}
- \tlp_set_eq:cN {TPO>/\l_TP_curr_name_tlp}\l_TP_curr_name_tlp
+ \tl_set_eq:cN {TPO>/\l_TP_curr_name_tl}\l_TP_curr_name_tl
% \end{macrocode}
%
-% Define the template (using |\def_new:Npn| means that one can't
+% Define the template (using |\cs_new_nopar:Npn| means that one can't
% redefine a template easily).
% \begin{macrocode}
- \def_long:cNn {TP>/\l_TP_curr_name_tlp}{#3}{#5}
+ \cs_generate_from_arg_count:cNnn {TP>/\l_TP_curr_name_tl}
+ \cs_set:Npn {#3}{#5}
}
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\tl_set:cx}
+% FIX this: The code above only works because in the past |\tl_set:cx| was
+% defined as follows:
+% \begin{macrocode}
+\cs_set:Npn \tl_set:cx {\exp_args:Nc \tl_set:Nx}
+% \end{macrocode}
+% i.e., expanding the second arg at the very end.
+% This is no longer the case but for the moment I revert to the old
+% definition until the template code is fixed to not rely on |\tl_set:cx|
+% expanding the second arg at the very last minute.
+% \end{macro}
+%
% \begin{macro}{\TP_templdecl_process_KV:nn}
% The list of undefined keys and values is put in the list of the form\\
% |\KV_elt:nn|\marg{key1}\marg{val1}%^^A
@@ -1343,18 +1357,20 @@
% to look at the first token of the value, to see what sort of key
% it is, so call a helper function to split that off.
% \begin{macrocode}
-\def_new:Npn \TP_templdecl_process_KV:nn#1#2{%
- \let:NN \TP_templdecl_add_global_or_nothing: \use_noop:
+\cs_new_nopar:Nn \TP_templdecl_process_KV:nn {%
+ \cs_set_eq:NN \TP_templdecl_add_global_or_nothing: \prg_do_nothing:
\bool_set_false:N\l_TP_global_assignment_bool
- \tlp_set:Nn\l_TP_currkey_tlp{#1}
+ \tl_set:Nn\l_TP_currkey_tl{#1}
\TP_templdecl_parse_KV:N#2\q_stop}
% \end{macrocode}
% \end{macro}
%
+%
+%
% \begin{macro}{\TP_templdecl_parse_KV:N}
% Case switch on the possible key types.
% \begin{macrocode}
-\def_new:Npn \TP_templdecl_parse_KV:N#1{
+\cs_new_nopar:Nn \TP_templdecl_parse_KV:N {
% \end{macrocode}
% In |#1| we have key, in |#2| the first character after the equal
% sign and in |#3| the remainder of the line. We now have to parse
@@ -1374,8 +1390,8 @@
% removed (if present)).
% \begin{macrocode}
\cs_if_free:cTF{TP_use_arg_type_#1:w}
- {\PackageError{template}{Unknown~key~type~ (#1)~for~\l_TP_currkey_tlp}\@eha}
- {\cs_use:c{TP_use_arg_type_#1:w}}
+ {\PackageError{template}{Unknown~key~type~ (#1)~for~\l_TP_currkey_tl}\@eha}
+ {\use:c{TP_use_arg_type_#1:w}}
% \end{macrocode}
% The |f| and |i| keys are somewhat different since there we first
% have to parse for an additional argument (a digit in case of |f|
@@ -1386,7 +1402,7 @@
% so we change |\TP_templdecl_add_global_or_nothing:| to append a
% |\pref_global:D| to the assignment toks and then reparse the rest.
% \begin{macrocode}
-% \def:Npn \TP_templdecl_add_global_or_nothing:
+% \cs_set_nopar:Npn \TP_templdecl_add_global_or_nothing:
% {\toks_put_right:Nn \l_TP_KV_assignments_toks {\pref_global:D} }
% \TP_templdecl_parse_KV:nw{#1}#3\TP_templdecl_parse_KV:nnw
}
@@ -1409,9 +1425,9 @@
% again.\footnote{It should probably all be changed to not rely on
% the prefix working}.
% \begin{macrocode}
-\def_new:cpn{TP_use_arg_type_+:w} {
+\cs_new_nopar:cpn{TP_use_arg_type_+:w} {
\bool_set_true:N\l_TP_global_assignment_bool
- \def:Npn \TP_templdecl_add_global_or_nothing:
+ \cs_set_nopar:Npn \TP_templdecl_add_global_or_nothing:
{\toks_put_right:Nn \l_TP_KV_assignments_toks {\pref_global:D} }
\TP_templdecl_parse_KV:N
}
@@ -1423,10 +1439,10 @@
% either |\gsetlength| or |\setlength| depending on whether a |+|
% was seen or not.
% \begin{macrocode}
-\def_new:Npn\TP_use_arg_type_l:w {
+\cs_new_nopar:Npn\TP_use_arg_type_l:w {
\TP_parse_optional_key_default:nw
{
- \let:NN \TP_templdecl_add_global_or_nothing: \use_noop:
+ \cs_set_eq:NN \TP_templdecl_add_global_or_nothing: \prg_do_nothing:
\bool_if:NTF \l_TP_global_assignment_bool
{\TP_templdecl_setup_register_key:Nn\gsetlength}
{\TP_templdecl_setup_register_key:Nn\setlength}
@@ -1438,7 +1454,7 @@
% \begin{macro}{\TP_use_arg_type_L:w}
% The |L| sets a fake length register.
% \begin{macrocode}
-\def_new:Npn\TP_use_arg_type_L:w {
+\cs_new_nopar:Npn\TP_use_arg_type_L:w {
\TP_parse_optional_key_default:nw
{\TP_templdecl_setup_fakeregister_key:NNn\setlength\l_tmpa_skip}
}
@@ -1448,10 +1464,10 @@
% \begin{macro}{\TP_use_arg_type_c:w}
% The |c| sets a count register.
% \begin{macrocode}
-\def_new:Npn\TP_use_arg_type_c:w {
+\cs_new_nopar:Npn\TP_use_arg_type_c:w {
\TP_parse_optional_key_default:nw
{
- \let:NN\TP_templdecl_add_global_or_nothing:\use_noop:
+ \cs_set_eq:NN\TP_templdecl_add_global_or_nothing:\prg_do_nothing:
\bool_if:NTF \l_TP_global_assignment_bool
{\TP_templdecl_setup_register_key:Nn\GSetInternalCounter}
{\TP_templdecl_setup_register_key:Nn\SetInternalCounter}
@@ -1463,7 +1479,7 @@
% \begin{macro}{\TP_use_arg_type_C:w}
% The |C| sets a fake count register.
% \begin{macrocode}
-\def_new:Npn\TP_use_arg_type_C:w {
+\cs_new_nopar:Npn\TP_use_arg_type_C:w {
\TP_parse_optional_key_default:nw
{\TP_templdecl_setup_fakeregister_key:NNn
\SetInternalCounter\l_tmpa_int}
@@ -1472,9 +1488,9 @@
% \end{macro}
%
% \begin{macro}{\TP_use_arg_type_n:w}
-% The |n| sets a token list pointer.
+% The |n| sets a token list variable.
% \begin{macrocode}
-\def_new:Npn\TP_use_arg_type_n:w {
+\cs_new_nopar:Npn\TP_use_arg_type_n:w {
\TP_parse_optional_key_default:nw
{\TP_templdecl_setup_n_key:N}
}
@@ -1485,14 +1501,14 @@
% \begin{macro}{\TP_templdecl_parse_f_arg:nw}
% The |f| defines a command with between 0 and 9 arguments.
% \begin{macrocode}
-\def_new:Npn\TP_use_arg_type_f:w #1{
+\cs_new_nopar:Npn\TP_use_arg_type_f:w #1{
%\TP_templdecl_parse_f_arg:nw {#1}
\TP_parse_optional_key_default:nw{\TP_templdecl_setup_f_key:Nn{#1}}
}
% \end{macrocode}
% Helper for |\TP_templdecl_parse_KV:nnw|.
% \begin{macrocode}
-\def_new:Npn \TP_templdecl_parse_f_arg:nw#1#2{
+\cs_new_nopar:Npn \TP_templdecl_parse_f_arg:nw#1#2{
% \end{macrocode}
% The third argument of |\TP_templdecl_setup_f_key:Nn|, i.e., the
% macro name, is the remaining data up to |\q_stop| which is picked up
@@ -1510,15 +1526,15 @@
% The |b| uses access to the |\if_true:| and |\if_false:|
% primitives. Needed?
% \begin{macrocode}
-\def_new:Npn\TP_use_arg_type_b:w {
+\cs_new_nopar:Npn\TP_use_arg_type_b:w {
\TP_parse_optional_key_default:nw
{\TP_templdecl_setup_b_key:n}
}
% \end{macrocode}
%
% \begin{macrocode}
-\def_new:Npn \TP_templdecl_setup_b_key:n#1{
- \let:cN { if#1 } \if_true:
+\cs_new_nopar:Npn \TP_templdecl_setup_b_key:n#1{
+ \cs_set_eq:cN { if#1 } \if_true:
\TP_templdecl_define_key:n
{ \TP_templdecl_eval_b_key_value:nn {#1}{##1} }
}
@@ -1530,12 +1546,12 @@
% Modify so the boolean does not need to have been
% declared with |\newif|
% \begin{macrocode}
-\def_new:Npn \TP_templdecl_eval_b_key_value:nn#1#2{
+\cs_new_nopar:Npn \TP_templdecl_eval_b_key_value:nn#1#2{
\cs_if_free:cTF {if#2}
{ \PackageError{template}{Bad~boolean~setting~#1=#2}\@eha }
- { \tlp_set_eq:cc {if_#1:}{if_#2:}
+ { \tl_set_eq:cc {if_#1:}{if_#2:}
\toks_put_right:Nf \l_TP_KV_assignments_toks
- { \tlp_set_eq:cc {if_#1:}{if_#2:} }
+ { \tl_set_eq:cc {if_#1:}{if_#2:} }
}
}
% \end{macrocode}
@@ -1546,13 +1562,13 @@
% \begin{macro}{\TP_templdecl_setup_s_key:n}
% The |s| chooses between true and false.
% \begin{macrocode}
-\def_new:Npn\TP_use_arg_type_s:w {
+\cs_new_nopar:Npn\TP_use_arg_type_s:w {
\TP_parse_optional_key_default:nw
{\TP_templdecl_setup_s_key:n}
}
% \end{macrocode}
% \begin{macrocode}
-\def_new:Npn \TP_templdecl_setup_s_key:n #1 {
+\cs_new_nopar:Npn \TP_templdecl_setup_s_key:n #1 {
\TP_templdecl_define_key:n
{ \TP_templdecl_eval_s_key_value:nnn{##1}#1 }
}
@@ -1569,7 +1585,7 @@
% \begin{macro}{\TP_use_arg_type_i:w}
% The |i| expects an instance.
% \begin{macrocode}
-\def_new:Npn\TP_use_arg_type_i:w #1{
+\cs_new_nopar:Npn\TP_use_arg_type_i:w #1{
\TP_parse_optional_key_default:nw{\TP_templdecl_setup_i_key:nnn{#1}}
}
% \end{macrocode}
@@ -1586,7 +1602,7 @@
% \begin{macro}{\TP_templdecl_setup_i_key:nnn}
% MH change: do either local or global.
% \begin{macrocode}
-\def_new:Npn \TP_templdecl_setup_i_key:nnn#1#2{
+\cs_new_nopar:Npn \TP_templdecl_setup_i_key:nnn#1#2{
\TP_templdecl_define_key:n
{
\TP_templdecl_eval_i_key_value:Nnn #2 {#1}{##1}
@@ -1598,10 +1614,10 @@
% \begin{macro}{\TP_templdecl_eval_i_key_value:Nnn}
% MH change: Add extra argument for local or global.
% \begin{macrocode}
-\def_new:Npn \TP_templdecl_eval_i_key_value:Nnn #1#2#3 {
- \tlist_if_head_eq_meaning:nNTF {#3.}\UseTemplate
+\cs_new_nopar:Npn \TP_templdecl_eval_i_key_value:Nnn #1#2#3 {
+ \tl_if_head_eq_meaning:nNTF {#3.}\UseTemplate
{
- \io_put_term:x{\token_to_string:N\UseTemplate\space seen}
+ \iow_term:x{\token_to_str:N\UseTemplate\space seen}
% \end{macrocode}
%
% Code below from |\TP_templdecl_setup_f_key:Nn| (should be
@@ -1612,25 +1628,25 @@
% \begin{macrocode}
{\TP_templdecl_declare_tmp_instance:nnnn #3 }
\toks_put_right:No \l_TP_KV_assignments_toks
- { \exp_after:NN \KV@toks \exp_after:NN {\g_tmpa_tlp} }
+ { \exp_after:wN \KV@toks \exp_after:wN {\g_tmpa_tl} }
%\TP_templdecl_add_global_or_nothing:
%\toks_put_right:Nn \l_TP_KV_assignments_toks
- % { \def:Npx #1{ \toks_use:N \KV@toks} }
+ % { \cs_set_nopar:Npx #1{ \toks_use:N \KV@toks} }
\bool_if:NTF \l_TP_global_assignment_bool
{\toks_put_right:Nn \l_TP_KV_assignments_toks
- {\gdef:Npx #1 { \toks_use:N \KV@toks}}
+ {\cs_gset_nopar:Npx #1 { \toks_use:N \KV@toks}}
}
{\toks_put_right:Nn \l_TP_KV_assignments_toks
- {\def:Npx #1 { \toks_use:N \KV@toks}}
+ {\cs_set_nopar:Npx #1 { \toks_use:N \KV@toks}}
}
}
{
\TP_let_instance:Nnn#1{#2}{#3}
% \end{macrocode}
-% We want the |\let:Nc| hiding in |\TP_let_instance:Nnn| to expand
+% We want the |\cs_set_eq:Nc| hiding in |\TP_let_instance:Nnn| to expand
% fully to two csnames so we put a |\tex_romannumeral:D 0| (which in
-% itself expands to nothing) in front. This expands the |\let:Nc| fully
-% before finding out that |\let:NwN| is not expandable.
+% itself expands to nothing) in front. This expands the |\cs_set_eq:Nc| fully
+% before finding out that |\cs_set_eq:NwN| is not expandable.
% \begin{macrocode}
\toks_put_right:Nf \l_TP_KV_assignments_toks
{ \TP_let_instance:Nnn#1{#2}{#3} }
@@ -1650,14 +1666,14 @@
% \begin{macro}{\TP_templdecl_setup_x_key:nn}
% The |x| runs internal code.
% \begin{macrocode}
-\def_new:Npn\TP_use_arg_type_x:w {
+\cs_new_nopar:Npn\TP_use_arg_type_x:w {
\TP_parse_optional_key_default:nw
{\TP_templdecl_setup_x_key:n}
}
% \end{macrocode}
%
% \begin{macrocode}
-\def_new:Npn \TP_templdecl_setup_x_key:n#1{
+\cs_new_nopar:Npn \TP_templdecl_setup_x_key:n#1{
\TP_templdecl_define_key:n
{ \toks_put_right:Nn\l_TP_KV_assignments_toks{#1} }
}
@@ -1673,14 +1689,14 @@
% \begin{macro}{\TP_templdecl_setup_g_key:nn}
% The |g| runs any code.
% \begin{macrocode}
-\def_new:Npn\TP_use_arg_type_g:w {
+\cs_new_nopar:Npn\TP_use_arg_type_g:w {
\TP_parse_optional_key_default:nw
{\TP_templdecl_setup_g_key:n}
}
% \end{macrocode}
%
% \begin{macrocode}
-\def_new:Npn \TP_templdecl_setup_g_key:n #1 {
+\cs_new_nopar:Npn \TP_templdecl_setup_g_key:n #1 {
\TP_templdecl_define_key:n{#1}}
% \end{macrocode}
%
@@ -1691,16 +1707,21 @@
%
%
% \begin{macro}{\TP_templdecl_define_key:n}
-% Here we define the key in the current template.
-% \begin{macrocode}
-\def_new:Npn \TP_templdecl_define_key:n#1{
- \tlp_set:Nx \l_tmpa_tlp {
- \exp_not:N \TP_templdecl_remove_from_default_assignments:N
- \exp_not:c{KV@\l_TP_curr_name_tlp @\l_TP_currkey_tlp}
- \exp_not:o {\TP_templdecl_add_global_or_nothing: }
- }
- \exp_args:NcNo \def:NNn {KV@\l_TP_curr_name_tlp @\l_TP_currkey_tlp} 1
- { \l_tmpa_tlp #1 }
+% Here we define the key in the current template. Original code from
+% r522 is essentially unreadable but we keep it here until the
+% internal structure is finally sorted out.
+% \begin{macrocode}
+\cs_new_nopar:Npn \TP_templdecl_define_key:n#1{
+ \exp_after:wN \cs_set:Npn \cs:w
+ KV@\l_TP_curr_name_tl @\l_TP_currkey_tl
+ \exp_after:wN\cs_end:
+ \exp_after:wN##\exp_after:wN1\exp_after:wN{
+ \exp_after:wN\TP_templdecl_remove_from_default_assignments:N
+ \cs:w KV@\l_TP_curr_name_tl @\l_TP_currkey_tl
+ \exp_after:wN \cs_end:
+ \TP_templdecl_add_global_or_nothing:
+ #1
+ }
}
% \end{macrocode}
% \end{macro}
@@ -1720,11 +1741,11 @@
% set it to be a regular optional argument in brackets. |#1| is what
% we are carrying over, |#2| the optional argument.
% \begin{macrocode}
-\def_long:Npn \TP_ignore_leading_space_in_arg_ii:nn#1#2{
+\cs_set:Npn \TP_ignore_leading_space_in_arg_ii:nn#1#2{
\exp_args:Nf\TP_ignore_leading_space_in_arg_ii_aux:nn
{\exp_not:N #2}{#1}
}
-\def_long:Npn \TP_ignore_leading_space_in_arg_ii_aux:nn#1#2{#2{#1}}
+\cs_set:Npn \TP_ignore_leading_space_in_arg_ii_aux:nn#1#2{#2{#1}}
\DeclareArgumentType t[{meaning}{}{\NoValue}{#1[#2]}{#2}
@@ -1744,7 +1765,7 @@
% executing the setup code (in |#1|) giving it |#2| (i.e., the
% remainder of the line) as an argument.
% \begin{macrocode}
-\def_new:Npn \TP_templdecl_finish_key_setup:nw#1#2\q_stop{
+\cs_new_nopar:Npn \TP_templdecl_finish_key_setup:nw#1#2\q_stop{
\TP_ignore_leading_space_in_arg_ii:nn{#1}{#2}
%%%#1{#2}
}
@@ -1759,7 +1780,7 @@
%
% First set up the the key itself:
% \begin{macrocode}
-\def_new:Npn \TP_templdecl_finish_key_setup_with_default:nnw#1#2#3\q_stop{
+\cs_new_nopar:Npn \TP_templdecl_finish_key_setup_with_default:nnw#1#2#3\q_stop{
\TP_ignore_leading_space_in_arg_ii:nn{#1}{#3}
%%% #1 {#3}
% \end{macrocode}
@@ -1774,25 +1795,25 @@
% \begin{macrocode}
\group_begin:
\toks_clear:N \l_TP_KV_assignments_toks
- \let:NN \TP_templdecl_remove_from_default_assignments:N \use_none:n
- \cs_use:c{KV@\l_TP_curr_name_tlp @\l_TP_currkey_tlp}{#2}
+ \cs_set_eq:NN \TP_templdecl_remove_from_default_assignments:N \use_none:n
+ \use:c{KV@\l_TP_curr_name_tl @\l_TP_currkey_tl}{#2}
% \end{macrocode}
% And now for a final trick: before closing the group again and losing
-% our local changes we run |\exp_after:NN| several times to get the
+% our local changes we run |\exp_after:wN| several times to get the
% value of |\l_TP_KV_assignments_toks| into
% |\l_TP_default_assignments_toks| outside that group!
% \begin{macrocode}
- \exp_after:NN
+ \exp_after:wN
\group_end:
- \exp_after:NN
+ \exp_after:wN
\toks_set:Nn
- \exp_after:NN
+ \exp_after:wN
\l_TP_default_assignments_toks
- \exp_after:NN
- { \cs:w KV@\l_TP_curr_name_tlp @\l_TP_currkey_tlp \exp_after:NN \cs_end:
- \exp_after:NN
- { \toks_use:N \exp_after:NN \l_TP_KV_assignments_toks
- \exp_after:NN
+ \exp_after:wN
+ { \cs:w KV@\l_TP_curr_name_tl @\l_TP_currkey_tl \exp_after:wN \cs_end:
+ \exp_after:wN
+ { \toks_use:N \exp_after:wN \l_TP_KV_assignments_toks
+ \exp_after:wN
}
\toks_use:N\l_TP_default_assignments_toks
}
@@ -1802,18 +1823,18 @@
%
%
%
-% \begin{macro}{\c_TP_true_tlp}
+% \begin{macro}{\c_TP_true_tl}
% \begin{macrocode}
-\tlp_new:Nn \c_TP_true_tlp {true}
+\tl_new:Nn \c_TP_true_tl {true}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\TP_templdecl_eval_s_key_value:nnn}
% \begin{macrocode}
-\def_new:Npn \TP_templdecl_eval_s_key_value:nnn#1#2#3 {
+\cs_new_nopar:Npn \TP_templdecl_eval_s_key_value:nnn#1#2#3 {
% no error check on this yet.
- \tlp_set:Nn \l_tmpa_tlp {#1}
- \tlp_if_eq:NNTF \l_tmpa_tlp \c_TP_true_tlp
+ \tl_set:Nn \l_tmpa_tl {#1}
+ \tl_if_eq:NNTF \l_tmpa_tl \c_TP_true_tl
{ \toks_put_right:Nn \l_TP_KV_assignments_toks {#2} }
{ \toks_put_right:Nn \l_TP_KV_assignments_toks {#3} }
}
@@ -1825,7 +1846,7 @@
%
% Command for setting a template attribute whose name
% corresponds directly to a \TeX{} count or length register\\
-% |#1| the function to set the value eg \setlength.\\
+% |#1| the function to set the value eg \cs{setlength}.\\
% |#2| key name.\\
% |#3| the register to set.
%
@@ -1838,16 +1859,16 @@
% just pass the whole assignment to the template. Remember to remove
% the |\DelayEvaluation|.
% \begin{macrocode}
-\def_new:Npn \TP_templdecl_setup_register_key:Nn #1#2{
+\cs_new_nopar:Npn \TP_templdecl_setup_register_key:Nn #1#2{
\TP_templdecl_define_key:n{
- \tlist_if_head_eq_meaning:nNTF{##1}\DelayEvaluation
+ \tl_if_head_eq_meaning:nNTF{##1}\DelayEvaluation
{
% \end{macrocode}
% Old line commented out. Remove |\DelayEvaluation| and also remove
% the braces surrounding its argument.
% \begin{macrocode}
\toks_put_right:Nn \l_TP_KV_assignments_toks {#1#2{##1}}
- %\toks_set:No\l_tmpa_toks{\use_arg_ii:nn ##1}
+ %\toks_set:No\l_tmpa_toks{\use_ii:nn ##1}
%\toks_put_right:Nx \l_TP_KV_assignments_toks
% {\exp_not:n{#1#2}{\toks_use:N \l_tmpa_toks}}
}
@@ -1864,7 +1885,7 @@
%
% \begin{macrocode}
{
- \tlist_if_head_eq_meaning:nNTF{##1..}\MultiSelection
+ \tl_if_head_eq_meaning:nNTF{##1..}\MultiSelection
{
\group_begin:
\TP_multiselection_add:nnnnnn #1#2##1
@@ -1875,19 +1896,19 @@
% there are probably better ways to do this (:-)
%
% \begin{macrocode}
- \tlist_if_in:onTF{\toks_use:N\g_TP_multiselection_toks}\DelayEvaluation
+ \tl_if_in:onTF{\toks_use:N\g_TP_multiselection_toks}\DelayEvaluation
{
\toks_put_right:No\l_TP_KV_assignments_toks
{
- \exp_after:NN#1\exp_after:NN#2\exp_after:NN
+ \exp_after:wN#1\exp_after:wN#2\exp_after:wN
{\toks_use:N\g_TP_multiselection_toks}
}
}
{
\toks_put_right:No\l_TP_KV_assignments_toks
{
- \exp_after:NN #2
- \exp_after:NN= \toks_use:N\g_TP_multiselection_toks\scan_stop:
+ \exp_after:wN #2
+ \exp_after:wN= \toks_use:N\g_TP_multiselection_toks\scan_stop:
}
}
% \end{macrocode}
@@ -1900,7 +1921,7 @@
{
#1#2{##1}
\toks_put_right:No\l_TP_KV_assignments_toks {
- \exp_after:NN #2 \exp_after:NN = \tex_the:D #2\scan_stop:
+ \exp_after:wN #2 \exp_after:wN = \tex_the:D #2\scan_stop:
}
}
}
@@ -1920,8 +1941,8 @@
% |\MultiSelection| a few places we better give them unique
% meanings!
% \begin{macrocode}
-\def_new:NNn\DelayEvaluation 1{\use_none:n{\DelayEvaluation}#1}
-\def_new:NNn\MultiSelection 1{\use_none:n{\MultiSelection}#1}
+\cs_new_nopar:Npn\DelayEvaluation #1{\use_none:n{\DelayEvaluation}#1}
+\cs_new_nopar:Npn\MultiSelection #1{\use_none:n{\MultiSelection}#1}
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -1931,11 +1952,11 @@
% perhaps be implemented as such as this would make far more
% readable code.
% \begin{macrocode}
-\def_new:Npn \TP_templdecl_remove_from_default_assignments:N#1{
- \def:Npn \tmp:w ##1#1##2##3#1##4\q_stop{
+\cs_new_nopar:Npn \TP_templdecl_remove_from_default_assignments:N#1{
+ \cs_set_nopar:Npn \TP_tmp:w ##1#1##2##3#1##4\q_stop{
\l_TP_default_assignments_toks{##1##3}
}
- \exp_after:NN \tmp:w
+ \exp_after:wN \TP_tmp:w
\toks_use:N\l_TP_default_assignments_toks #1\scan_stop:#1\q_stop}
% \end{macrocode}
% \end{macro}
@@ -1955,7 +1976,7 @@
% is responsible for picking up the requested number of
% arguments. (This is \emph{not} checked.)
% \begin{macrocode}
-\def_new:Npn \TP_templdecl_setup_f_key:Nn#1#2{
+\cs_new_nopar:Npn \TP_templdecl_setup_f_key:Nn#1#2{
% \end{macrocode}
%
% |##1| can either be arbitrary inline code, in which case it will be
@@ -1972,11 +1993,13 @@
%
%
% \begin{macro}{\TP_templdecl_define_function:NNn}
-% |\def:Npn | setup with a latex style `number of arguments' argument.
+% Use number of arguments to define function.
% \begin{macrocode}
-\def_new:Npn \TP_templdecl_define_function:NNn#1#2#3{
- \def:NNn #2 #1 {#3}
- \toks_put_right:Nf \l_TP_KV_assignments_toks { \def:NNn #2 #1 {#3} }
+\cs_new_nopar:Npn \TP_templdecl_define_function:NNn#1#2#3{
+ \cs_generate_from_arg_count:NNnn #2 \cs_set:Npn {#1}{#3}
+ \toks_put_right:Nf \l_TP_KV_assignments_toks {
+ \cs_generate_from_arg_count:NNnn #2 \cs_set:Npn {#1}{#3}
+ }
}
% \end{macrocode}
% \end{macro}
@@ -1996,9 +2019,9 @@
% it is essentially doing the same.
%
% \begin{macrocode}
-\def_new:Npn \TP_templdecl_setup_n_key:N#1{
+\cs_new_nopar:Npn \TP_templdecl_setup_n_key:N#1{
\TP_templdecl_define_key:n{
- \tlist_if_head_eq_meaning:nNTF{##1..}\MultiSelection
+ \tl_if_head_eq_meaning:nNTF{##1..}\MultiSelection
{
\group_begin:
\TP_templdecl_multiselection:nnnn ##1
@@ -2009,17 +2032,17 @@
% number of times to get to the item but we also want to ensure we do
% not have any unwanted leftover |\fi:|s or other junk which is bound
% to cause errors later on. Therefore we start an |f| expansion (so we
-% don't have to count |\exp_after:NN|s and then stop it again when we
+% don't have to count |\exp_after:wN|s and then stop it again when we
% want to.
% \begin{macrocode}
\toks_put_right:Nx\l_TP_KV_assignments_toks {
- \exp_not:n{\tlp_set:Nf #1} { \toks_use:N \g_TP_multiselection_toks}
+ \exp_not:n{\tl_set:Nf #1} { \toks_use:N \g_TP_multiselection_toks}
}
}
{
- \def:Npn #1{##1} % setting it?
+ \cs_set_nopar:Npn #1{##1} % setting it?
\toks_put_right:Nn \l_TP_KV_assignments_toks
- { \tlp_set:Nn #1{##1} }
+ { \tl_set:Nn #1{##1} }
}
}
}
@@ -2031,13 +2054,13 @@
% type expansion we better stop it at the right place once we have
% emerged on the other side of the conditional.
% \begin{macrocode}
-\def_new:Npn \TP_templdecl_multiselection:nnnn #1#2#3#4{
+\cs_new_nopar:Npn \TP_templdecl_multiselection:nnnn #1#2#3#4{
\toks_gset:Nn \g_TP_multiselection_toks {\if_case:w #2}
\clist_map_inline:nn {#3}{
\TP_multiselection_add_or_case:n {\exp_stop_f:##1}
}
\toks_gput_right:Nn\g_TP_multiselection_toks {
- \else: \use_arg_i_after_fi:nw { \exp_stop_f: #4} \fi:
+ \else: \use_i_after_fi:nw { \exp_stop_f: #4} \fi:
}
}
% \end{macrocode}
@@ -2053,7 +2076,7 @@
% \begin{macro}{\DeclareInstance}
% |{type}{instname}{templatename}{keyval}|
% \begin{macrocode}
-\def_new:Npn \DeclareInstance { \DeclareCollectionInstance{} }
+\cs_new_nopar:Npn \DeclareInstance { \DeclareCollectionInstance{} }
% \end{macrocode}
% \end{macro}
%
@@ -2061,7 +2084,7 @@
% |{collection}{type}{instname}{templatename}{keyval}|
% The fifth argument is picked up implicitly.
% \begin{macrocode}
-\def_long_new:Npn \DeclareCollectionInstance#1#2#3#4{
+\cs_new:Npn \DeclareCollectionInstance#1#2#3#4{
\TP_declare_instance:cnn { <#1>#2/#3 }{ #2/#4 }
}
% \end{macrocode}
@@ -2070,8 +2093,8 @@
% \begin{macro}{\UseCollection}
% |{type}{collection}|
% \begin{macrocode}
-\def_new:Npn \UseCollection#1#2{
- \tlp_set:cx { TP@<#1> }
+\cs_new_nopar:Npn \UseCollection#1#2{
+ \tl_set:cx { TP@<#1> }
{ {#2} \TP_get_arg_count:n{#1} }
}
% \end{macrocode}
@@ -2080,12 +2103,12 @@
% \begin{macro}{\TP_let_instance:Nnn}
% |\internalcommand{type}{instname}|
%
-% The way this macro is used, it must result in |\let:NwN| |<csname1>|
+% The way this macro is used, it must result in |\cs_set_eq:NwN| |<csname1>|
% |<csname2>| after exactly two expansions as it is used this way
% in |\TP_templdecl_eval_i_key_value:nnn|!
% \begin{macrocode}
-\def_new:Npn \TP_let_instance:Nnn#1#2#3{
- \let:Nc #1
+\cs_new_nopar:Npn \TP_let_instance:Nnn#1#2#3{
+ \cs_set_eq:Nc #1
{
\cs_if_free:cTF { \TP_get_csname_prefix:n{#2} #3 }
{ <>#2/ }
@@ -2099,11 +2122,11 @@
% \begin{macro}{\UseInstance}
% |{type}{instname}|
% \begin{macrocode}
-\def_new:Npn \UseInstance#1#2{
- \TP_let_instance:Nnn \l_tmpa_tlp {#1}{#2}
- \tlp_if_eq:NNTF \l_tmpa_tlp \scan_stop:
+\cs_new_nopar:Npn \UseInstance#1#2{
+ \TP_let_instance:Nnn \l_tmpa_tl {#1}{#2}
+ \tl_if_eq:NNTF \l_tmpa_tl \scan_stop:
\INSTANCEundefined
- \l_tmpa_tlp
+ \l_tmpa_tl
}
% \end{macrocode}
% \end{macro}
@@ -2116,8 +2139,8 @@
% the template and the fourth argument will be implictly picked up
% by |\TP_declare_instance:Nnn|.
% \begin{macrocode}
-\def_long_new:Npn \TP_templdecl_declare_tmp_instance:nnnn#1#2#3{%
- \TP_declare_instance:Nnn \g_tmpa_tlp {#2/#3} }
+\cs_new:Npn \TP_templdecl_declare_tmp_instance:nnnn#1#2#3{%
+ \TP_declare_instance:Nnn \g_tmpa_tl {#2/#3} }
% \end{macrocode}
% \end{macro}
%
@@ -2125,21 +2148,21 @@
% Some extension to |\ShowTemplate| so that we also get to see the
% restrictions if any
% \begin{macrocode}
-\def_new:Npn \ShowTemplate#1#2{
- \io_put_term:x{*******~ Template:~ #1/#2~ *******}
- \io_put_term:x{*}
- \io_put_term:x{*~ Defaults:}
- \io_put_term:x{*}
- \io_put_term:x{\token_to_string:N\TPD>/#1/#2=
+\cs_new_nopar:Npn \ShowTemplate#1#2{
+ \iow_term:x{*******~ Template:~ #1/#2~ *******}
+ \iow_term:x{*}
+ \iow_term:x{*~ Defaults:}
+ \iow_term:x{*}
+ \iow_term:x{\token_to_str:N\TPD>/#1/#2=
\cs_meaning:c{TPD>/#1/#2}}
- \io_put_term:x{*}
- \io_put_term:x{*~ Restrictions:}
- \io_put_term:x{*}
- \io_put_term:x{\token_to_string:N\TPR>/#1/#2=
+ \iow_term:x{*}
+ \iow_term:x{*~ Restrictions:}
+ \iow_term:x{*}
+ \iow_term:x{\token_to_str:N\TPR>/#1/#2=
\cs_meaning:c{TPR>/#1/#2}}
- \io_put_term:x{*}
- \io_put_term:x{*~ Body:}
- \io_put_term:x{*}
+ \iow_term:x{*}
+ \iow_term:x{*~ Body:}
+ \iow_term:x{*}
\cs_show:c {TP>/#1/#2}}
% \end{macrocode}
% \end{macro}
@@ -2147,39 +2170,39 @@
%
% \begin{macro}{\ShowCollectionInstance}
% \begin{macrocode}
-\def_new:Npn \ShowCollectionInstance#1#2#3{
- \io_put_term:x{*******~ Instance:~ <#1>#2/#3~ *******}
- \io_put_term:x{*}
+\cs_new_nopar:Npn \ShowCollectionInstance#1#2#3{
+ \iow_term:x{*******~ Instance:~ <#1>#2/#3~ *******}
+ \iow_term:x{*}
\cs_show:c {<#1>#2/#3}}
-\def_new:Npn \ShowInstance{\ShowCollectionInstance{}}
+\cs_new_nopar:Npn \ShowInstance{\ShowCollectionInstance{}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\TP_templdecl_setup_fakeregister_key:NNn}
% |{setcomand}{privateregister}{key}{internalcode}|
% \begin{macrocode}
-\def_new:Npn \TP_templdecl_setup_fakeregister_key:NNn#1#2#3{
+\cs_new_nopar:Npn \TP_templdecl_setup_fakeregister_key:NNn#1#2#3{
\TP_templdecl_define_key:n{
- \tlist_if_head_eq_meaning:nNTF{##1..}\DelayEvaluation
+ \tl_if_head_eq_meaning:nNTF{##1..}\DelayEvaluation
{
% \end{macrocode}
% In the v0.08 version of \texttt{template.dtx} a
% |\DelayEvaluation| for a faked register would simply be equiv to
-% a |\def:Npn | (code is below commented out). The negative side effect
+% a |\cs_set_nopar:Npn | (code is below commented out). The negative side effect
% of this is that something like |=L| used with |\DelayEvaluation|
% would not allow for calc syntax since it would end up as
-% |\def:Npn |\allowbreak|\foo|\allowbreak|{a+b}|. The code below changes
+% |\cs_set_nopar:Npn |\allowbreak|\foo|\allowbreak|{a+b}|. The code below changes
% this to first assign to a scratch register (at runtime) and then
% do an |\edef|. Could be coded differently to save space (at cost
% of time)
% \begin{macrocode}
-% \toks_put_right:Nn \l_TP_KV_assignments_toks {\def:Npn #3{##1}}
+% \toks_put_right:Nn \l_TP_KV_assignments_toks {\cs_set_nopar:Npn #3{##1}}
% \toks_put_right:Nn \l_TP_KV_assignments_toks
-% {#1#2{##1}\def:Npx #3{\toks_use:N#2}}
- \toks_set:No \l_tmpa_toks {\use_arg_ii:nn ##1}
+% {#1#2{##1}\cs_set_nopar:Npx #3{\toks_use:N#2}}
+ \toks_set:No \l_tmpa_toks {\use_ii:nn ##1}
\toks_put_right:Nx \l_TP_KV_assignments_toks {
\exp_not:n{#1#2}{\toks_use:N \l_tmpa_toks}
- \exp_not:n{ \def:Npx #3{\toks_use:N#2} }
+ \exp_not:n{ \cs_set_nopar:Npx #3{\toks_use:N#2} }
}
}
@@ -2198,18 +2221,18 @@
%
% \begin{macrocode}
{
- \tlist_if_head_eq_meaning:nNTF{##1..}\MultiSelection
+ \tl_if_head_eq_meaning:nNTF{##1..}\MultiSelection
{
\group_begin:
\TP_multiselection_add:nnnnnn#1#2##1
\group_end:
\toks_put_right:Nx\l_TP_KV_assignments_toks
- {\exp_not:n{\def:Npn #3} {\toks_use:N\g_TP_multiselection_toks}}
+ {\exp_not:n{\cs_set_nopar:Npn #3} {\toks_use:N\g_TP_multiselection_toks}}
}
{
#1#2{##1}
\toks_put_right:Nx\l_TP_KV_assignments_toks
- {\exp_not:n{\def:Npn#3} {\toks_use:N#2}}
+ {\exp_not:n{\cs_set_nopar:Npn#3} {\toks_use:N#2}}
}
}
}
@@ -2236,10 +2259,10 @@
% outside.
%
% \begin{macrocode}
-\def_new:Npn \TP_multiselection_add:nnnnnn #1#2#3#4#5#6{
+\cs_new_nopar:Npn \TP_multiselection_add:nnnnnn #1#2#3#4#5#6{
\toks_gset:Nn \g_TP_multiselection_toks {\if_case:w #4}
\clist_map_inline:nn {#5}{
- \tlist_if_head_eq_meaning:nNTF{##1..}\DelayEvaluation
+ \tl_if_head_eq_meaning:nNTF{##1..}\DelayEvaluation
{
\TP_multiselection_add_or_case:n {##1}
}
@@ -2249,7 +2272,7 @@
}
}
\toks_gput_right:Nn \g_TP_multiselection_toks {
- \else: \use_arg_i_after_fi:nw{#6}\fi:
+ \else: \use_i_after_fi:nw{#6}\fi:
}
}
% \end{macrocode}
@@ -2260,14 +2283,12 @@
% No need to worry about where |\or:| is allowed to be added since
% all loops in \LaTeX3 process the item outside conditionals.
% \begin{macrocode}
-\def_new:Npn \TP_multiselection_add_or_case:n #1 {
+\cs_new_nopar:Npn \TP_multiselection_add_or_case:n #1 {
\toks_gput_right:Nn \g_TP_multiselection_toks {
- \or: \use_arg_i_after_orelse:nw{#1}
+ \or: \use_i_after_orelse:nw{#1}
}
}
-\def_new:Npn \TP_multiselection_add_or_case:o {
- \exp_args:No \TP_multiselection_add_or_case:n
-}
+\cs_generate_variant:Nn \TP_multiselection_add_or_case:n {o}
% \end{macrocode}
% \end{macro}
%
@@ -2294,7 +2315,7 @@
% tests that there is a \emph{default} definition
% taken from xinitials.dtx:
% \begin{macrocode}
-\def_new:Npn \IfExistsInstanceTF#1#2{
+\cs_new_nopar:Npn \IfExistsInstanceTF#1#2{
\cs_if_exist:cTF{<>#1/#2}
}
% \end{macrocode}
@@ -2307,13 +2328,13 @@
% really should be. The code below is not better only different( and
% slower).\footnote{fix semantics}
% \begin{macrocode}
-\def:Npn \IfExistsInstanceTF#1#2{
- \TP_let_instance:Nnn \l_tmpa_tlp {#1}{#2}
-% next is not \tlp_if_eq:NNTF but ...FT so done manually
- \if_meaning:NN\l_tmpa_tlp\scan_stop:
- \exp_after:NN\use_arg_ii:nn
+\cs_set_nopar:Npn \IfExistsInstanceTF#1#2{
+ \TP_let_instance:Nnn \l_tmpa_tl {#1}{#2}
+% next is not \tl_if_eq:NNTF but ...FT so done manually
+ \if_meaning:w\l_tmpa_tl\scan_stop:
+ \exp_after:wN\use_ii:nn
\else:
- \exp_after:NN\use_arg_i:nn
+ \exp_after:wN\use_i:nn
\fi:}
% \end{macrocode}
% \end{macro}
@@ -2327,22 +2348,19 @@
% This uses the same code as {T-type} {source-T-name} but adds
% settings from {keyvals}
% \begin{macrocode}
-\def_new:Npn \DeclareRestrictedTemplate#1#2#3#4{
+\cs_new_nopar:Npn \DeclareRestrictedTemplate#1#2#3#4{
% CCC do we need a group here??
- \tlp_set_eq:cc { TPD>/#1/#2 } { TPD>/#1/#3 }
- \tlp_set_eq:cc { TP>/#1/#2 } { TP>/#1/#3 }
-
- \toks_set:Nd \l_TP_KV_assignments_toks
- {\cs:w TPR>/#1/#3\cs_end:}
-
+ \tl_set_eq:cc { TPD>/#1/#2 } { TPD>/#1/#3 }
+ \tl_set_eq:cc { TP>/#1/#2 } { TP>/#1/#3 }
+ \toks_set:Nv \l_TP_KV_assignments_toks { TPR>/ #1 / #3 }
% adds stuff to \l_TP_KV_assignments_toks
\setkeys {\cs:w TPO>/#1/#3\cs_end:}{#4}
- \tlp_set:cx { TPR>/#1/#2 }
+ \tl_set:cx { TPR>/#1/#2 }
{ \toks_use:N \l_TP_KV_assignments_toks }
\cs_if_free:cTF { TPO>/#1/#3 }
- { \tlp_set:cn {TPO>/#1/#2}{#1/#3} }
- { \tlp_set_eq:cc {TPO>/#1/#2}{TPO>/#1/#3} }
+ { \tl_set:cn {TPO>/#1/#2}{#1/#3} }
+ { \tl_set_eq:cc {TPO>/#1/#2}{TPO>/#1/#3} }
}
% \end{macrocode}
% \end{macro}
@@ -2356,23 +2374,19 @@
% Assumption: setkeys fully expands its first argument.
%
% \begin{macrocode}
-\def_new:Npn \TP_instdecl_generate_assignments:nn#1#2 {
+\cs_new_nopar:Npn \TP_instdecl_generate_assignments:nn#1#2 {
% Returns to \l_TP_KV_assignments_toks
% the restrictions
% stored in the TP-structure (at present
% in YAM) of the template #1
-
- \toks_set:Nd \l_TP_default_assignments_toks
+ \exp_args:NNo \toks_set:No \l_TP_default_assignments_toks
{\cs:w TPD>/#1\cs_end:\scan_stop:\scan_stop:}
-
- \toks_set:Nd \l_TP_KV_assignments_toks
- {\cs:w TPR>/#1\cs_end:}
-
+ \toks_set:Nv \l_TP_KV_assignments_toks { TPR>/ #1 }
\setkeys { \cs:w TPO>/#1 \cs_end: }
{ #2 } % adds stuff to \l_TP_KV_assignments_toks
% prepends stuff to \l_TP_KV_assignments_toks :
- \exp_after:NN\TP_instdecl_add_default_recurse:nn
+ \exp_after:wN\TP_instdecl_add_default_recurse:nn
\toks_use:N\l_TP_default_assignments_toks
}
@@ -2383,16 +2397,16 @@
% \begin{macro}{\TP_instdecl_add_default_recurse:nn}
% [ 2001/06/10 Think about doing this properly with explicit plists! --- but
% this means that one has to think about whether or not plists should be
-% implemented as token registers and not as tlps as they are now. ]
+% implemented as token registers and not as tl vars as they are now. ]
% \begin{macrocode}
-\def_new:Npn \TP_instdecl_add_default_recurse:nn#1#2{
+\cs_new_nopar:Npn \TP_instdecl_add_default_recurse:nn#1#2{
\token_if_eq_meaning:NNF #1\scan_stop:
{
\l_tmpa_toks{#2}
- \tlp_set:Nx \l_tmpa_tlp {
+ \tl_set:Nx \l_tmpa_tl {
{\toks_use:N \l_tmpa_toks \toks_use:N \l_TP_KV_assignments_toks}
}
- \l_TP_KV_assignments_toks \l_tmpa_tlp
+ \l_TP_KV_assignments_toks \l_tmpa_tl
\TP_instdecl_add_default_recurse:nn
}
}
@@ -2422,7 +2436,7 @@
% key name, and the last two are the \meta{dimen} registers that
% stores the stretch and shrink components. Assignments are global.
% \begin{macrocode}
-\def_new:Npn \TP_split_finite_skip_value:nnNN #1#2{
+\cs_new_nopar:Npn \TP_split_finite_skip_value:nnNN #1#2{
\skip_split_finite_else_action:nnNN {#1} {
\PackageError{template}{Value~ for~ key~ #2~ contains~ `fil(ll)'}
{Only~ finite~ minus~ or~ plus~ parts~ are~ allowed~ for~ this~ key.}