From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Thierry Volpiatto Newsgroups: gmane.emacs.devel Subject: Re: Improve `replace-regexp-in-string' ergonomics? Date: Wed, 13 Oct 2021 08:41:10 +0000 Message-ID: <87y26xe1ni.fsf@posteo.net> References: <878rzpw7jo.fsf@gnus.org> <875yuban9b.fsf@mail.linkov.net> <871r4qalit.fsf@mail.linkov.net> <87h7dme953.fsf@gnus.org> <87r1cqct4f.fsf@gnus.org> <87ily2v04e.fsf@posteo.net> <874k9m835c.fsf@mail.linkov.net> <87y26y7yxz.fsf@posteo.net> <8735p5z79i.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23685"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Lars Ingebrigtsen , Stefan Monnier , emacs-devel@gnu.org To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Oct 13 11:11:55 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1maaIk-0005tN-L5 for ged-emacs-devel@m.gmane-mx.org; Wed, 13 Oct 2021 11:11:54 +0200 Original-Received: from localhost ([::1]:56030 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1maaIj-0006ki-AX for ged-emacs-devel@m.gmane-mx.org; Wed, 13 Oct 2021 05:11:53 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53772) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maaC2-0008Ue-Q6 for emacs-devel@gnu.org; Wed, 13 Oct 2021 05:04:58 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:55015) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maaBp-0002Jo-5F for emacs-devel@gnu.org; Wed, 13 Oct 2021 05:04:58 -0400 Original-Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 3A6C4240107 for ; Wed, 13 Oct 2021 11:04:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1634115879; bh=IlLvfzWB2CXCTxHPcM29ojJp+dv0nKLcfCT7klsM9lY=; h=From:To:Cc:Subject:Date:Autocrypt:From; b=UYJTQ8M+Ybp1HxPaEHfNDa/K/LaW9pPbILyaNR4oT6RdG8A8rzqccu43EtoA3q5vp szFEWY9ytU8AvLmbQSYemDS+ZGHVXguYp/UkNepTwSUyiPQgYaNOg4PckuK1R6RuYa f8ByTnsSb7Xlr/7DdooFsJu4POAz4V3l+WZ+ifDZAMCKik0XEI1WlTRr9cUgLV/b9C RknO1zAJxl+H7yla/fsmHtEWwLTM0yGPGr9Rz2SJvUU6qjhY5PNLkbrTBXPCcnzlyN zVL4XCQPkoB0f3mxGNzPnWm2HGmlZWQ2qKmj6ZQHcoZiHdE2vWG3vt14pAcgLOhXAA wmhSo+VlfiLZw== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4HTmnK2dpcz9rxP; Wed, 13 Oct 2021 11:04:36 +0200 (CEST) In-reply-to: <8735p5z79i.fsf@mail.linkov.net> Autocrypt: addr=thievol@posteo.net; prefer-encrypt=mutual; keydata= mQGNBF8ylcIBDADG+hy+zR6L4/vbdDDZuSaMmSrU3A5QZJpeBCvxTr7MpzzruZbhLPW1K3R6N2MA edi8Y+C8o27FVRIjpdbaKMGu9je7JV/TbUQYo3SOwCK1vM4LUn4V6ZLzSYkuiEt4eyMoiDdyvN0p kcK6P9x9DCetcEVszXzQg+yzCVrQ2hXWDXWT4M18EC3wtO7RHPouMqGiwBFhBAYErCqFWFxQHkfb tG/4yGyJ58rglb65O3qijjMWvYwcWZun9/7qm8Z4/4mHopmo2zgU+OrptnLSZfkZGz3Y7Uf452xQ GVq0Fv75NPvQru7y+DYVhuVXXyAmGxt+vf4rIiixMBbhKEPjcxEPAa2LTzex2IsTZR+QVG9uDnqC WcgaOEQ58fzXNvNhtwwF/Rgio2XWAJVdmFWS59/k9W58CIUSNKBMZh2XeGdEmtHvDtCxW3z6FJha 36RzOM3fMNNiAGdFZJA84gcdloJR+sHCDTTPT3784fjr+V8An7sI581NGFzkRQqPvEQCZbUAEQEA AbQSdGhpZXZvbEBwb3N0ZW8ubmV0iQHUBBMBCgA+FiEEI9twfRN7r3nig/xwDsVtFB0W75MFAl8y lcICGwMFCQPCZwAFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AACgkQDsVtFB0W75MB3QwAlTsVzFmr +S/tMKwwwOibjhNPi/OZiUC2AYfaqfVAiIHDT3RbzDe03sAJoomJkJnYVjGzQZwibCMO2+ITkMPV 2wvrd4CbgS1KCVbrltwcuK/nxPCBaHytOCZUIInnhJo5PE/h03K Received-SPF: pass client-ip=185.67.36.66; envelope-from=thievol@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:276868 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Juri Linkov writes: >>> What does the following return? >>> >>> (let ((bar "bar")) >>> (helm-aand bar >>> (replace-regexp-in-string "b" "f" it) >>> (replace-regexp-in-string "f" "o" it))) >>> >>> If it returns "oar" then it applies replacements sequentially, >>> and we have no problem with such implementations. >> >> Yes, it does, thought you wanted something easy to read (and write), it >> was the initial question isn't it? > > General-purpose threading like you proposed is a nice feature. > But is supports only sequential replacements. > >>> But we need an alternative version that performs simultaneous >>> replacements and returns "far". >> >> So I don't understand what you want to achieve. > > Most of replacements are intended to be simultaneous. > But in practice most of simultaneous replacements > could be performed using sequential replacement > because often the result of every replacement step > doesn't contain matches for the next replacement step. > > But sometimes simultaneous replacement is required. > For example, > > (let ((bar "<&")) > (helm-aand bar > (replace-regexp-in-string "<" "<" it) > (replace-regexp-in-string "&" "&" it))) > > will do the wrong thing (and will return "&lt;&" instead of the > intended "<&") because these replacements should be performed > simultaneously. I see what you mean now, thanks for explanations.=20 =2D-=20 Thierry --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQHHBAEBCgAxFiEEI9twfRN7r3nig/xwDsVtFB0W75MFAmFmoSETHHRoaWV2b2xA cG9zdGVvLm5ldAAKCRAOxW0UHRbvk+HQC/9qd4Tw941G4estzWJnHduv6/1InmqI TiOqUOzI5I7B3BjCajn4aRMUbKlH7FWvNsAopGEaCy7kUp7kJ7plN/CSmsBUua+Y PdRZRMfOh3kRGLvh4PE9VBndRMeU+QkfIsoM4dYp/1wQDsj47D8gnF4JHcp1fa/j aAbgCeq8VyETjN7QzlJVMWZGeAJnkBuesLq2BeMzG5CAUl6iJp+/Rm1D9fOoUIi2 70Cp0HTG2Qb50CiwyH/aV6xFfM2ScLzxg+4LRZiy7/0W7KzpAVBzMBxRyKoBZAai kaBWqK5ZDZh+TFLM/YngVmbKvKPHBnoSysFbe+76wE9xcwjX6GDz4oq6wKbZwxRq 5tse/RmpSf1h6cUAEsRkA3HJ90KLVM6bBEfxXhz9BkKOrIj97dUZl6eKA9Z+ZJeC 7PgFipdUtRPL7hZhBP5ta14812U8n1tha1uaADZgEokhak/Zv6AXqUpqERG4yCcs nU8NT6g0MCyvn0Hq7UE8z4CsX+QJEBVb/oQ= =4wmH -----END PGP SIGNATURE----- --=-=-=--