From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: query-replace-regexp: Can't use \0 in TO-STRING Date: Wed, 10 May 2017 01:02:04 +0300 Organization: LINKOV.NET Message-ID: <87r2zxg03b.fsf@localhost> References: <87bmr5micc.fsf@gmail.com> <83lgq8en8o.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1494368036 9517 195.159.176.226 (9 May 2017 22:13:56 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 9 May 2017 22:13:56 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (x86_64-pc-linux-gnu) Cc: netjune@qq.com, emacs-devel@gnu.org, tino.calancha@gmail.com, zhanghj To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed May 10 00:13:51 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d8DO9-0002HJ-CO for ged-emacs-devel@m.gmane.org; Wed, 10 May 2017 00:13:49 +0200 Original-Received: from localhost ([::1]:39661 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8DOD-0005RX-DC for ged-emacs-devel@m.gmane.org; Tue, 09 May 2017 18:13:53 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38485) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8DNT-0005Ol-Cp for emacs-devel@gnu.org; Tue, 09 May 2017 18:13:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8DNR-0006KL-TS for emacs-devel@gnu.org; Tue, 09 May 2017 18:13:07 -0400 Original-Received: from sub3.mail.dreamhost.com ([69.163.253.7]:41916 helo=homiemail-a15.g.dreamhost.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8DNN-0006Gy-JS; Tue, 09 May 2017 18:13:01 -0400 Original-Received: from homiemail-a15.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a15.g.dreamhost.com (Postfix) with ESMTP id AE0B276C06E; Tue, 9 May 2017 15:12:54 -0700 (PDT) Original-Received: from localhost.linkov.net (m90-133-229-48.cust.tele2.ee [90.133.229.48]) (Authenticated sender: jurta@jurta.org) by homiemail-a15.g.dreamhost.com (Postfix) with ESMTPA id 164C576C069; Tue, 9 May 2017 15:12:52 -0700 (PDT) In-Reply-To: <83lgq8en8o.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 07 May 2017 17:48:55 +0300") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-Received-From: 69.163.253.7 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:214728 Archived-At: >> >> Why not \0? I think \0 is more intuitive and also used in vim. >> > I agree is more intuitive, and it works in `replace-match', or instance: >> > (mapcar >> > (lambda (group) >> > (let ((str "foo123")) >> > (when (string-match "[a-z]+\\([1-9]+\\)" str) >> > (replace-match "bar" nil nil str group)))) >> > (list 0 1)) >> > => ("bar" "foobar") >> > >> > Are you willing to write a patch to implement it? >> >> The following patch works on my machine for regexp replacing. But I >> don't known if \0 should be supported in other places such as >> sort-regexp-fields, occur. > > If this is accepted (and I'm not sure we should), then the user manual > should also be updated, and NEWS should have an entry about the > change. Some other regexp engines support the \0 format as well: http://www.regular-expressions.info/refreplacebackref.html What is important is to clearly differentiate the whole match from back references in the documentation (i.e. unlike back references \0 works only in replacements, not matches).