Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by h1439878.stratoserver.net (8.14.4/8.14.4/Debian-2ubuntu2.1) with ESMTP id t7PBanc9010645 for ; Tue, 25 Aug 2015 13:36:50 +0200 Received: from relay2.uni-heidelberg.de ([129.206.210.211]) by mx-ha.gmx.net (mxgmx103) with ESMTPS (Nemesis) id 0M837l-1YZKYc2QQj-00vhMg for ; Tue, 25 Aug 2015 13:36:43 +0200 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [129.206.100.94]) by relay2.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id t7PBZ06Y005247 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 25 Aug 2015 13:35:01 +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 t7P9HwNw015549; Tue, 25 Aug 2015 13:35:00 +0200 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 12533079 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Tue, 25 Aug 2015 13:35:00 +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 t7PBZ0cu016378 for ; Tue, 25 Aug 2015 13:35:00 +0200 Received: from mail-io0-f181.google.com (mail-io0-f181.google.com [209.85.223.181]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id t7PBYveO012857 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL) for ; Tue, 25 Aug 2015 13:34:59 +0200 Received: by iods203 with SMTP id s203so182455627iod.0 for ; Tue, 25 Aug 2015 04:34:56 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.107.130.141 with SMTP id m13mr29088331ioi.22.1440502496718; Tue, 25 Aug 2015 04:34:56 -0700 (PDT) Received: by 10.36.81.201 with HTTP; Tue, 25 Aug 2015 04:34:56 -0700 (PDT) References: <55DBB7F6.1070307@clear.net.nz> <55DABA1D.3050706@morningstar2.co.uk> <55DCFDF7.7080305@clear.net.nz> <55DC05BF.1040505@morningstar2.co.uk> Content-Type: text/plain; charset=UTF-8 Message-ID: Date: Tue, 25 Aug 2015 13:34:56 +0200 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: Bruno Le Floch Subject: Re: Catcode changes To: LATEX-L@LISTSERV.UNI-HEIDELBERG.DE In-Reply-To: <55DC05BF.1040505@morningstar2.co.uk> 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:h2NqklPpldQ=:YGPemX2nhqJzEsnJM0yHs6u4Pn hZRpPJbrVhNouKTi/ubtu+gJyHy8yJuMX7bkesSNnlMSOvE7HEDO2dFRPKkmFibf6NOaVbnGL CdDjdfuQQ2Jte+zYHNUQfU988+aFxQCdtz4c/DvvqoLRR9g7Si5/1EG39C89G7fYlrI3Io/tW tTHP5tDYGQb5yYanzWs/gs5AJ27Fzs5TuSFBakDvkjqXdoP4uecV6nCW5ZyR2/3vjrObbdCO+ Ak7Wx0PONqyd50Md6azgYI6ZP4ckBL3E4vv2rXZgF62akKYx2mSIiV4Q1tvbPykSRzt5xtA8W QYczYvqsdvf/DUjGfxQw+wRQAJk0yo6q/AiMLtvQJnc960Co9274wc9nHVlSh+kfgCrHx7YNg 89x1FXjBNZ6t6Y9wX4GE0tiWYBkH2omYZanTrw47BPOsyN2xclqYdfpWIsvUvuZS8kGwtGwG9 g9EEjhow9Mo26kW4y/D20+jvykfn3sZZ8QExuTkEq1LiAmtdzM0RAKoti0GkKX5ub2yh+XZ1a Y0cSmeOFne5vB6+Gi+ssrt0TVsEE5QRZF7c4OVlwLWObOaioZ/BXoRMDlWQ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zUpb62gxcNVx8A5Ae3nGU zzMhQCYjU1/Ss0wMiV39BZwFbHAnS6N45VkODSSsidRBUpG+4iYlXmvx6gta4kNcisiLIto7L kf1biue1f5hxfoQeb0TT/bGtROV4vEyOINJQdqtpgomaUy7MFxnVBg0k865QcnPF+7StyTC+H MAE2ODfbqZiurwGp3sCJnJ635OBMl5uFnSnGr/Hm6HAbbbH8eAwyanhOkUmpapKp3u/MQQuYQ MDg1P2buvk+PHrtVdrlEpOitNgczmQZJlsNI8+6eIsKwvrRGkNWiVVOQwtwiI1/z1J/ifyJMA vKM77vLxFyOuRLajJKCwpsd8hQlNj/zRXOIU27zuhNAgfny+qaZZ6VBp1QFL3924ARqOJkpQe iHPAh+e2LHcbGNRVoqFAkINk4DRVL04fqGPIOf+s9NeUqGddbnVLSbrgvqKIBcneR6qsqB2Xn NvAvBGq9+v2fR6akhbHZnocQvA/j3SxnXtQP/G/+OEMafYCok5Nj X-Scanned-By: MIMEDefang 2.71 on 85.214.41.38 Status: R X-Status: X-Keywords: X-UID: 7835 On 8/25/15, Joseph Wright wrote: > On 26/08/2015 00:44, aparsloe wrote: >> (1) I wanted to use \tl_replace_all:Nnn on a token list that might >> contain braced groups. Using \tl_set_rescan:Nnn to change the category >> codes of { and } seemed the most direct way of proceeding. (Then >> resetting the category codes after replacement with an empty setup.) > > I see what you mean (I have a similar case in siunitx, for historical > reasons). We'll explore what we can do with this: there are > mapping-based approaches one can imagine that will enter brace groups. > (We do that for \tl_lower_case:n, for example). However, for a general > 'search and replace' I'd be slightly wary as the TeX convention that > stuff in brace groups is 'special' is quite prevalent. (Depending on > performance requirements, you might also look at l3regex if you are > doing the replacement only very rarely.) > >> (2) Using \fp_to_scientific:n on the result of an l3fp calculation >> produces, say, 6.023e23. I want to write this as 6.023 \times 10^{23}, >> but the "e" of 6.023e23 doesn't have its "usual" catcode so >> \tl_replace_once:Nnn doesn't find the "e". (I presume "e" has catcode >> "other" -- I haven't checked.) Hence I rescan 6.023e23 with an empty >> setup and then use \tl_replace_once:Nnn (which now does find the "e"). > > I see that we don't mention the catcode of "e" here: we should do > (Bruno?). For this particular use case, I'd set up your search using a > detokenized e > > \cs_generate_variant:Nn \tl_replace_all:Nnn { Nx } > \tl_replace_all:Nnn { \tl_to_str:n { e } } { \times } > > but probably with a dedicated function > > \cs_new:Npn \__mymodule_format:n #1 > { \__mymodule_format:w #1 \q_stop } > \use:x > { > \cs_new:Npn \exp_not:N \__mymodule_format:w > ##1 \tl_to_str:n { e } ##2 \exp_not:N \q_stop > } > { \exp_not:n { #1 \times 10 ^ {##2} } } > > which can be made more 'robust' if you need to allow for cases where > there is no "e". Actually, should we just make the "e" output by \fp_to_scientific:n into a letter "e" rather than an other "e"? That's trivial to change, and would be in line with how \int_to_roman:n produces letter catcodes. I don't remember my rationale for outputting an other "e". Bruno