Received: from mail.proteosys.com ([213.139.130.197]) by nummer-3.proteosys with Microsoft SMTPSVC(6.0.3790.3959); Thu, 3 Dec 2009 18:10:10 +0100 Received: by mail.proteosys.com (8.14.3/8.14.3) with ESMTP id nB3HAD7F002543 for ; Thu, 3 Dec 2009 18:10:13 +0100 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 nB3H61Ik011368 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 3 Dec 2009 18:06:01 +0100 Received: from listserv.uni-heidelberg.de (localhost.localdomain [127.0.0.1]) by listserv.uni-heidelberg.de (8.13.1/8.13.1) with ESMTP id nB3G8TuM025664; Thu, 3 Dec 2009 18:05:55 +0100 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 15.5) with spool id 363722 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Thu, 3 Dec 2009 18:05:55 +0100 Received: from relay2.uni-heidelberg.de (relay2.uni-heidelberg.de [129.206.210.211]) by listserv.uni-heidelberg.de (8.13.1/8.13.1) with ESMTP id nB3H5trm006422 for ; Thu, 3 Dec 2009 18:05:55 +0100 Received: from lon1-post-2.mail.demon.net (lon1-post-2.mail.demon.net [195.173.77.149]) by relay2.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id nB3H5inM011164 for ; Thu, 3 Dec 2009 18:05:47 +0100 Received: from pr-webmail-1.demon.net ([194.159.244.51] helo=pr-webmail-1.mail.demon.net) by lon1-post-2.mail.demon.net with esmtp (Exim 4.69) id 1NGF7g-0004AK-be for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Thu, 03 Dec 2009 17:05:44 +0000 Received: from localhost ([127.0.0.1] helo=web.mail.demon.net) by pr-webmail-1.mail.demon.net with smtp (Exim 4.42) id 1NGF7g-0001eB-Dp for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Thu, 03 Dec 2009 17:05:44 +0000 Received: from morningstar2.demon.co.uk ([61.95.196.137]) by web.mail.demon.net with http; Thu, 03 Dec 2009 17:05:44 +0000 User-Agent: Demon-WebMail/2.0 MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-ID: Date: Thu, 3 Dec 2009 17:05:44 +0000 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: Joseph Wright Subject: Re: Rescanning an argument with a special catcode for the colon To: LATEX-L@LISTSERV.UNI-HEIDELBERG.DE In-Reply-To: <4B17B855.90608@free.fr> Precedence: list List-Help: , List-Unsubscribe: List-Subscribe: List-Owner: List-Archive: X-ProteoSys-SPAM-Score: -6.599 () BAYES_00,RCVD_IN_DNSWL_MED X-Scanned-By: MIMEDefang 2.65 on 213.139.130.197 Return-Path: owner-latex-l@LISTSERV.UNI-HEIDELBERG.DE X-OriginalArrivalTime: 03 Dec 2009 17:10:10.0997 (UTC) FILETIME=[78ACE650:01CA743B] Status: R X-Status: X-Keywords: X-UID: 6193 frnchfrgg@FREE.FR wrote: > > \begingroup > \catcode`\:=13 > \catcode`\.=13\relax > \gdef\chemin#1{% > \begingroup > \catcode`\:=13 > \catcode`\.=13\relax > \let.\cheminsommet > \let:\cheminface > \endlinechar=-1 > \everyeof{}% > \scantokens{#1}% > \endgroup > } > \endgroup A couple of things here. First, active characters tend to be bad news. In my own siunitx package, I've moved from using an approach like yours in v1 to trying a different system in v2, based on \tl_replace_all_in:Nnn: \cs_set:Nn \my_int_function:n #1 { \tl_set:Nn \l_my_tmp_tl {#1} \tl_replace_all_in:Nnn \l_my_tmp_tl { . } { \cheminsommet } \tl_replace_all_in:Nnn \l_my_tmp_tl { : } { \cheminface } % Do more stuff with the input } The reason for this is two-fold. First, active characters can cause a lot of problems (see what happens when two packages try to do something like this). Second, the \tl_replace_all_in:Nnn approach means that there is only one level of replacement, which is often what people expect if they protect characters. I think the general feeling is that the team are aiming to avoid active characters as far as possible. If you do want to use \tl_rescan:Nnx, what is wrong with \group_begin: \char_make_active:N \: \char_make_active:N \. \cs_gset:Npn \my_int_function:n #1 { \tl_set_rescan:Nnx \l_my_tmp_tl { \char_make_active:N \: \char_make_active:N \. \cs_set_eq:NN . \cheminsommet \cs_set_eq:NN : \cheminface } {#1} % Stuff with \l_my_tmp_tl } \group_end: or \group_begin: \char_make_active:N \: \char_make_active:N \. \cs_gset_eq:NN . \cheminsommet \cs_gset_eq:NN : \cheminface \cs_gset:Npn \my_int_function:n #1 { \tl_set_rescan:Nnn \l_my_tmp_tl { \char_make_active:N \: \char_make_active:N \. } {#1} % Stuff with \l_my_tmp_tl } \group_end: (The later makes active . and : globally available, so works without x-type expansion of the tl. I'd personally go for the first of these two solutions as it again is independent of what others do.) -- Joseph Wright