Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by h1439878.stratoserver.net (8.14.4/8.14.4/Debian-2ubuntu2.1) with ESMTP id u340BtIk015910 for ; Mon, 4 Apr 2016 02:11:58 +0200 Received: from relay.uni-heidelberg.de ([129.206.100.212]) by mx-ha.gmx.net (mxgmx002) with ESMTPS (Nemesis) id 0LiCKx-1bZMAK0A2F-00nQLh for ; Mon, 04 Apr 2016 02:11:47 +0200 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [129.206.100.94]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id u3409k0j011694 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 4 Apr 2016 02:09:47 +0200 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [127.0.0.1]) by listserv.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id u33M1364010937; Mon, 4 Apr 2016 02:09:46 +0200 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 13517487 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Mon, 4 Apr 2016 02:09:44 +0200 Received: from relay.uni-heidelberg.de (relay.uni-heidelberg.de [129.206.100.212]) by listserv.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id u3409i8n019724 for ; Mon, 4 Apr 2016 02:09:44 +0200 Received: from smtp4-g21.free.fr (smtp4-g21.free.fr [212.27.42.4]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id u3409c7Z011632 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 4 Apr 2016 02:09:41 +0200 Received: from [IPv6:2a01:e35:2e92:63f0:fa16:54ff:fef7:e1a8] (unknown [IPv6:2a01:e35:2e92:63f0:fa16:54ff:fef7:e1a8]) (Authenticated sender: frnchfrgg) by smtp4-g21.free.fr (Postfix) with ESMTPSA id 288D54C8025 for ; Mon, 4 Apr 2016 02:05:21 +0200 (CEST) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.6.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <5701B0C1.9080407@free.fr> Date: Mon, 4 Apr 2016 02:09:37 +0200 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: "Julien RIVAUD (_FrnchFrgg_)" Subject: Bug in xparse r, or R, or d or D argument specifiers To: LATEX-L@LISTSERV.UNI-HEIDELBERG.DE Precedence: list List-Help: , List-Unsubscribe: List-Subscribe: List-Owner: List-Archive: Envelope-To: X-GMX-Antispam: 0 (Mail was not recognized as spam); Detail=V3; X-GMX-Antivirus: 0 (no virus found) X-UI-Filterresults: notjunk:1;V01:K0:N2ONINZ/gbo=:TzmllefZYysFVcmHV57b7d1qC6 wo7mxtrcjNSe4xBQayGPcZ2Dw5tvly9kRXrPkmgB3VaiS5vteHCfmG2uFKBMvf5E4VUQ6v253 pc9/TJYnzaYPr+S24+nQKeopmC6fOvnmxjTLUYF9PvFHU79ODQwpW55Z5iavO7nlYL+XbbBh9 bppD0EdIllABkn7oUpHxgoIthxsmv+5jdWSCS1e4RGRICwKhWiw/nuNCxfZB5DWUv00qfMMb5 As0zks14eVZlc8HU9h/CLeoYcGqOk7J2B1rcKyv2nz6yMBUuhGv47JBGKRkn3JvjSKkhgtMy7 k31yEzEh6iZL2aaHrgwou+w4YMaa2al690boV02C6WbCVN5m469DVnKO/RzhATPJDYrqFCT9j lL3V4+BjsthBJdWV/PFR1qQwIKbJPH+Fzov/QJKn9Vf07lkeStFGZF8rgeC95bnWaUUs3bMsN pcuKqn6B5lXRDE2njt1c4eTYq6cHJG4rvOdctBh44xJC+0txARXoWLsIaAG/RnZEMV/WL5b8X jytltraFow3vbjvvM8uQjvr5g8QWvhDLqrdLzNoCIr/TzYonQ9PpiPszrM1PcrhY2sGxr3NTH UyDfyhka7YI5eIXL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scW8Y=:qPy8jwjTdJSUTDNyjrVBH4brsVwxR8R+ASez8YKvb9E= X-UI-Out-Filterresults: notjunk:1;V01:K0:Js7j15AtaTg=:Qxl2ad2a9+50ecQgAZY2bm t3tFB2GMIDDeAceMyt025gMMJAeazK2CGzJ368ER9+O9jHNYDBpSGKeXLCRpdJdMU1ksGlAJ8 5Y0OdZj4gpLzW/RjZfzqbj4MeTtAwhNYLBpvdswx5gVCw9pu9EpS0jYgC/yyU2k9RRbdOk48e zcwxwTcquIwZqj96DwcHKf1sHKhvlfGxVkk4clixKELxCc6bEKOzMMpTiJPsvgsFCiBnmZSek XyG+u+CNEBB5IrYqxfY4+3TiV7rYIbk/UZLslxF19xa7h59eSTAJAs5MzKlOtbORUwOSANegY R7fIZSTiPn2/4+BWxo/ZTYuwkHJBO+CG6gcVDoecV95mvHyfTWk7c52N+eyjFkbnS4+j2FFpA +HyUf/P9hwqpzYOMMntOKe5VO9RD7Rv3Dra8zdUsQ0n4wS8aNzxt+MD4FDXzMbKkOeijxgZCb Jffhpz8eWe/A9Xc84eJ0sXqdZvJQzS+1F9ntXgPT8xxI41Q90psPHJ6W8bmCSLvIx0nqU7KDT 5us8liCXvUT24mZLnhYIWnUabGWToVFd5/CqKn5y00Q X-Scanned-By: MIMEDefang 2.71 on 85.214.41.38 Status: R X-Status: X-Keywords: X-UID: 7919 Hello, A command created with \NewDocumentCommand \foo { r\OPEN\CLOSE } { } seems to work fine, and grabs correctly its argument (even when there is nesting involved), but leaves OPEN at the beginning of the argument. The problem is in \__xparse_grab_D_aux:NNnN where you do: \token_if_eq_catcode:NNTF + #1 { } { \exp_after:wN \l__xparse_fn_tl \token_to_str:N #1 } But of course \token_to_str:N #1 is several characters long. Suppose now that there was no nesting, i.e. we used \foo\OPEN hello\CLOSE. Then \l__xparse_fn_tl goes to \tl_if_blank:oTF { \use_none:n ####1 } { \__xparse_add_arg:o { \use_none:n ####1 } } { \str_if_eq_x:nnTF { \exp_not:o { \use_none:n ####1 } } { { \exp_not:o { \use_ii:nnn ####1 \q_nil } } } { \__xparse_add_arg:o { \use_ii:nn ####1 } } { \__xparse_add_arg:o { \use_none:n ####1 } } } #3 \l__xparse_args_tl where the blank test cannot succeed (####1 is \OPEN hello where \ is a letter so \use_none:n will only gobble that), and the \str_if_eq_x is also false, because \use_none:n ####1 gives OPEN hello (all catcode 12) and \use_ii:nnn ####1 \q_nil gives OEN hello\q_nil (all catcode 12) As a side note, I don't understand what this test is about: it can be true only when ####1 is two tokens, so only one token, and I didn't find a situation where \use_none:n didn't cut it (I tried loosing braces prevention, or loosing space prevention, I never made the test return true *and* the \use_none:n call be wrong). Of course here it doesn't matter, the many letters of the opening token make these fine mechanics go awry. So we call \__xparse_add_arg:o { \use_none:n ####1 }, so \__xparse_add_arg:n {OPEN hello} where it should have been \__xparse_add_arg:n {hello} Of course, you could decide that control sequences don't count as tokens in this case and update the documentation (as for me, I was sometimes bitten[1] by the restriction on single tokens for delimited arguments, so you see towards where I'm leaning). Sorry for the confuse message, it is far too late here for steady thoughts, and English is not my mother tongue Cheers, Julien "_FrnchFrgg_" Rivaud [1] iirc, it was to make enumitem overlay-aware in beamer while respecting the already existing syntax. So \begin{enumerate}[][enumitem options], where of course any of them can be present (in that order only according to what beamer does for its enumerate). I had to resort to grabbing the first optional argument, check if it began with <, and if so remove the trailing > and grab another optional argument. A bit ugly, whereas \NewDocumentEnvironment {enumerate} { d{[<}{>]} o } would have been beautifully clean. P.S.: I also encountered a "quirk" in \NewDocumentEnvironment, in that the environment close is not align-safe (probably because of the retrieving of arguments, but I didn't check; or just because it is protected?): it starts a new row (and that's the least worry because then the closing stuff is in a box group and TeX frowns upon the \endgroup of \end). I didn't need closing args, so I just used \NewDocumentCommand.