summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3kernel/l3expan.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-10-10 21:52:54 +0000
committerKarl Berry <karl@freefriends.org>2011-10-10 21:52:54 +0000
commit26a0070af35fa5652128c74fa1f126ec51def209 (patch)
treec3cb194fd4cc2dc13141e39c561dc5bc5d0b7a83 /Master/texmf-dist/source/latex/l3kernel/l3expan.dtx
parent4d055293335b5b39f55edeff0c28700ebc2486eb (diff)
l3kernel 2900 (10oct11)
git-svn-id: svn://tug.org/texlive/trunk@24256 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3expan.dtx')
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3expan.dtx79
1 files changed, 43 insertions, 36 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3expan.dtx b/Master/texmf-dist/source/latex/l3kernel/l3expan.dtx
index ee3d43b91b9..7aada65f41b 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3expan.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3expan.dtx
@@ -35,7 +35,7 @@
%
%<*driver|package>
\RequirePackage{l3names}
-\GetIdInfo$Id: l3expan.dtx 2812 2011-09-12 09:19:26Z bruno $
+\GetIdInfo$Id: l3expan.dtx 2896 2011-10-09 20:36:50Z joseph $
{L3 Experimental argument expansion}
%</driver|package>
%<*driver>
@@ -115,7 +115,7 @@
%
% \section{Methods for defining variants}
%
-% \begin{function}{\cs_generate_variant:Nn}
+% \begin{function}[updated = 2011-09-15]{\cs_generate_variant:Nn}
% \begin{syntax}
% \cs{cs_generate_variant:Nn} \meta{parent control sequence} \Arg{variant argument specifiers}
% \end{syntax}
@@ -1188,8 +1188,8 @@
% shuffle is used to ensure that |#2| can be multiple tokens.
% \begin{macrocode}
\cs_new:Npn \exp_last_two_unbraced:Noo #1#2#3
- { \exp_after:wN \exp_last_two_unbraced_aux:nnN \exp_after:wN {#3} {#2} #1 }
-\cs_new:Npn \exp_last_two_unbraced_aux:nnN #1#2#3
+ { \exp_after:wN \exp_last_two_unbraced_aux:noN \exp_after:wN {#3} {#2} #1 }
+\cs_new:Npn \exp_last_two_unbraced_aux:noN #1#2#3
{ \exp_after:wN #3 #2 #1 }
% \end{macrocode}
% \end{macro}
@@ -1233,11 +1233,14 @@
% \begin{macro}[aux]{\cs_generate_variant_aux:nnNNn}
% \begin{macro}[aux]{\cs_generate_variant_aux:Nnnw}
% \begin{macro}[aux]{\cs_generate_variant_aux:NNn}
-% \begin{macro}[aux]{\cs_generate_variant_aux:N}
% \begin{arguments}
% \item Base form of a function; \emph{e.g.},~|\tl_set:Nn|
% \item One or more variant argument specifiers; e.g., |{Nx,c,cx}|
% \end{arguments}
+% Test whether the base function is protected or not
+% and define \cs{cs_tmp:w} as either \cs{cs_new_nopar:Npx} or
+% \cs{cs_new_protected_nopar:Npx}, then used to define all the
+% variants.
% Split up the original base function to grab its name and signature
% consisting of $k$ letters. Then we wish to iterate through the list
% of variant argument specifiers, and for each one construct a new
@@ -1249,6 +1252,7 @@
\cs_new_protected:Npn \cs_generate_variant:Nn #1
{
\chk_if_exist_cs:N #1
+ \cs_generate_variant_aux:N #1
\cs_split_function:NN #1 \cs_generate_variant_aux:nnNNn
#1
}
@@ -1266,9 +1270,9 @@
% In our example, we wanted to discard the first two letters of the
% base signature because the variant form started with |cc|. This is
% the same as putting first |cc| in the signature and then
-% |\use_none:nn| followed by the base signature |NNn|. We therefore
-% call a small loop that outputs an |n| for each letter in the variant
-% signature and use this to call the correct |\use_none:| variant.
+% |\use_none:nn| followed by the base signature |NNn|. Depending on
+% the number of characters in |#4|, the relevant \cs{use_none:n\ldots{}n}
+% is called.
%
% Firstly though, we check whether to terminate the loop.
% Then build the variant function once, to avoid repeating this
@@ -1281,7 +1285,23 @@
\fi:
\exp_args:NNc \cs_generate_variant_aux:NNn
#1
- { #2 : #4 \use:c { use_none: \cs_generate_variant_aux:N #4 ? } #3 }
+ {
+ #2 : #4
+ \exp_after:wN \use_i_delimit_by_q_stop:nw
+ \use_none:nnnnnnnnn #4
+ \use_none:nnnnnnnnn
+ \use_none:nnnnnnnn
+ \use_none:nnnnnnn
+ \use_none:nnnnnn
+ \use_none:nnnnn
+ \use_none:nnnn
+ \use_none:nnn
+ \use_none:nn
+ \use_none:n
+ { }
+ \q_stop
+ #3
+ }
{#4}
\cs_generate_variant_aux:Nnnw #1 {#2} {#3}
}
@@ -1295,8 +1315,7 @@
{
\cs_if_free:NTF #2
{
- \cs_generate_variant_aux:NNpx #1 #2
- { \exp_not:c { exp_args:N #3 } \exp_not:N #1 }
+ \cs_tmp:w #2 { \exp_not:c { exp_args:N #3 } \exp_not:N #1 }
\cs_generate_internal_variant:n {#3}
}
{
@@ -1309,25 +1328,12 @@
}
}
% \end{macrocode}
-% The small loop for defining the required number of |n|s. Break when
-% seeing a |?|.
-% \begin{macrocode}
-\cs_new:Npn \cs_generate_variant_aux:N #1
- {
- \if:w ? #1
- \exp_after:wN \use_none:nn
- \fi:
- n
- \cs_generate_variant_aux:N
- }
-% \end{macrocode}
-% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
-%
-% \begin{macro}[aux]{\cs_generate_variant_aux:NNpx}
+%
+% \begin{macro}[aux]{\cs_generate_variant_aux:N}
% \begin{macro}[aux]{\cs_generate_variant_aux:w}
% The idea here is to pick up protected parent functions, using the
% nature of the meaning string that they generate. The test here is
@@ -1348,18 +1354,19 @@
\tex_lowercase:D
{
\group_end:
- \cs_new_nopar:Npn \cs_generate_variant_aux:NNpx #1
+ \cs_new_nopar:Npn \cs_generate_variant_aux:N #1
{
\exp_after:wN \cs_generate_variant_aux:w
- \token_to_meaning:N #1 ? PROTECTEZ \q_stop
+ \token_to_meaning:N #1
+ \q_mark \cs_new_protected_nopar:Npx
+ ? PROTECTEZ
+ \q_mark \cs_new_nopar:Npx
+ \q_stop
}
- \cs_new:Npn \cs_generate_variant_aux:w #1 ? PROTECTEZ #2 \q_stop
+ \cs_new:Npn \cs_generate_variant_aux:w
+ #1 ? PROTECTEZ #2 \q_mark #3 #4 \q_stop
{
- \if_catcode:w a \etex_detokenize:D \exp_after:wN {#1} a
- \exp_after:wN \cs_new_protected_nopar:Npx
- \else:
- \exp_after:wN \cs_new_nopar:Npx
- \fi:
+ \cs_set_eq:NN \cs_tmp:w #3
}
}
% \end{macrocode}
@@ -1378,7 +1385,7 @@
{
\cs_new:cpx { exp_args:N #1 }
{ \cs_generate_internal_variant_aux:N #1 : }
- }
+ }
}
% \end{macrocode}
% This command grabs char by char outputting |\::#1| (not expanded
@@ -1389,7 +1396,7 @@
\cs_new:Npn \cs_generate_internal_variant_aux:N #1
{
\exp_not:c { :: #1 }
- \if_meaning:w #1 :
+ \if_meaning:w : #1
\exp_after:wN \use_none:n
\fi:
\cs_generate_internal_variant_aux:N