From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/107985 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 17:00:49 -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="===============7827334079664747509==" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33885"; mail-complaints-to="usenet@ciao.gmane.io" To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Wed Jul 08 00:01:26 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 1jsveY-0008iT-3D for gctc-ntg-context-518@m.gmane-mx.org; Wed, 08 Jul 2020 00:01:26 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id ECC5E185634; Wed, 8 Jul 2020 00:01:05 +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 Dmq8RImAw1Tw; Wed, 8 Jul 2020 00:01:05 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 13B18185640; Wed, 8 Jul 2020 00:01:05 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 192EA185618 for ; Wed, 8 Jul 2020 00:01:04 +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 2157GG3wrK63 for ; Wed, 8 Jul 2020 00:01:02 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.128.44; helo=mail-wm1-f44.google.com; envelope-from=jairoadelrio6@gmail.com; receiver= Original-Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 E3AA9185552 for ; Wed, 8 Jul 2020 00:01:02 +0200 (CEST) Original-Received: by mail-wm1-f44.google.com with SMTP id f139so793289wmf.5 for ; Tue, 07 Jul 2020 15:01:02 -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=wrfYirRWZ6VR3YpRaxpy8W+vaVNCPktmc9iPNyct6IU=; b=I4r39mu+gK5KKQqZnaNhPiLQj3QwWXSFciv1VnxZqWDjR4rmL4fzJO53noxd/pQhlK vvRBtXIr+9RZZ7R3xUaeqdIFSht8xuOXiF6XDRwGgKlpSU6J9kaogfQ35KLrNswRRo2V qghPOcf1K6KtTgDIJSZC3ikD4O7Fo4rdsQPxW+dnKo9FtO2jiET0nTAWdC/eBcoZNtcV VqlCI3TPKIk06A0scWiKvfGHT4qKQ1CwRHmAIdbhWXAltaV77QICUoagx/5aF1BpElSb PyzWyDM+YURFSSjeFIKHqA1v8rkKXPBvUviAMg0hH7t7V390Vt0+bHcYW+zSP8hLNfY1 Espw== 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=wrfYirRWZ6VR3YpRaxpy8W+vaVNCPktmc9iPNyct6IU=; b=IbXXhjdlvcurArXO4ebDGUUUEThcM48sN3wwefQlv/NatgtWrLAUefGt+MBtY+1P9m 0NUAcYIovuGeN3NTAfvkHvjlKRIJghLtOeW3AQpVtTE4u/zPmXCSoPThhy1xt8viXL9x hSxGIZ0iPWLoiyJrxfNz/fo06Pd1hTx/vClpRsq+7WFAg1/3Slr0S2umQd2FDSG++7j3 N1Fu8QtFMvQQ+isSU7+SdCP2JiGigJcOPsad512B+9aXNN8JinhDyWhF2Ag0bE6omRJx NjYKniu0COjwToeNvSkQdrlzcD7oCIjXZjysYZxDOGm15OREcF1HMFDyToF7Tds00uPK lw9w== X-Gm-Message-State: AOAM532OfWxMgTdfSYo7kPhfTRd3BSB5LDQcnKYPbakq32DxsIdRvO3b hLuRw/boxjwmRAuZbeIGwvw+0ZD1yLPSFjCus3wfjiQB X-Google-Smtp-Source: ABdhPJwqHHIMsE/thS4SDqm4QFc+ioKZjhnKoqmzs1pkCIuz5BPRz0m8G5DEB72ciMgiwgcjgCJVALuztSiZsanpXwY= X-Received: by 2002:a1c:4b08:: with SMTP id y8mr6058637wma.89.1594159262220; Tue, 07 Jul 2020 15:01:02 -0700 (PDT) In-Reply-To: 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:107985 Archived-At: --===============7827334079664747509== Content-Type: multipart/alternative; boundary="0000000000008a464505a9e12061" --0000000000008a464505a9e12061 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Yep, now it finally works. Certainly it requires a few more lines. I was going to rewrite some TikZ code which was too dependent on LaTeX and xstring was the last stone on the shoe. Thank you a lot, Phelype and Wolfgang (I didn't know about push/popmacro either and now it's in my to-do readings). Jairo :D El mar., 7 de jul. de 2020 a la(s) 16:31, Phelype Oleinik ( phe.h.o1@gmail.com) escribi=C3=B3: > On Tue, Jul 7, 2020 at 6:21 PM Jairo A. del Rio > wrote: > > > > 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 happe= n > (prefixed command) > > > > > > \unexpanded { > > > > f} > > > > \xs_execfirst #1#2->#1 > > > > However, some others work. > > As I said, the internals of `xstring` still use \unexpanded which, after > you do \popmacro\unexpanded, will mean e-TeX's \protected, rather than > \unexpanded, which are quite different. To be on the safe side, you'd > need to wrap every `xstring` command in > \pushmacro\unexpanded > \let\unexpanded\normalunexpanded > > \popmacro\unexpanded > to make sure that \unexpanded means what `xstring` expects. > > The *proper* way to make `xstring` work in ConTeXt would be something > like Circuitikz does: > \ifcsname normalunexpanded\endcsname > \let\pgfcircutil@unexpanded\normalunexpanded > \else > \let\pgfcircutil@unexpanded\unexpanded > \fi > then use \pgfcircutil@unexpanded in the code, which will always have the > same meaning. That, of course, requires an update to `xstring`. > > Phelype > > _________________________________________________________________________= __________ > 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 > > _________________________________________________________________________= __________ > --0000000000008a464505a9e12061 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Yep, now it finally works. Certainly it requires a fe= w more lines. I was going to rewrite some TikZ code which was too dependent= on LaTeX and xstring was the last stone on the shoe. Thank you a lot, Phel= ype and Wolfgang (I didn't know about push/popmacro either and now it&#= 39;s in my to-do readings).

Jairo :D

El mar., 7 de jul. d= e 2020 a la(s) 16:31, Phelype Oleinik (phe.h.o1@gmail.com) escribi=C3=B3:
On Tue, Jul 7, 2020 at 6:21 PM Jairo A. del Rio &l= t;jairoadelrio= 6@gmail.com> wrote:
>
> Thank, Wolfgang! Both methods work, but both fail with the following e= xample:
>
> \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)
>
>
> <argument> \unexpanded {
>
> f}
>
> \xs_execfirst #1#2->#1
>
> However, some others work.

As I said, the internals of `xstring` still use \unexpanded which, after you do \popmacro\unexpanded, will mean e-TeX's \protected, rather than<= br> \unexpanded, which are quite different.=C2=A0 To be on the safe side, you&#= 39;d
need to wrap every `xstring` command in
=C2=A0 =C2=A0 \pushmacro\unexpanded
=C2=A0 =C2=A0 \let\unexpanded\normalunexpanded
=C2=A0 =C2=A0 <xstring stuff>
=C2=A0 =C2=A0 \popmacro\unexpanded
to make sure that \unexpanded means what `xstring` expects.

The *proper* way to make `xstring` work in ConTeXt would be something
like Circuitikz does:
=C2=A0 =C2=A0 \ifcsname normalunexpanded\endcsname
=C2=A0 =C2=A0 =C2=A0 \let\pgfcircutil@unexpanded\normalunexpanded
=C2=A0 =C2=A0 \else
=C2=A0 =C2=A0 =C2=A0 \let\pgfcircutil@unexpanded\unexpanded
=C2=A0 =C2=A0 \fi
then use \pgfcircutil@unexpanded in the code, which will always have the same meaning.=C2=A0 That, of course, requires an update to `xstring`.

Phelype
___________________________________________________________________________= ________
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
___________________________________________________________________________= ________
--0000000000008a464505a9e12061-- --===============7827334079664747509== 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== --===============7827334079664747509==--