[latex3-commits] [l3svn] r6935 - Add \NewExpandableDocumentCommand (and Renew and Provide)

noreply at latex-project.org noreply at latex-project.org
Thu Feb 16 20:53:45 CET 2017


Author: bruno
Date: 2017-02-16 20:53:45 +0100 (Thu, 16 Feb 2017)
New Revision: 6935

Modified:
   trunk/l3packages/xparse/testfiles/xparse001.lvt
   trunk/l3packages/xparse/testfiles/xparse001.ptex.tlg
   trunk/l3packages/xparse/testfiles/xparse001.tlg
   trunk/l3packages/xparse/testfiles/xparse001.uptex.tlg
   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:
Add \NewExpandableDocumentCommand (and Renew and Provide)

Expandable commands are not as rare as we had initially thought
so it makes sense to provide a whole set of functions.
The doc could probably do with some words on when expandable
functions are meant to be used.


Modified: trunk/l3packages/xparse/testfiles/xparse001.lvt
===================================================================
--- trunk/l3packages/xparse/testfiles/xparse001.lvt	2017-02-16 19:15:42 UTC (rev 6934)
+++ trunk/l3packages/xparse/testfiles/xparse001.lvt	2017-02-16 19:53:45 UTC (rev 6935)
@@ -364,5 +364,21 @@
     \TYPE { \exp_not:c { test- \foo .... } }
   }
 
+\TEST{Checking~for~existing~expandable~definitions}{
+  \OMIT
+  \DeclareExpandableDocumentCommand \foo { } { }
+  \TIMO
+  \NewExpandableDocumentCommand \foo { } { }
+  \OMIT
+  \cs_undefine:N \foo
+  \TIMO
+  \RenewExpandableDocumentCommand \foo { } { }
+  \OMIT
+  \DeclareExpandableDocumentCommand \foo { } { First~definition }
+  \TIMO
+  \ProvideExpandableDocumentCommand \foo { } { Second~definition }
+  \xparse_show:N \foo
+}
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \END

Modified: trunk/l3packages/xparse/testfiles/xparse001.ptex.tlg
===================================================================
--- trunk/l3packages/xparse/testfiles/xparse001.ptex.tlg	2017-02-16 19:15:42 UTC (rev 6934)
+++ trunk/l3packages/xparse/testfiles/xparse001.ptex.tlg	2017-02-16 19:53:45 UTC (rev 6935)
@@ -1221,3 +1221,45 @@
 not appear between \csname and \endcsname.
 \test- \xparse function is not expandable \__xparse_start_aux:nNNnnn {D...}\foo code {\__xparse_grab_D_trailing:w ..}{{..}}{}....\cs_end: 
 ============================================================
+============================================================
+TEST 20: Checking for existing expandable definitions
+============================================================
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "xparse/command-already-defined"
+! 
+! Command '\foo' already defined!
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...}
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| You have used \NewExpandableDocumentCommand with a command that already has
+| a definition.
+| The existing definition of '\foo' will not be altered.
+|...............................................
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "xparse/command-not-yet-defined"
+! 
+! Command '\foo' not yet defined!
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...}
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| You have used \RenewExpandableDocumentCommand with a command that was never
+| defined.
+| A new command '\foo' will be created.
+|...............................................
+> \foo=macro:->\__xparse_start_expandable:nNNNn {}\foo  \foo code ?{}.
+<recently read> }
+l. ...}
+> \foo code=\long macro:->First definition.
+<recently read> }
+l. ...}
+============================================================

Modified: trunk/l3packages/xparse/testfiles/xparse001.tlg
===================================================================
--- trunk/l3packages/xparse/testfiles/xparse001.tlg	2017-02-16 19:15:42 UTC (rev 6934)
+++ trunk/l3packages/xparse/testfiles/xparse001.tlg	2017-02-16 19:53:45 UTC (rev 6935)
@@ -1217,3 +1217,45 @@
 not appear between \csname and \endcsname.
 \test- \xparse function is not expandable \__xparse_start_aux:nNNnnn {D...}\foo code {\__xparse_grab_D_trailing:w ..}{{..}}{}....\cs_end: 
 ============================================================
+============================================================
+TEST 20: Checking for existing expandable definitions
+============================================================
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "xparse/command-already-defined"
+! 
+! Command '\foo' already defined!
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...}
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| You have used \NewExpandableDocumentCommand with a command that already has
+| a definition.
+| The existing definition of '\foo' will not be altered.
+|...............................................
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "xparse/command-not-yet-defined"
+! 
+! Command '\foo' not yet defined!
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...}
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| You have used \RenewExpandableDocumentCommand with a command that was never
+| defined.
+| A new command '\foo' will be created.
+|...............................................
+> \foo=macro:->\__xparse_start_expandable:nNNNn {}\foo  \foo code ?{}.
+<recently read> }
+l. ...}
+> \foo code=\long macro:->First definition.
+<recently read> }
+l. ...}
+============================================================

Modified: trunk/l3packages/xparse/testfiles/xparse001.uptex.tlg
===================================================================
--- trunk/l3packages/xparse/testfiles/xparse001.uptex.tlg	2017-02-16 19:15:42 UTC (rev 6934)
+++ trunk/l3packages/xparse/testfiles/xparse001.uptex.tlg	2017-02-16 19:53:45 UTC (rev 6935)
@@ -1221,3 +1221,45 @@
 not appear between \csname and \endcsname.
 \test- \xparse function is not expandable \__xparse_start_aux:nNNnnn {D...}\foo code {\__xparse_grab_D_trailing:w ..}{{..}}{}....\cs_end: 
 ============================================================
+============================================================
+TEST 20: Checking for existing expandable definitions
+============================================================
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "xparse/command-already-defined"
+! 
+! Command '\foo' already defined!
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...}
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| You have used \NewExpandableDocumentCommand with a command that already has
+| a definition.
+| The existing definition of '\foo' will not be altered.
+|...............................................
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "xparse/command-not-yet-defined"
+! 
+! Command '\foo' not yet defined!
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...}
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| You have used \RenewExpandableDocumentCommand with a command that was never
+| defined.
+| A new command '\foo' will be created.
+|...............................................
+> \foo=macro:->\__xparse_start_expandable:nNNNn {}\foo  \foo code ?{}.
+<recently read> }
+l. ...}
+> \foo code=\long macro:->First definition.
+<recently read> }
+l. ...}
+============================================================

Modified: trunk/l3packages/xparse/testfiles/xparse004.luatex.tlg
===================================================================
--- trunk/l3packages/xparse/testfiles/xparse004.luatex.tlg	2017-02-16 19:15:42 UTC (rev 6934)
+++ trunk/l3packages/xparse/testfiles/xparse004.luatex.tlg	2017-02-16 19:53:45 UTC (rev 6935)
@@ -650,6 +650,66 @@
 !
 ! LaTeX error: "xparse/not-one-token"
 ! 
+! First argument of '\NewExpandableDocumentCommand' must be a command.
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...  }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| This is a coding error.
+| 
+| The first argument of '\NewExpandableDocumentCommand' should be the document
+| command that will be defined. The provided argument '\foo !' contains more
+| than one token.
+| 
+| LaTeX will ignore this entire definition.
+|...............................................
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "xparse/not-one-token"
+! 
+! First argument of '\RenewExpandableDocumentCommand' must be a command.
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...  }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| This is a coding error.
+| 
+| The first argument of '\RenewExpandableDocumentCommand' should be the
+| document command that will be defined. The provided argument '\foo !'
+| contains more than one token.
+| 
+| LaTeX will ignore this entire definition.
+|...............................................
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "xparse/not-one-token"
+! 
+! First argument of '\ProvideExpandableDocumentCommand' must be a command.
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...  }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| This is a coding error.
+| 
+| The first argument of '\ProvideExpandableDocumentCommand' should be the
+| document command that will be defined. The provided argument '\foo !'
+| contains more than one token.
+| 
+| LaTeX will ignore this entire definition.
+|...............................................
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "xparse/not-one-token"
+! 
 ! First argument of '\GetDocumentCommandArgSpec' must be a command.
 ! 
 ! See the LaTeX3 documentation for further information.
@@ -790,6 +850,66 @@
 !
 ! LaTeX error: "xparse/not-one-token"
 ! 
+! First argument of '\NewExpandableDocumentCommand' must be a command.
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...  }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| This is a coding error.
+| 
+| The first argument of '\NewExpandableDocumentCommand' should be the document
+| command that will be defined. The provided argument 'foo' contains more than
+| one token.
+| 
+| LaTeX will ignore this entire definition.
+|...............................................
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "xparse/not-one-token"
+! 
+! First argument of '\RenewExpandableDocumentCommand' must be a command.
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...  }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| This is a coding error.
+| 
+| The first argument of '\RenewExpandableDocumentCommand' should be the
+| document command that will be defined. The provided argument 'foo' contains
+| more than one token.
+| 
+| LaTeX will ignore this entire definition.
+|...............................................
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "xparse/not-one-token"
+! 
+! First argument of '\ProvideExpandableDocumentCommand' must be a command.
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...  }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| This is a coding error.
+| 
+| The first argument of '\ProvideExpandableDocumentCommand' should be the
+| document command that will be defined. The provided argument 'foo' contains
+| more than one token.
+| 
+| LaTeX will ignore this entire definition.
+|...............................................
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "xparse/not-one-token"
+! 
 ! First argument of '\GetDocumentCommandArgSpec' must be a command.
 ! 
 ! See the LaTeX3 documentation for further information.
@@ -930,6 +1050,66 @@
 !
 ! LaTeX error: "xparse/not-definable"
 ! 
+! First argument of '\NewExpandableDocumentCommand' must be a command.
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...  }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| This is a coding error.
+| 
+| The first argument of '\NewExpandableDocumentCommand' should be the document
+| command that will be defined. The provided argument '##' is a character.
+| Perhaps a backslash is missing?
+| 
+| LaTeX will ignore this entire definition.
+|...............................................
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "xparse/not-definable"
+! 
+! First argument of '\RenewExpandableDocumentCommand' must be a command.
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...  }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| This is a coding error.
+| 
+| The first argument of '\RenewExpandableDocumentCommand' should be the
+| document command that will be defined. The provided argument '##' is a
+| character. Perhaps a backslash is missing?
+| 
+| LaTeX will ignore this entire definition.
+|...............................................
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "xparse/not-definable"
+! 
+! First argument of '\ProvideExpandableDocumentCommand' must be a command.
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...  }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| This is a coding error.
+| 
+| The first argument of '\ProvideExpandableDocumentCommand' should be the
+| document command that will be defined. The provided argument '##' is a
+| character. Perhaps a backslash is missing?
+| 
+| LaTeX will ignore this entire definition.
+|...............................................
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "xparse/not-definable"
+! 
 ! First argument of '\GetDocumentCommandArgSpec' must be a command.
 ! 
 ! See the LaTeX3 documentation for further information.
@@ -975,7 +1155,7 @@
 !
 ! LaTeX error: "xparse/command-already-defined"
 ! 
-! Command ' \? ' already defined!
+! Command '\?' already defined!
 ! 
 ! See the LaTeX3 documentation for further information.
 ! 
@@ -985,7 +1165,7 @@
 |'''''''''''''''''''''''''''''''''''''''''''''''
 | You have used \NewDocumentCommand with a command that already has a
 | definition.
-| The existing definition of ' \? ' will not be altered.
+| The existing definition of '\?' will not be altered.
 |...............................................
 .................................................
 . LaTeX info: "xparse/redefine-command"
@@ -997,6 +1177,27 @@
 . 
 . Redefining command \? with sig. 'm' on line ....
 .................................................
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "xparse/command-already-defined"
+! 
+! Command '\?' already defined!
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...  }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| You have used \NewExpandableDocumentCommand with a command that already has
+| a definition.
+| The existing definition of '\?' will not be altered.
+|...............................................
+.................................................
+. LaTeX info: "xparse/redefine-command"
+. 
+. Redefining command \? with sig. 'm' on line ....
+.................................................
 > \ArgumentSpecification=m.
 <recently read> }
 l. ...  }
@@ -1046,7 +1247,7 @@
 . 
 . Redefining command \foo with sig.
 . '+D<>{####}+G{####}+t*+E{_^}{{1####}{2####}}+l+m+R(){####}+u{...}+v' on line
-. 233.
+. 245.
 .................................................
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 !
@@ -1136,7 +1337,7 @@
 . LaTeX info: "xparse/redefine-command"
 . 
 . Redefining command \foo with sig. 'E{_^}{{##2}{##3}}E{*+}{{##1}}m' on line
-. 267.
+. 279.
 .................................................
 {{\C }{-NoValue-}}{\E }|{\C }{-NoValue-}|\E 
 {\A }{\E }|{{\A }{\E }}{-NoValue-}|\E 
@@ -1169,7 +1370,7 @@
 . LaTeX info: "xparse/redefine-command"
 . 
 . Redefining command \foobar with sig. 'D<>{##2}O{##4##1}mO{##3##5}m' on line
-. 282.
+. 294.
 .................................................
 .................................................
 . LaTeX info: "xparse/define-command"
@@ -1571,7 +1772,7 @@
 . LaTeX info: "xparse/redefine-command"
 . 
 . Redefining command \foo with sig. 'E{^_}{{##2}{\DO WN}}O{####}m' on line
-. 381.
+. 393.
 .................................................
 ({##}{\DO WN})(##)(\A )
 ({\A }{\DO WN})(\A )(\B )

Modified: trunk/l3packages/xparse/testfiles/xparse004.lvt
===================================================================
--- trunk/l3packages/xparse/testfiles/xparse004.lvt	2017-02-16 19:15:42 UTC (rev 6934)
+++ trunk/l3packages/xparse/testfiles/xparse004.lvt	2017-02-16 19:53:45 UTC (rev 6935)
@@ -181,6 +181,9 @@
     \RenewDocumentCommand             { \foo! } { x } { y }
     \ProvideDocumentCommand           { \foo! } { x } { y }
     \DeclareExpandableDocumentCommand { \foo! } { x } { y }
+    \NewExpandableDocumentCommand     { \foo! } { x } { y }
+    \RenewExpandableDocumentCommand   { \foo! } { x } { y }
+    \ProvideExpandableDocumentCommand { \foo! } { x } { y }
     \GetDocumentCommandArgSpec        { \foo! }
     \ShowDocumentCommandArgSpec       { \foo! }
     \DeclareDocumentCommand           { foo } { x } { y }
@@ -188,6 +191,9 @@
     \RenewDocumentCommand             { foo } { x } { y }
     \ProvideDocumentCommand           { foo } { x } { y }
     \DeclareExpandableDocumentCommand { foo } { x } { y }
+    \NewExpandableDocumentCommand     { foo } { x } { y }
+    \RenewExpandableDocumentCommand   { foo } { x } { y }
+    \ProvideExpandableDocumentCommand { foo } { x } { y }
     \GetDocumentCommandArgSpec        { foo }
     \ShowDocumentCommandArgSpec       { foo }
     \DeclareDocumentCommand           { # } { x } { y }
@@ -195,6 +201,9 @@
     \RenewDocumentCommand             { # } { x } { y }
     \ProvideDocumentCommand           { # } { x } { y }
     \DeclareExpandableDocumentCommand { # } { x } { y }
+    \NewExpandableDocumentCommand     { # } { x } { y }
+    \RenewExpandableDocumentCommand   { # } { x } { y }
+    \ProvideExpandableDocumentCommand { # } { x } { y }
     \GetDocumentCommandArgSpec        { # }
     \ShowDocumentCommandArgSpec       { # }
     \DeclareDocumentCommand           { ~\?~ } { m } { y }
@@ -202,6 +211,9 @@
     \RenewDocumentCommand             { ~\?~ } { m } { y }
     \ProvideDocumentCommand           { ~\?~ } { m } { y }
     \DeclareExpandableDocumentCommand { ~\?~ } { m } { y }
+    \NewExpandableDocumentCommand     { ~\?~ } { m } { y }
+    \RenewExpandableDocumentCommand   { ~\?~ } { m } { y }
+    \ProvideExpandableDocumentCommand { ~\?~ } { m } { y }
     \GetDocumentCommandArgSpec        { ~\?~ }
     \ShowDocumentCommandArgSpec       { ~\?~ }
   }

Modified: trunk/l3packages/xparse/testfiles/xparse004.tlg
===================================================================
--- trunk/l3packages/xparse/testfiles/xparse004.tlg	2017-02-16 19:15:42 UTC (rev 6934)
+++ trunk/l3packages/xparse/testfiles/xparse004.tlg	2017-02-16 19:53:45 UTC (rev 6935)
@@ -650,6 +650,66 @@
 !
 ! LaTeX error: "xparse/not-one-token"
 ! 
+! First argument of '\NewExpandableDocumentCommand' must be a command.
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...  }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| This is a coding error.
+| 
+| The first argument of '\NewExpandableDocumentCommand' should be the document
+| command that will be defined. The provided argument '\foo !' contains more
+| than one token.
+| 
+| LaTeX will ignore this entire definition.
+|...............................................
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "xparse/not-one-token"
+! 
+! First argument of '\RenewExpandableDocumentCommand' must be a command.
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...  }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| This is a coding error.
+| 
+| The first argument of '\RenewExpandableDocumentCommand' should be the
+| document command that will be defined. The provided argument '\foo !'
+| contains more than one token.
+| 
+| LaTeX will ignore this entire definition.
+|...............................................
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "xparse/not-one-token"
+! 
+! First argument of '\ProvideExpandableDocumentCommand' must be a command.
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...  }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| This is a coding error.
+| 
+| The first argument of '\ProvideExpandableDocumentCommand' should be the
+| document command that will be defined. The provided argument '\foo !'
+| contains more than one token.
+| 
+| LaTeX will ignore this entire definition.
+|...............................................
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "xparse/not-one-token"
+! 
 ! First argument of '\GetDocumentCommandArgSpec' must be a command.
 ! 
 ! See the LaTeX3 documentation for further information.
@@ -790,6 +850,66 @@
 !
 ! LaTeX error: "xparse/not-one-token"
 ! 
+! First argument of '\NewExpandableDocumentCommand' must be a command.
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...  }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| This is a coding error.
+| 
+| The first argument of '\NewExpandableDocumentCommand' should be the document
+| command that will be defined. The provided argument 'foo' contains more than
+| one token.
+| 
+| LaTeX will ignore this entire definition.
+|...............................................
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "xparse/not-one-token"
+! 
+! First argument of '\RenewExpandableDocumentCommand' must be a command.
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...  }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| This is a coding error.
+| 
+| The first argument of '\RenewExpandableDocumentCommand' should be the
+| document command that will be defined. The provided argument 'foo' contains
+| more than one token.
+| 
+| LaTeX will ignore this entire definition.
+|...............................................
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "xparse/not-one-token"
+! 
+! First argument of '\ProvideExpandableDocumentCommand' must be a command.
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...  }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| This is a coding error.
+| 
+| The first argument of '\ProvideExpandableDocumentCommand' should be the
+| document command that will be defined. The provided argument 'foo' contains
+| more than one token.
+| 
+| LaTeX will ignore this entire definition.
+|...............................................
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "xparse/not-one-token"
+! 
 ! First argument of '\GetDocumentCommandArgSpec' must be a command.
 ! 
 ! See the LaTeX3 documentation for further information.
@@ -930,6 +1050,66 @@
 !
 ! LaTeX error: "xparse/not-definable"
 ! 
+! First argument of '\NewExpandableDocumentCommand' must be a command.
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...  }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| This is a coding error.
+| 
+| The first argument of '\NewExpandableDocumentCommand' should be the document
+| command that will be defined. The provided argument '##' is a character.
+| Perhaps a backslash is missing?
+| 
+| LaTeX will ignore this entire definition.
+|...............................................
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "xparse/not-definable"
+! 
+! First argument of '\RenewExpandableDocumentCommand' must be a command.
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...  }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| This is a coding error.
+| 
+| The first argument of '\RenewExpandableDocumentCommand' should be the
+| document command that will be defined. The provided argument '##' is a
+| character. Perhaps a backslash is missing?
+| 
+| LaTeX will ignore this entire definition.
+|...............................................
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "xparse/not-definable"
+! 
+! First argument of '\ProvideExpandableDocumentCommand' must be a command.
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...  }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| This is a coding error.
+| 
+| The first argument of '\ProvideExpandableDocumentCommand' should be the
+| document command that will be defined. The provided argument '##' is a
+| character. Perhaps a backslash is missing?
+| 
+| LaTeX will ignore this entire definition.
+|...............................................
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "xparse/not-definable"
+! 
 ! First argument of '\GetDocumentCommandArgSpec' must be a command.
 ! 
 ! See the LaTeX3 documentation for further information.
@@ -975,7 +1155,7 @@
 !
 ! LaTeX error: "xparse/command-already-defined"
 ! 
-! Command ' \? ' already defined!
+! Command '\?' already defined!
 ! 
 ! See the LaTeX3 documentation for further information.
 ! 
@@ -985,7 +1165,7 @@
 |'''''''''''''''''''''''''''''''''''''''''''''''
 | You have used \NewDocumentCommand with a command that already has a
 | definition.
-| The existing definition of ' \? ' will not be altered.
+| The existing definition of '\?' will not be altered.
 |...............................................
 .................................................
 . LaTeX info: "xparse/redefine-command"
@@ -997,6 +1177,27 @@
 . 
 . Redefining command \? with sig. 'm' on line ....
 .................................................
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "xparse/command-already-defined"
+! 
+! Command '\?' already defined!
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...  }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| You have used \NewExpandableDocumentCommand with a command that already has
+| a definition.
+| The existing definition of '\?' will not be altered.
+|...............................................
+.................................................
+. LaTeX info: "xparse/redefine-command"
+. 
+. Redefining command \? with sig. 'm' on line ....
+.................................................
 > \ArgumentSpecification=m.
 <recently read> }
 l. ...  }
@@ -1046,7 +1247,7 @@
 . 
 . Redefining command \foo with sig.
 . '+D<>{####}+G{####}+t*+E{_^}{{1####}{2####}}+l+m+R(){####}+u{...}+v' on line
-. 233.
+. 245.
 .................................................
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 !
@@ -1136,7 +1337,7 @@
 . LaTeX info: "xparse/redefine-command"
 . 
 . Redefining command \foo with sig. 'E{_^}{{##2}{##3}}E{*+}{{##1}}m' on line
-. 267.
+. 279.
 .................................................
 {{\C }{-NoValue-}}{\E }|{\C }{-NoValue-}|\E 
 {\A }{\E }|{{\A }{\E }}{-NoValue-}|\E 
@@ -1169,7 +1370,7 @@
 . LaTeX info: "xparse/redefine-command"
 . 
 . Redefining command \foobar with sig. 'D<>{##2}O{##4##1}mO{##3##5}m' on line
-. 282.
+. 294.
 .................................................
 .................................................
 . LaTeX info: "xparse/define-command"
@@ -1571,7 +1772,7 @@
 . LaTeX info: "xparse/redefine-command"
 . 
 . Redefining command \foo with sig. 'E{^_}{{##2}{\DO WN}}O{####}m' on line
-. 381.
+. 393.
 .................................................
 ({##}{\DO WN})(##)(\A )
 ({\A }{\DO WN})(\A )(\B )

Modified: trunk/l3packages/xparse/xparse.dtx
===================================================================
--- trunk/l3packages/xparse/xparse.dtx	2017-02-16 19:15:42 UTC (rev 6934)
+++ trunk/l3packages/xparse/xparse.dtx	2017-02-16 19:53:45 UTC (rev 6935)
@@ -100,6 +100,9 @@
 %   \item \cs{RenewDocumentEnvironment}
 %   \item \cs{ProvideDocumentEnvironment}
 %   \item \cs{DeclareExpandableDocumentCommand}
+%   \item \cs{NewExpandableDocumentCommand}
+%   \item \cs{RenewExpandableDocumentCommand}
+%   \item \cs{ProvideExpandableDocumentCommand}
 %   \item \cs{IfNoValue(TF)}
 %   \item \cs{IfBoolean(TF)}
 % \end{itemize}
@@ -675,18 +678,24 @@
 % if you do not understand when this might be, \emph{do not use these
 % functions}!
 %
-% \begin{function}{\DeclareExpandableDocumentCommand}
+% \begin{function}
+%   {
+%     \DeclareExpandableDocumentCommand ,
+%     \NewExpandableDocumentCommand     ,
+%     \RenewExpandableDocumentCommand   ,
+%     \ProvideExpandableDocumentCommand
+%   }
 %   \begin{syntax}
 %     \cs{DeclareExpandableDocumentCommand}
 %     ~~~~\meta{function} \Arg{arg spec} \Arg{code}
 %   \end{syntax}
-%   This command is used to create a document-level \meta{function},
+%   This family of commands is used to create a document-level \meta{function},
 %   which will grab its arguments in a fully-expandable manner. The
 %   argument specification for the function is given by \meta{arg spec},
 %   and the function will execute \meta{code}. In  general, \meta{code} will
 %   also be fully expandable, although it is possible that this will
 %   not be the case (for example, a function for use in a table might
-%   expand so that \cs{omit} is the first non-expandable token).
+%   expand so that \cs{omit} is the first non-expandable non-space token).
 %
 %   Parsing arguments expandably imposes a number of restrictions on
 %   both the type of arguments that can be read and the error checking
@@ -4028,14 +4037,14 @@
 \__msg_kernel_new:nnnn { xparse } { command-already-defined }
   { Command~'#1'~already~defined! }
   {
-    You~have~used~\NewDocumentCommand
+    You~have~used~#2~
     with~a~command~that~already~has~a~definition. \\
     The~existing~definition~of~'#1'~will~not~be~altered.
   }
 \__msg_kernel_new:nnnn { xparse } { command-not-yet-defined }
   { Command ~'#1'~not~yet~defined! }
   {
-    You~have~used~\RenewDocumentCommand
+    You~have~used~#2~
     with~a~command~that~was~never~defined. \\
     A~new~command~'#1'~will~be~created.
   }
@@ -4266,8 +4275,9 @@
 % \begin{macro}{\RenewDocumentCommand}
 % \begin{macro}{\ProvideDocumentCommand}
 %   The user macros are pretty simple wrappers around the internal ones.
-%   There is however a check that the first argument is a single token
-%   and is definable.
+%   There is however a check that the first argument is a single token,
+%   possibly surrounded by spaces (hence the strange \cs{use:nnn}), and
+%   is definable.
 %    \begin{macrocode}
 \cs_new_protected:Npn \DeclareDocumentCommand #1#2#3
   {
@@ -4280,8 +4290,9 @@
       {
         \cs_if_exist:NTF #1
           {
-            \__msg_kernel_error:nnx { xparse } { command-already-defined }
-              { \token_to_str:N #1 }
+            \__msg_kernel_error:nnxx { xparse } { command-already-defined }
+              { \use:nnn \token_to_str:N #1 { } }
+              { \token_to_str:N \NewDocumentCommand }
           }
           { \@@_declare_cmd:Nnn #1 {#2} {#3} }
       }
@@ -4293,8 +4304,9 @@
         \cs_if_exist:NTF #1
           { \@@_declare_cmd:Nnn #1 {#2} {#3} }
           {
-            \__msg_kernel_error:nnx { xparse } { command-not-yet-defined }
-              { \token_to_str:N #1 }
+            \__msg_kernel_error:nnxx { xparse } { command-not-yet-defined }
+              { \use:nnn \token_to_str:N #1 { } }
+              { \token_to_str:N \RenewDocumentCommand }
           }
       }
   }
@@ -4338,15 +4350,55 @@
 % \end{macro}
 %
 % \begin{macro}{\DeclareExpandableDocumentCommand}
-%   The expandable version of the basic function is essentially the same.
+% \begin{macro}{\NewExpandableDocumentCommand}
+% \begin{macro}{\RenewExpandableDocumentCommand}
+% \begin{macro}{\ProvideExpandableDocumentCommand}
+%   The expandable versions are essentially the same as the basic functions.
 %    \begin{macrocode}
 \cs_new_protected:Npn \DeclareExpandableDocumentCommand #1#2#3
   {
     \@@_check_definable:nNT {#1} \DeclareExpandableDocumentCommand
       { \@@_declare_expandable_cmd:Nnn #1 {#2} {#3} }
   }
+\cs_new_protected:Npn \NewExpandableDocumentCommand #1#2#3
+  {
+    \@@_check_definable:nNT {#1} \NewExpandableDocumentCommand
+      {
+        \cs_if_exist:NTF #1
+          {
+            \__msg_kernel_error:nnxx { xparse } { command-already-defined }
+              { \use:nnn \token_to_str:N #1 { } }
+              { \token_to_str:N \NewExpandableDocumentCommand }
+          }
+          { \@@_declare_expandable_cmd:Nnn #1 {#2} {#3} }
+      }
+  }
+\cs_new_protected:Npn \RenewExpandableDocumentCommand #1#2#3
+  {
+    \@@_check_definable:nNT {#1} \RenewExpandableDocumentCommand
+      {
+        \cs_if_exist:NTF #1
+          { \@@_declare_expandable_cmd:Nnn #1 {#2} {#3} }
+          {
+            \__msg_kernel_error:nnxx { xparse } { command-not-yet-defined }
+              { \use:nnn \token_to_str:N #1 { } }
+              { \token_to_str:N \RenewExpandableDocumentCommand }
+          }
+      }
+  }
+\cs_new_protected:Npn \ProvideExpandableDocumentCommand #1#2#3
+  {
+    \@@_check_definable:nNT {#1} \ProvideExpandableDocumentCommand
+      {
+        \cs_if_exist:NF #1
+          { \@@_declare_expandable_cmd:Nnn #1 {#2} {#3} }
+      }
+ }
 %    \end{macrocode}
 % \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
 %
 % \begin{macro}{\IfBooleanT, \IfBooleanF, \IfBooleanTF}
 %   The logical \meta{true} and \meta{false} statements are just the



More information about the latex3-commits mailing list