From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/107983 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Jairo A. del Rio" Newsgroups: gmane.comp.tex.context Subject: Re: About xstring and ConTeXt Date: Tue, 7 Jul 2020 16:21:03 -0500 Message-ID: References: <60da2635-f431-79fb-cacc-91847903a826@gmail.com> Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5284569315096832760==" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21675"; mail-complaints-to="usenet@ciao.gmane.io" To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Tue Jul 07 23:21:29 2020 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane-mx.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jsv1t-0005Wd-P3 for gctc-ntg-context-518@m.gmane-mx.org; Tue, 07 Jul 2020 23:21:29 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id A6922185623; Tue, 7 Jul 2020 23:21:18 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id C2LnX1xnIsQ0; Tue, 7 Jul 2020 23:21:17 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id ADD4E185629; Tue, 7 Jul 2020 23:21:17 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 5533F185623 for ; Tue, 7 Jul 2020 23:21:16 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ffE6v72Ut7cY for ; Tue, 7 Jul 2020 23:21:15 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.128.48; helo=mail-wm1-f48.google.com; envelope-from=jairoadelrio6@gmail.com; receiver= Original-Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 6B6DA185622 for ; Tue, 7 Jul 2020 23:21:15 +0200 (CEST) Original-Received: by mail-wm1-f48.google.com with SMTP id f139so662932wmf.5 for ; Tue, 07 Jul 2020 14:21:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=Hnye677FhRr/8gqgcMcPlr4VKq/Ux7fzrGFWR++HGBI=; b=f0CX91CpmsvDMUyu21GL0fkQ4YOnmqqJ5rsEcr9tAbdERy4zrb2P64eR2Q5z8XWggd WpIdtaSSiyOVSFwZWS+qWNPvyApYzqWRAZ6ig05EalFXO2qAn9hckFAx4xyVQWwC9NCc Y6sIT4HJjCTVwkkWx1R+AaCPTQHqgikrNPlAKZEWwK01IdTApKaNeV+J/5AZdp8+NAN2 KY4ffsC7Yf9FTOFzkcl892q8CHI5a+UfeLt6CUcc1Sv6XzcMiFo/+UQVK0eHHAn783nq 1VY3lEfU2PTH/UoXwlX3Qz5NqSp114JNLaJCMnrajtO6G+zl4GP/RybtNfv0I08lVA5X RCgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=Hnye677FhRr/8gqgcMcPlr4VKq/Ux7fzrGFWR++HGBI=; b=f1rKwGgiAHslOumO1Lza37ouPWhNFmnYCpClH3MMMVrmflgNzKi5SXNKm37CU3f5q3 es2hEa+OABYEufy7Im0uBzSca9MGwfFD3aLc9zujpEivm9ntu+7qnjcY7kQ1bwZd7JhI qTTiIsyshxD3LvAhHA9jFXBaMbHnRRXMffono9E4pTWHlAOS4B5gUMu2cc4VOXqyucNq SOOvaRYX6vAwgyz8mKzYiQxoytMF2ozcmHgCi/KZYoBl9T7nxmk/6u8OOxdPK74IKTn/ cj72q1eNWxKWPfj3NtiA1/hgTRE/DyxY6/gCr8lJV/PhMddr5aYVfw0Hw782aqBKaxLf cSIA== X-Gm-Message-State: AOAM5335S890NgMklgAYqB3UisZ0PFMhcYa+99YzTw/wxFWTyPrfBmZa yh2KNyOGPOVlRzqBjvQH+EXA4dwxgXuiFJOJPuP+LS+k4iE= X-Google-Smtp-Source: ABdhPJzkEmN4aJek3V7/I/MZ4mFnARZ4i1W3MbKSC7k1pzDIpxmEt5JIw6UEqGlwheMOlMqUrjLiz4oD7WJB2Tcf7fQ= X-Received: by 2002:a1c:790c:: with SMTP id l12mr5891262wme.50.1594156874706; Tue, 07 Jul 2020 14:21:14 -0700 (PDT) In-Reply-To: <60da2635-f431-79fb-cacc-91847903a826@gmail.com> X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.io gmane.comp.tex.context:107983 Archived-At: --===============5284569315096832760== Content-Type: multipart/alternative; boundary="0000000000003bb57c05a9e09213" --0000000000003bb57c05a9e09213 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thank, Wolfgang! Both methods work, but both fail with the following example: \pushmacro\unexpanded \let\unexpanded\normalunexpanded \input xstring \popmacro\unexpanded \starttext \StrGobbleLeft{bcdef}{4} \stoptext The log says: tex error > tex error on line 6 in file ./tests.tex: ! This can't happen (prefixed command) \unexpanded { f} \xs_execfirst #1#2->#1 However, some others work. El mar., 7 de jul. de 2020 a la(s) 15:20, Wolfgang Schuster ( wolfgang.schuster.lists@gmail.com) escribi=C3=B3: > Phelype Oleinik schrieb am 07.07.2020 um 20:53: > > Hi Jairo, > > > > ConTeXt's \unexpanded is e-TeX's \protected, so the error boils down to > > something like: \edef\x{\unexpanded{#}}, which works in Plain but not i= n > > ConTeXt. > > > > Usually packages that claim to be generic have to cope with that. > > xstring would need to do (in a ConTeXt-specific loader): > > \let\xstring@unexpanded\normalunexpanded > > and > > \let\xstring@unexpanded\unexpanded > > in Plain and LaTeX loaders, then then use \xstring@unexpanded in the > > code. But `xstring` doesn't claim (that I found, at least) to be > > compatible with ConTeXt, so it's understandable: though if it is > > compatible with Plain, it wouldn't be hard to adapt to ConTeXt. > > > > That said, you can load `xstring` if you do: > > \let\unexpanded\normalunexpanded > > \input xstring.tex > > \let\unexpanded\protected > > but the internals of the package will probably be comprimised by the > > misuse of (ConTeXt) \unexpanded. > > Bad idea because ConTeXt also changes the meaning of \protected (you can > use \normalprotected to get the primitve). > > A better version is > > \pushmacro\unexpanded > \let\unexpanded\normalunexpanded > \input xstring > \popmacro\unexpanded > > Wolfgang > > _________________________________________________________________________= __________ > If your question is of interest to others as well, please add an entry to > the Wiki! > > maillist : ntg-context@ntg.nl / > http://www.ntg.nl/mailman/listinfo/ntg-context > webpage : http://www.pragma-ade.nl / http://context.aanhet.net > archive : https://bitbucket.org/phg/context-mirror/commits/ > wiki : http://contextgarden.net > > _________________________________________________________________________= __________ > --0000000000003bb57c05a9e09213 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thank, Wolfgang! Both methods work, but both fail wit= h the following example:

\pushmacro\unexpanded =C2= =A0
\let\unexpanded\normalunexpanded
\input xstring
\popmacro\unex= panded
\starttext
\StrGobbleLeft{bcdef}{4}
\stoptext

The log says:

tex error = > tex error on line 6 in file ./tests.tex: ! This can't happen (pr= efixed command)


<argument&g= t; \unexpanded {

f= }

\xs_execfirst = #1#2->#1

However, some others work.


El mar., 7 de jul. de 2020= a la(s) 15:20, Wolfgang Schuster (wolfgang.schuster.lists@gmail.com) escribi=C3=B3:
Phelype Oleinik schrieb = am 07.07.2020 um 20:53:
> Hi Jairo,
>
> ConTeXt's \unexpanded is e-TeX's \protected, so the error boil= s down to
> something like: \edef\x{\unexpanded{#}}, which works in Plain but not = in
> ConTeXt.
>
> Usually packages that claim to be generic have to cope with that.
> xstring would need to do (in a ConTeXt-specific loader):
>=C2=A0 =C2=A0 =C2=A0 \let\xstring@unexpanded\normalunexpanded
> and
>=C2=A0 =C2=A0 =C2=A0 \let\xstring@unexpanded\unexpanded
> in Plain and LaTeX loaders, then then use \xstring@unexpanded in the > code.=C2=A0 But `xstring` doesn't claim (that I found, at least) t= o be
> compatible with ConTeXt, so it's understandable: though if it is > compatible with Plain, it wouldn't be hard to adapt to ConTeXt. >
> That said, you can load `xstring` if you do:
>=C2=A0 =C2=A0 =C2=A0 =C2=A0\let\unexpanded\normalunexpanded
>=C2=A0 =C2=A0 =C2=A0 =C2=A0\input xstring.tex
>=C2=A0 =C2=A0 =C2=A0 =C2=A0\let\unexpanded\protected
> but the internals of the package will probably be comprimised by the > misuse of (ConTeXt) \unexpanded.

Bad idea because ConTeXt also changes the meaning of \protected (you can use \normalprotected to get the primitve).

A better version is

\pushmacro\unexpanded
\let\unexpanded\normalunexpanded
\input xstring
\popmacro\unexpanded

Wolfgang
___________________________________________________________________________= ________
If your question is of interest to others as well, please add an entry to t= he Wiki!

maillist : ntg-cont= ext@ntg.nl / http://www.ntg.nl/mailman/listinfo/nt= g-context
webpage=C2=A0 : http://www.pragma-ade.nl / http://context.aanhet.net=
archive=C2=A0 : https://bitbucket.org/phg/context-m= irror/commits/
wiki=C2=A0 =C2=A0 =C2=A0: http://contextgarden.net
___________________________________________________________________________= ________
--0000000000003bb57c05a9e09213-- --===============5284569315096832760== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --===============5284569315096832760==--