[latex3-commits] [l3svn] r7076 - Make xparse e-type give separate arguments (see #226, #331) (breaking change)

noreply at latex-project.org noreply at latex-project.org
Wed Apr 12 19:46:46 CEST 2017


Author: bruno
Date: 2017-04-12 19:46:46 +0200 (Wed, 12 Apr 2017)
New Revision: 7076

Modified:
   trunk/l3packages/xparse/testfiles/xparse004.luatex.tlg
   trunk/l3packages/xparse/testfiles/xparse004.lvt
   trunk/l3packages/xparse/testfiles/xparse004.tlg
   trunk/l3packages/xparse/xparse.dtx
Log:
Make xparse e-type give separate arguments (see #226, #331) (breaking change)

This avoids requiring an auxiliary to use the output of e-type arguments. The
current "e{^_}" has a behaviour similar to the old "k^k_" (but allowing arbitrary
order) but quite different from the previous version of e-type arguments.


Modified: trunk/l3packages/xparse/testfiles/xparse004.luatex.tlg
===================================================================
--- trunk/l3packages/xparse/testfiles/xparse004.luatex.tlg	2017-04-12 16:16:16 UTC (rev 7075)
+++ trunk/l3packages/xparse/testfiles/xparse004.luatex.tlg	2017-04-12 17:46:46 UTC (rev 7076)
@@ -1220,7 +1220,7 @@
 . LaTeX info: "xparse/define-command"
 . 
 . Defining command \foo with sig.
-. 'D<>{####}G{####}t*E{_^}{{1####}{2####}}lmR(){####}u{...}v' on line ....
+. 'D<>{####}G{####}t*E{_^}{{1####}{2####}}lmR(){####}u{...}' on line ....
 .................................................
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 !
@@ -1246,7 +1246,7 @@
 . LaTeX info: "xparse/redefine-command"
 . 
 . Redefining command \foo with sig.
-. '+D<>{####}+G{####}+t*+E{_^}{{1####}{2####}}+l+m+R(){####}+u{...}+v' on line
+. '+D<>{####}+G{####}+t*+E{_^}{{1####}{2####}}+l+m+R(){####}+u{...}' on line
 . 245.
 .................................................
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -1293,8 +1293,8 @@
 .................................................
 . LaTeX info: "xparse/define-command"
 . 
-. Defining command \foo with sig. 'D<>{##2}G{##4##1}E{_^}{{1}{2}}O{##3##5}m'
-. on line ....
+. Defining command \foo with sig.
+. 'D<>{##2}G{##5##1}E{_^}{{1}{2}}O{{##3}{##4}##6}m' on line ....
 .................................................
 *************************************************
 * LaTeX warning: "xparse/optional-mandatory"
@@ -1336,8 +1336,8 @@
 .................................................
 . LaTeX info: "xparse/redefine-command"
 . 
-. Redefining command \foo with sig. 'E{_^}{{##2}{##3}}E{*+}{{##1}}m' on line
-. 279.
+. Redefining command \foo with sig.
+. 'E{_^}{{{##3}{##4}}{##5}}E{*+}{{{##1}{##2}}}m' on line ....
 .................................................
 {{\C }{-NoValue-}}{\E }|{\C }{-NoValue-}|\E 
 {\A }{\E }|{{\A }{\E }}{-NoValue-}|\E 
@@ -1771,7 +1771,7 @@
 .................................................
 . LaTeX info: "xparse/redefine-command"
 . 
-. Redefining command \foo with sig. 'E{^_}{{##2}{\DO WN}}O{####}m' on line
+. Redefining command \foo with sig. 'E{^_}{{##3}{\DO WN}}O{####}m' on line
 . 393.
 .................................................
 ({##}{\DO WN})(##)(\A )

Modified: trunk/l3packages/xparse/testfiles/xparse004.lvt
===================================================================
--- trunk/l3packages/xparse/testfiles/xparse004.lvt	2017-04-12 16:16:16 UTC (rev 7075)
+++ trunk/l3packages/xparse/testfiles/xparse004.lvt	2017-04-12 17:46:46 UTC (rev 7076)
@@ -81,13 +81,13 @@
 \TEST { Basic~e-type~argument~definitions }
   {
     \DeclareDocumentCommand \foo { e { ^ _ } m }
-      { \TYPE { (#1) (#2) } }
+      { \TYPE { ({#1}{#2}) (#3) } }
     \foo { there }
     \foo ^ { up } { here }
     \foo _ { down } { here }
     \foo ^ { up } _ { down } { here }
     \DeclareDocumentCommand \foo { e { ^ _ } }
-      { \TYPE { (#1) } }
+      { \TYPE { ({#1}{#2}) } }
     \foo stop
     \foo ^ { up } stop
     \foo _ { down } stop
@@ -97,19 +97,19 @@
 \TEST { Basic~E-type~argument~definitions }
   {
     \DeclareDocumentCommand \foo { E { ^ _ } { } }
-      { \TYPE { (#1) } }
+      { \TYPE { ({#1}{#2}) } }
     \foo { there }
     \foo ^ { up } { here }
     \foo _ { down } { here }
     \foo ^ { up } _ { down } { here }
     \DeclareDocumentCommand \foo { E { ^ _ } { { UP } } }
-      { \TYPE { (#1) } }
+      { \TYPE { ({#1}{#2}) } }
     \foo { there }
     \foo ^ { up } { here }
     \foo _ { down } { here }
     \foo ^ { up } _ { down } { here }
     \DeclareDocumentCommand \foo { E { ^ _ } { { UP } { DOWN } } }
-      { \TYPE { (#1) } }
+      { \TYPE { ({#1}{#2}) } }
     \foo { there }
     \foo ^ { up } { here }
     \foo _ { down } { here }
@@ -227,21 +227,21 @@
 \TEST { Test~#~in~argument~specification }
   {
     \DeclareDocumentCommand { \foo }
-      { D<>{##} G{##} t* E{_^}{{1##}{2##}} l m R(){##} u{...} v }
-      { \TYPE { #1 | #2 | #3 | #4 | #5 | #6 | #7 | #8 | #9 } }
-    \foo<1>...{A}C...|D|
-    \foo{1}...{A}(B)C...|D|
-    \foo*...{A}(B)C...|D|
-    \foo^1...{A}(B)C...|D|
-    \foo<1>{2}*_3^4...{A}(B)C...|D|
+      { D<>{##} G{##} t* E{_^}{{1##}{2##}} l m R(){##} u{...} }
+      { \TYPE { #1 | #2 | #3 | {#4}{#5} | #6 | #7 | #8 | #9 | D } }
+    \foo<1>...{A}C...
+    \foo{1}...{A}(B)C...
+    \foo*...{A}(B)C...
+    \foo^1...{A}(B)C...
+    \foo<1>{2}*_3^4...{A}(B)C...
     \DeclareDocumentCommand { \foo }
-      { +D<>{##} +G{##} +t* +E{_^}{{1##}{2##}} +l +m +R(){##} +u{...} +v }
-      { \TYPE { #1 | #2 | #3 | #4 | #5 | #6 | #7 | #8 | #9 } }
-    \foo<1>...{A}C...|D|
-    \foo{1}...{A}(B)C...|D|
-    \foo*...{A}(B)C...|D|
-    \foo^1...{A}(B)C...|D|
-    \foo<1>{2}*_3^4...{A}(B)C...|D|
+      { +D<>{##} +G{##} +t* +E{_^}{{1##}{2##}} +l +m +R(){##} +u{...} }
+      { \TYPE { #1 | #2 | #3 | {#4}{#5} | #6 | #7 | #8 | #9 | D } }
+    \foo<1>...{A}C...
+    \foo{1}...{A}(B)C...
+    \foo*...{A}(B)C...
+    \foo^1...{A}(B)C...
+    \foo<1>{2}*_3^4...{A}(B)C...
   }
 
 \TEST { Defaults~referring~to~other~arguments }
@@ -258,8 +258,8 @@
     \margins {a} [1cm] {b}
     \margins [1cm] {a} [2cm] {b}
     \DeclareDocumentCommand {\foo}
-      { D<>{#2} G{#4#1} E{_^}{{1}{2}} O{#3#5} m }
-      { \TYPE { \exp_not:n { #1 | #2 | #3 | #4 | #5 } } }
+      { D<>{#2} G{#5#1} E{_^}{{1}{2}} O{{#3}{#4}#6} m }
+      { \TYPE { \exp_not:n { #1 | #2 | {#3}{#4} | #5 | #6 } } }
     \foo<\A>_{\B}{\C}
     \foo{\A}{\B}
     \foo{\A}[\B]{\C}
@@ -271,7 +271,7 @@
       { \TYPE { \exp_not:n {#1} } }
     \foo{\A}
     \DeclareDocumentCommand {\foo}
-      { E{_^}{{#2}{#3}} E{*+}{{#1}} m } { \TYPE { \exp_not:n { #1 | #2 | #3 } } }
+      { E{_^}{{{#3}{#4}}{#5}} E{*+}{{{#1}{#2}}} m } { \TYPE { \exp_not:n { {#1}{#2} | {#3}{#4} | #5 } } }
     \foo *{\C}  {\E}
     \foo _{\A}  {\E}
     \foo ^{\A} *{\C}  {\E}
@@ -341,7 +341,7 @@
     \foo **a*
     \DeclareDocumentCommand { \foo } { t( r() t) } { \TYPE{|#1|#2|#3|} }
     \foo ((a(b)c))
-    \DeclareDocumentCommand { \foo } { e{_^} s r__ } { \TYPE{|#1|#2|#3|} }
+    \DeclareDocumentCommand { \foo } { e{_^} s r__ } { \TYPE{|{#1}{#2}|#3|#4|} }
     \foo ^{a}____ \foo _a_abc_ \foo *_a_
   }
 
@@ -366,25 +366,25 @@
 \TEST { Expandable~e-type~argument~definitions }
   {
     \DeclareExpandableDocumentCommand \foo { e { ^ _ } m }
-      { \exp_not:n { (#1) (#2) } }
+      { \exp_not:n { ({#1}{#2}) (#3) } }
     \TYPE { \foo { \the re } }
     \TYPE { \foo ^ { \u p } { \he re } }
     \TYPE { \foo _ { \do wn } { \he re } }
     \TYPE { \foo ^ { \u p } _ { \do wn } { \he re } }
     \DeclareExpandableDocumentCommand \foo { E { ^ _ } { { \U P } } m }
-      { \exp_not:n { (#1) (#2) } }
+      { \exp_not:n { ({#1}{#2}) (#3) } }
     \TYPE { \foo { \the re } }
     \TYPE { \foo ^ { \u p } { \he re } }
     \TYPE { \foo _ { \do wn } { \he re } }
     \TYPE { \foo ^ { \u p } _ { \do wn } { \he re } }
     \DeclareExpandableDocumentCommand \foo { E { ^ _ } { { \U P } { \DO WN } } m }
-      { \exp_not:n { (#1) (#2) } }
+      { \exp_not:n { ({#1}{#2}) (#3) } }
     \TYPE { \foo { \the re } }
     \TYPE { \foo ^ { \u p } { \he re } }
     \TYPE { \foo _ { \do wn } { \he re } }
     \TYPE { \foo ^ { \u p } _ { \do wn } { \he re } }
-    \DeclareExpandableDocumentCommand \foo { E { ^ _ } { {#2} { \DO WN } } O{##} m }
-      { \exp_not:n { (#1) (#2) (#3) } }
+    \DeclareExpandableDocumentCommand \foo { E { ^ _ } { {#3} { \DO WN } } O{##} m }
+      { \exp_not:n { ({#1}{#2}) (#3) (#4) } }
     \TYPE { \foo { \A } }
     \TYPE { \foo [ \A ] { \B } }
     \TYPE { \foo ^ { \A } [ \B ] { \C } }

Modified: trunk/l3packages/xparse/testfiles/xparse004.tlg
===================================================================
--- trunk/l3packages/xparse/testfiles/xparse004.tlg	2017-04-12 16:16:16 UTC (rev 7075)
+++ trunk/l3packages/xparse/testfiles/xparse004.tlg	2017-04-12 17:46:46 UTC (rev 7076)
@@ -1220,7 +1220,7 @@
 . LaTeX info: "xparse/define-command"
 . 
 . Defining command \foo with sig.
-. 'D<>{####}G{####}t*E{_^}{{1####}{2####}}lmR(){####}u{...}v' on line ....
+. 'D<>{####}G{####}t*E{_^}{{1####}{2####}}lmR(){####}u{...}' on line ....
 .................................................
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 !
@@ -1246,7 +1246,7 @@
 . LaTeX info: "xparse/redefine-command"
 . 
 . Redefining command \foo with sig.
-. '+D<>{####}+G{####}+t*+E{_^}{{1####}{2####}}+l+m+R(){####}+u{...}+v' on line
+. '+D<>{####}+G{####}+t*+E{_^}{{1####}{2####}}+l+m+R(){####}+u{...}' on line
 . 245.
 .................................................
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -1293,8 +1293,8 @@
 .................................................
 . LaTeX info: "xparse/define-command"
 . 
-. Defining command \foo with sig. 'D<>{##2}G{##4##1}E{_^}{{1}{2}}O{##3##5}m'
-. on line ....
+. Defining command \foo with sig.
+. 'D<>{##2}G{##5##1}E{_^}{{1}{2}}O{{##3}{##4}##6}m' on line ....
 .................................................
 *************************************************
 * LaTeX warning: "xparse/optional-mandatory"
@@ -1336,8 +1336,8 @@
 .................................................
 . LaTeX info: "xparse/redefine-command"
 . 
-. Redefining command \foo with sig. 'E{_^}{{##2}{##3}}E{*+}{{##1}}m' on line
-. 279.
+. Redefining command \foo with sig.
+. 'E{_^}{{{##3}{##4}}{##5}}E{*+}{{{##1}{##2}}}m' on line ....
 .................................................
 {{\C }{-NoValue-}}{\E }|{\C }{-NoValue-}|\E 
 {\A }{\E }|{{\A }{\E }}{-NoValue-}|\E 
@@ -1771,7 +1771,7 @@
 .................................................
 . LaTeX info: "xparse/redefine-command"
 . 
-. Redefining command \foo with sig. 'E{^_}{{##2}{\DO WN}}O{####}m' on line
+. Redefining command \foo with sig. 'E{^_}{{##3}{\DO WN}}O{####}m' on line
 . 393.
 .................................................
 ({##}{\DO WN})(##)(\A )

Modified: trunk/l3packages/xparse/xparse.dtx
===================================================================
--- trunk/l3packages/xparse/xparse.dtx	2017-04-12 16:16:16 UTC (rev 7075)
+++ trunk/l3packages/xparse/xparse.dtx	2017-04-12 17:46:46 UTC (rev 7076)
@@ -179,12 +179,12 @@
 %     |-NoValue-| if not present.
 %   \item[G] As for \texttt{g} but returns \meta{default} if no value
 %     is given: \texttt{G}\marg{default}.
-%   \item[e] An optional set of \emph{embellishments}, each of which requires a
-%     \emph{value}. If a key is not present, |-NoValue-| is returned.
-%     The returned data is a token list comprising one braced entry per key,
-%     ordered as for the key list in the argument specification.  Given as
-%     \texttt{e}\marg{tokens}.  All \meta{tokens} must be distinct.
-%     \emph{This is an experimental type}.
+%   \item[e] A set of optional \emph{embellishments}, each of which
+%     requires a \emph{value}: \texttt{e}\marg{tokens}.  If an
+%     embellishment is not present, |-NoValue-| is returned.  Each
+%     embellishment gives one argument, ordered as for the list of
+%     \meta{tokens} in the argument specification.  All \meta{tokens}
+%     must be distinct.  \emph{This is an experimental type}.
 %   \item[E] As for \texttt{e} but returns one or more \meta{defaults}
 %     if values are not given: \texttt{E}\marg{tokens}\marg{defaults}. See
 %     Section~\ref{sec:embellishment} for more details.
@@ -828,9 +828,10 @@
 % \end{variable}
 %
 % \begin{variable}{\l_@@_current_arg_int}
-%   The number of the current argument being set up: this is used for creating
-%   the expandable auxiliary functions, and also to indicate if all arguments
-%   are \texttt{m}-type.
+%   The number of the current argument being set up: this is used to
+%   make sure there are at most 9 arguments, then for creating the
+%   expandable auxiliary functions and knowing how many arguments the
+%   code function should take.
 %    \begin{macrocode}
 \int_new:N \l_@@_current_arg_int
 %    \end{macrocode}
@@ -1292,7 +1293,7 @@
 % \end{macro}
 %
 % \begin{macro}{\@@_defaults:}
-% \begin{macro}[aux]{\@@_defaults_def:, \@@_defaults_def:nn, \@@_defaults_def:nnn, \@@_defaults_def_aux:nn}
+% \begin{macro}[aux]{\@@_defaults_def:, \@@_defaults_def:nn, \@@_defaults_def:nnn}
 % \begin{macro}[aux]{\@@_defaults_aux:,  \@@_defaults_error:w}
 %   First construct \cs{@@_tmp:w} (see below) that will receive
 %   the arguments found so far and determine default values for any
@@ -1332,13 +1333,7 @@
 %   |{#|\meta{arg number}|}| for arguments found in the input (whose
 %   default will not be used) and otherwise
 %   |{|\cs{exp_not:n}\Arg{default}|}| for arguments whose default will
-%   be used.  The case of \texttt{E}-type arguments, detected by
-%   \cs{tl_if_head_is_group:nTF}, is special because we may need to
-%   partly use an argument found in the input and partly some default.
-%   This case is delayed until \cs{@@_tmp:w} is called: then we
-%   map through the original argument and its corresponding list of
-%   defaults; for each item (corresponding to one embellishment) if a
-%   value has already been found use it otherwise use the default.
+%   be used.
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_defaults_def:
   {
@@ -1357,36 +1352,18 @@
   }
 \cs_new_protected:Npn \@@_defaults_def:nnn #1#2#3
   {
-    \tl_if_head_is_group:nTF {#3}
+    \tl_put_right:Nx \l_@@_tmpa_tl
       {
-        \tl_put_right:Nn \l_@@_tmpa_tl
-          {
+        {
+          \exp_not:N \exp_not:n
             {
-              \exp_args:Nf \@@_tl_mapthread_function:nnN
-                { \tl_item:Nn \l_@@_args_tl {#1} }
-                {#3}
-                \@@_defaults_def_aux:nn
+              \@@_if_no_value:nTF {#2}
+                { \exp_not:o {#3} }
+                { \exp_not:n { ## #1 } }
             }
-          }
+        }
       }
-      {
-        \@@_if_no_value:nTF {#2}
-          {
-            \tl_put_right:Nx \l_@@_tmpa_tl
-              { { \exp_not:N \exp_not:n { \exp_not:o {#3} } } }
-          }
-          {
-            \tl_put_right:Nn \l_@@_tmpa_tl
-              { { \exp_not:n { ## #1 } } }
-          }
-      }
   }
-\cs_new:Npn \@@_defaults_def_aux:nn #1#2
-  {
-    \@@_if_no_value:nTF {#1}
-      { { \exp_not:n {#2} } }
-      { { \exp_not:n {#1} } }
-  }
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
@@ -1442,7 +1419,6 @@
 % \begin{macro}[EXP,aux]{\@@_end_expandable_defaults:nnnNNn}
 % \begin{macro}[EXP,aux]{\@@_end_expandable_defaults:nnw}
 % \begin{macro}[EXP,aux]{\@@_end_expandable_defaults:nw}
-% \begin{macro}[EXP,aux]{\@@_end_expandable_defaults_E:nnw}
 %   Followed by a function |#1| to determine default values (or |?| if
 %   there are no defaults), the code
 %   |#2|, arguments that have been grabbed, then \cs{q_@@} and two generic
@@ -1485,29 +1461,10 @@
   }
 \cs_new:Npn \@@_end_expandable_defaults:nnw #1#2
   {
-    \tl_if_head_is_group:nTF {#1}
-      {
-        \@@_end_expandable_defaults_E:nnw { }
-          #1 \q_nil \q_mark
-          #2 \q_nil
-      }
-      {
-        \@@_if_no_value:nTF {#2}
-          { \exp_args:No \@@_end_expandable_defaults:nw {#1} }
-          { \@@_end_expandable_defaults:nw {#2} }
-      }
+    \@@_if_no_value:nTF {#2}
+      { \exp_args:No \@@_end_expandable_defaults:nw {#1} }
+      { \@@_end_expandable_defaults:nw {#2} }
   }
-\cs_new:Npn \@@_end_expandable_defaults_E:nnw #1#2#3 \q_mark #4
-  {
-    \quark_if_nil:nTF {#2}
-      { \@@_end_expandable_defaults:nw {#1} }
-      {
-        \@@_if_no_value:nTF {#4}
-          { \@@_end_expandable_defaults_E:nnw { #1 {#2} } }
-          { \@@_end_expandable_defaults_E:nnw { #1 {#4} } }
-        #3 \q_mark
-      }
-  }
 \cs_new:Npn \@@_end_expandable_defaults:nw
     #1#2 \@@_end_expandable_defaults:nnnNNn #3
   { #2 \@@_end_expandable_defaults:nnnNNn { #3 {#1} } }
@@ -1518,7 +1475,6 @@
 % \end{macro}
 % \end{macro}
 % \end{macro}
-% \end{macro}
 %
 % \subsection{Normalizing the argument specifications}
 %
@@ -1715,7 +1671,9 @@
 %   forbidden types for expandable commands.  For \texttt{E}-type
 %   require that there is at least one embellishment, that each one is a
 %   single token, and that there aren't more optional arguments than
-%   embellishments.  Then store the data in \cs{l_@@_arg_spec_tl}, and
+%   embellishments; also remember that each embellishment counts as one
+%   argument for \cs{l_@@_current_arg_int}.  Then in each case
+%   store the data in \cs{l_@@_arg_spec_tl}, and
 %   for later checks store in \cs{l_@@_last_delimiters_tl} the tokens
 %   whose presence determines whether there is an optional argument (for
 %   braces store |{}|, seen later as an empty delimiter).
@@ -1741,6 +1699,7 @@
     \@@_add_arg_spec:n { E {#1} {#2} }
     \tl_put_right:Nn \l_@@_last_delimiters_tl {#1}
     \bool_set_false:N \l_@@_grab_expandably_bool
+    \int_add:Nn \l_@@_current_arg_int { \tl_count:n {#1} - 1 }
     \@@_normalize_arg_spec_loop:n
   }
 \cs_new_protected:Npn \@@_normalize_E_unique_check:w #1#2 \q_stop
@@ -1993,7 +1952,6 @@
 \cs_new_protected:Npn \@@_prepare_signature_bypass:N #1
   {
     \quark_if_recursion_tail_stop:N #1
-    \int_incr:N \l_@@_current_arg_int
     \use:c
       {
          @@_add
@@ -2015,11 +1973,12 @@
 % type.  All of the functions then call the loop function
 % \cs{@@_prepare_signature:N}.  Default values of arguments are
 % collected by \cs{@@_add_default:n} rather than being stored with the
-% argument.
+% argument; this function and \cs{@@_add_default:} are also responsible
+% for keeping track of \cs{l_@@_current_arg_int}.
 %
 % \begin{macro}{\@@_add_type_+:w}
-%   Making the next argument long means setting the flag and knocking one back
-%   off the total argument count. The \texttt{m} arguments are recorded here as
+%   Making the next argument long means setting the flag. The \texttt{m}
+%   arguments are recorded here as
 %   this has to be done for every case where there is then a long argument.
 %    \begin{macrocode}
 \cs_new_protected:cpn { @@_add_type_+:w }
@@ -2027,7 +1986,6 @@
     \@@_flush_m_args:
     \bool_set_true:N \l_@@_long_bool
     \bool_set_true:N \l_@@_prefixed_bool
-    \int_decr:N \l_@@_current_arg_int
     \@@_prepare_signature_bypass:N
   }
 %    \end{macrocode}
@@ -2044,7 +2002,6 @@
     \@@_flush_m_args:
     \bool_set_true:N \l_@@_prefixed_bool
     \bool_set_true:N \l_@@_process_some_bool
-    \int_decr:N \l_@@_current_arg_int
     \tl_put_left:Nn \l_@@_process_one_tl { {#1} }
     \@@_prepare_signature_bypass:N
   }
@@ -2214,7 +2171,7 @@
 %   the signature is done here. For mandatory arguments, the only question
 %   is whether to add a long grabber. For optional arguments, there is
 %   also a check to see if any mandatory arguments are still to be added.
-%   This is used to determine whether to skip spaces or not where
+%   This is used to determine whether to skip spaces or not when
 %   searching for the argument.
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_add_grabber_mandatory:N #1
@@ -2253,45 +2210,39 @@
 % \end{macro}
 %
 % \begin{macro}{\@@_add_default:n, \@@_add_default:, \@@_add_default_E:nn}
-% \begin{macro}[aux]{\@@_add_default_E_aux:n}
 %   Store the default value of an argument, or rather code that gives
 %   that default value (it may involve other arguments).  This is
 %   \cs{c_@@_no_value_tl} for arguments with no actual default or with
-%   default |-NoValue-|; \cs{prg_do_nothing:} followed by a default
-%   value for most others, and a token list of braced arguments for
-%   \texttt{E}-type arguments.  For \texttt{E}-type arguments, pad the
-%   defaults |#2| with some |{-NoValue-}| until there are as many as
-%   embellishments~|#1|.  These functions are also used when defining
-%   expandable commands.
+%   default |-NoValue-|; and (in a brace group) \cs{prg_do_nothing:}
+%   followed by a default value for others.  For \texttt{E}-type
+%   arguments, pad the defaults |#2| with some \cs{c_@@_no_value_tl}
+%   until there are as many as embellishments~|#1|.  These functions are
+%   also used when defining expandable commands.
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_add_default:n #1
   {
     \@@_if_no_value:nTF {#1}
       { \@@_add_default: }
       {
+        \int_incr:N \l_@@_current_arg_int
         \bool_set_true:N \l_@@_defaults_bool
         \tl_put_right:Nn \l_@@_defaults_tl { { \prg_do_nothing: #1 } }
       }
   }
 \cs_new_protected:Npn \@@_add_default:
-  { \tl_put_right:Nn \l_@@_defaults_tl { \c_@@_no_value_tl } }
+  {
+    \int_incr:N \l_@@_current_arg_int
+    \tl_put_right:Nn \l_@@_defaults_tl { \c_@@_no_value_tl }
+  }
 \cs_new_protected:Npn \@@_add_default_E:nn #1#2
   {
-    \bool_set_true:N \l_@@_defaults_bool
-    \tl_put_right:Nx \l_@@_defaults_tl
-      {
-        {
-          \tl_map_function:nN {#2} \@@_add_default_E_aux:n
-          \prg_replicate:nn
-            { \tl_count:n {#1} - \tl_count:n {#2} }
-            { { \c_@@_no_value_tl } }
-        }
-      }
+    \tl_map_function:nN {#2} \@@_add_default:n
+    \prg_replicate:nn
+      { \tl_count:n {#1} - \tl_count:n {#2} }
+      { \@@_add_default: }
   }
-\cs_new:Npn \@@_add_default_E_aux:n #1 { \exp_not:n { {#1} } }
 %    \end{macrocode}
 % \end{macro}
-% \end{macro}
 %
 % \subsection{Setting up expandable types}
 %
@@ -2310,7 +2261,6 @@
 \cs_new_protected:cpn { @@_add_expandable_type_+:w }
   {
     \bool_set_true:N \l_@@_long_bool
-    \int_decr:N \l_@@_current_arg_int
     \@@_prepare_signature:N
   }
 %    \end{macrocode}
@@ -2377,7 +2327,7 @@
 %   the auxiliary and the token in \cs{l_@@_tmpb_tl}, before appending
 %   the whole set of these pairs to the signature, and an equal number
 %   of |-NoValue-| markers (regardless of the default values of
-%   arguments).
+%   arguments).  Set the current argument appropriately.
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_add_expandable_type_E:w #1#2
   {
@@ -2766,18 +2716,14 @@
     \tl_set:Nn \l_@@_signature_tl {#2}
     \cs_set_protected:Npn \@@_grab_E_finalise:
       {
-        \tl_clear:N \l_@@_tmpa_tl
         \tl_map_inline:nn {#1}
           {
             \prop_get:NnNF \l_@@_tmp_prop {####1} \l_@@_tmpb_tl
               { \tl_set_eq:NN \l_@@_tmpb_tl \c_@@_no_value_tl }
-            \tl_set:Nx \l_@@_tmpa_tl
-              {
-                \exp_not:V \l_@@_tmpa_tl
-                { \exp_not:V \l_@@_tmpb_tl }
-              }
+            \tl_put_right:Nx \l_@@_args_tl
+              { { \exp_not:V \l_@@_tmpb_tl } }
           }
-        \@@_add_arg:V \l_@@_tmpa_tl
+        \l_@@_signature_tl \@@_run_code:
       }
     \@@_grab_E_loop:nnN {#4} { } #1 \q_recursion_tail \q_recursion_stop
   }
@@ -3570,7 +3516,7 @@
 \cs_new:Npn \@@_expandable_grab_E_find:nnw #1#2#3 \q_nil #4 \q_@@ #5#6#7#8
   { \@@_expandable_grab_E_aux:w {#1} { #2 {#8} #3 } #4 \q_@@ #5 #6 #7 }
 \cs_new:Npn \@@_expandable_grab_E_end:nnw #1#2#3 \q_@@ #4#5#6
-  { #3 {#2} \q_@@ #4 #5 {#1} }
+  { #3 #2 \q_@@ #4 #5 {#1} }
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}



More information about the latex3-commits mailing list