From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ted Zlatanov Newsgroups: gmane.emacs.devel,gmane.emacs.gnus.general Subject: Re: replace matches in any string Date: Thu, 02 Sep 2010 08:10:38 -0500 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: <87fwxs5m0h.fsf@lifelogs.com> References: <87ab3gfb41.fsf@hati.baby-gnu.org> <87r5wrgg8w.fsf@lifelogs.com> <87y6gvwryp.fsf@hati.baby-gnu.org> <87d3y7p1ie.fsf@gnu.org> <87633y7v02.fsf@hati.baby-gnu.org> <87vdbyccgg.fsf@hati.baby-gnu.org> <87eiikdfub.fsf@hati.baby-gnu.org> <87ocf18ntz.fsf@hati.baby-gnu.org> <87aaq2uldu.fsf@lifelogs.com> <87y6dg5vv2.fsf@hati.baby-gnu.org> <878w4skgqn.fsf_-_@lifelogs.com> <87sk1tk1px.fsf@lifelogs.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1283433087 10353 80.91.229.12 (2 Sep 2010 13:11:27 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 2 Sep 2010 13:11:27 +0000 (UTC) Cc: ding@gnus.org To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Sep 02 15:11:25 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Or9Zb-00032z-7G for ged-emacs-devel@m.gmane.org; Thu, 02 Sep 2010 15:11:23 +0200 Original-Received: from localhost ([127.0.0.1]:39675 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Or9Za-0007oX-Af for ged-emacs-devel@m.gmane.org; Thu, 02 Sep 2010 09:11:22 -0400 Original-Received: from [140.186.70.92] (port=38360 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Or9ZO-0007YL-WE for emacs-devel@gnu.org; Thu, 02 Sep 2010 09:11:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Or9Z5-0004Ed-FR for emacs-devel@gnu.org; Thu, 02 Sep 2010 09:10:52 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:49257) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Or9Z5-0004Dw-3y for emacs-devel@gnu.org; Thu, 02 Sep 2010 09:10:51 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1Or9Z2-0002eh-SA for emacs-devel@gnu.org; Thu, 02 Sep 2010 15:10:48 +0200 Original-Received: from 38.98.147.130 ([38.98.147.130]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 02 Sep 2010 15:10:48 +0200 Original-Received: from tzz by 38.98.147.130 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 02 Sep 2010 15:10:48 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 43 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 38.98.147.130 X-Face: bd.DQ~'29fIs`T_%O%C\g%6jW)yi[zuz6; d4V0`@y-~$#3P_Ng{@m+e4o<4P'#(_GJQ%TT= D}[Ep*b!\e,fBZ'j_+#"Ps?s2!4H2-Y"sx" User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:9Xve2puGHG65KmgSW3u56C9zIT8= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:129589 gmane.emacs.gnus.general:70354 Archived-At: On Thu, 02 Sep 2010 13:29:41 +0200 Stefan Monnier wrote: SM> I do not understand the feature you request. SM> Rather than code that supposedly implements the feature, try to post SM> examples of uses you'd like to see work. I believe the following is accurate. Daniel, please correct me if I'm wrong in my description. Given: (let ((regex "\\(alpha\\)") (string "gamma alpha beta")) (when (string-match regex string) (replace-match "[first greek letter \\1]" nil nil string 1))) -> "gamma [first greek letter alpha] beta" We want the equivalent but against any string, not just the original string (the `replace-match' docs say STRING has to be the one used for the original `string-match'). The use case is when you say to match X in an e-mail address, then set the target group to "something-X-other". We want to do it with regex "\\(X\\)" against "userX@valid.domain" and target group "something-\\1-other". Does that make sense? Basically we want \1 but without the context of that original string we matched: (let ((regex "\\(alpha\\)") (string "gamma alpha beta")) (when (string-match regex string) (our-new-function "found greek letter \\1"))) -> "found greek letter alpha" As I said, `nnmail-expand-newtext' implements this for Gnus purposes and it can handle \[0-9] arguments and \& for the whole match but it's not generic. It needed to be extended for Daniel Dehennin's patch and so we came to this. SM> I have the impression that what you want is already provided by SM> replace-match, tho only in the case when the match was performed on SM> a string rather than in a buffer. I hope so. Ted