From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Improve `replace-regexp-in-string' ergonomics? Date: Tue, 12 Oct 2021 11:48:55 -0400 Message-ID: References: <878rzpw7jo.fsf@gnus.org> <875yuban9b.fsf@mail.linkov.net> <871r4qalit.fsf@mail.linkov.net> <87h7dme953.fsf@gnus.org> <87r1cqct4f.fsf@gnus.org> <87sfx6bcup.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30263"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel@gnu.org, Juri Linkov To: Lars Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Oct 12 17:51:47 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 1maK4A-0007cJ-Q8 for ged-emacs-devel@m.gmane-mx.org; Tue, 12 Oct 2021 17:51:46 +0200 Original-Received: from localhost ([::1]:39050 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1maK48-0005x8-OT for ged-emacs-devel@m.gmane-mx.org; Tue, 12 Oct 2021 11:51:45 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53908) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maK2g-0003xf-PQ for emacs-devel@gnu.org; Tue, 12 Oct 2021 11:50:15 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:43869) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maK2T-0000v8-GM for emacs-devel@gnu.org; Tue, 12 Oct 2021 11:50:13 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 97095802B7; Tue, 12 Oct 2021 11:49:58 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 517738031E; Tue, 12 Oct 2021 11:49:53 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1634053793; bh=tGdVdY7tAWBdPIvnjwF+1Y78GnLZqOdO+pYXqzdHA7w=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=CphH76FoH2caivMKjCC5ZcIJD8bSBJt8n0Tzhf53J3o1XmkIYloR4k44XancyJc8T ZqX+AOM9ZC03YSL4dj1JRa2wlYhRd40jZEAOdakEPmmB6p/TBrVqHPP/2CgU1rOCKu Y2zGYsLpO9T+UiqiyLxO+tXo29J52hGEn9MdYqzbicZ2bPZCwHpnfyUWq6+XyXNn0/ i+QRHAgGgJInUs6kqnYt/HmdviUVd5l0yhPjL2XXaUlFVce0lgLaZIktgOkUD2rgRE F50+bTDlkStC0plVX6N58X4RK61UB7eVtqHHhCOEa5Vs0RiU/nsZto5U3ufkS6JhZd mvtlNrgnBixFw== Original-Received: from alfajor (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 23BBE120442; Tue, 12 Oct 2021 11:49:53 -0400 (EDT) In-Reply-To: <87sfx6bcup.fsf@gnus.org> (Lars Ingebrigtsen's message of "Tue, 12 Oct 2021 15:18:38 +0200") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_PASS=-0.001, T_SPF_HELO_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:276810 Archived-At: > (new-and-spiffy-regexp-replace string > "\\(foo\\)" "bar\\1" > "\\(bar\\)" "foo\\1" > ...) > > should work just fine, no matter how many of them you have -- you just > have to transpose the groups down to where they were again before doing > the replacement. That's right (and `syntax-propertize-rules` does indeed do that, tho for the above example it would probably be better to do it differently). > It will break down if the user has a lot of actual backrefs in the > matching regexps, but that's quite rare in practice. Indeed, tho IIRC the problem can occur even with just a single backref. Stefan