From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.devel,gmane.emacs.gnus.general Subject: Re: replace matches in any string Date: Thu, 02 Sep 2010 20:04:39 +0200 Organization: Organization?!? Message-ID: <87r5hcc98o.fsf@lola.goethe.zz> 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> <87fwxs5m0h.fsf@lifelogs.com> <87r5hc2hvr.fsf@lifelogs.com> <87vd6ocb6s.fsf@lola.goethe.zz> <87k4n42fw4.fsf@lifelogs.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1283450724 28646 80.91.229.12 (2 Sep 2010 18:05:24 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 2 Sep 2010 18:05:24 +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 20:05:22 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 1OrEA4-0004eZ-Ko for ged-emacs-devel@m.gmane.org; Thu, 02 Sep 2010 20:05:22 +0200 Original-Received: from localhost ([127.0.0.1]:52583 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OrEA1-00060K-FL for ged-emacs-devel@m.gmane.org; Thu, 02 Sep 2010 14:05:17 -0400 Original-Received: from [140.186.70.92] (port=57628 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OrE9i-0005rE-RU for emacs-devel@gnu.org; Thu, 02 Sep 2010 14:05:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OrE9d-00068K-40 for emacs-devel@gnu.org; Thu, 02 Sep 2010 14:04:56 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:40590) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OrE9c-00067U-Q9 for emacs-devel@gnu.org; Thu, 02 Sep 2010 14:04:53 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1OrE9a-0004ND-7N for emacs-devel@gnu.org; Thu, 02 Sep 2010 20:04:50 +0200 Original-Received: from p508ecf4b.dip.t-dialin.net ([80.142.207.75]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 02 Sep 2010 20:04:50 +0200 Original-Received: from dak by p508ecf4b.dip.t-dialin.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 02 Sep 2010 20:04:50 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 41 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: p508ecf4b.dip.t-dialin.net X-Face: 2FEFf>]>q>2iw=B6, xrUubRI>pR&Ml9=ao@P@i)L:\urd*t9M~y1^:+Y]'C0~{mAl`oQuAl \!3KEIp?*w`|bL5qr,H)LFO6Q=qx~iH4DN; i"; /yuIsqbLLCh/!U#X[S~(5eZ41to5f%E@'ELIi$t^ Vc\LWP@J5p^rst0+('>Er0=^1{]M9!p?&:\z]|;&=NP3AhB!B_bi^]Pfkw User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:YX97sDTiOeE9MCqa3a3DGpEj8/s= 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:129610 gmane.emacs.gnus.general:70377 Archived-At: Ted Zlatanov writes: > On Thu, 02 Sep 2010 19:22:35 +0200 David Kastrup wrote: > > DK> Ted Zlatanov writes: >>> That would be great. Then we wouldn't have to play the string-match >>> regex escaping game above. But it complicates the code a bit to >>> provide `string'. > > DK> Hardly. > > Is "a tiny bit" more accurate? In any case, > `match-substitute-replacement' seems like the right function. Thank > you. > >>> I think Lars's suggestion to always save `string' to the same global >>> variable is sensible; > > DK> For one thing I guess it is too late to change the API. > > There's no change! Saving the string is setting just one pointer > reference and does not change any existing code or APIs. A function using save-match-data may be used in any hook or other stuff called nearly asynchronously. It is a very bad idea to add some global variable to the match data (which is everything that affects matching) without making save-match-data, match-data and set-match-data involved. > DK> For another, that prevents strings from being garbage-collected as > DK> long as they are present in some match-data. While the same is true > DK> of buffers, a dead buffer does not take significant space. > > Only one string would be kept around, not all the matches (I think > you're thinking of the tacked-on wishlist item below). Huh? Of course only one string would be kept around, the source string on which the match was made. And that is at least as long as all matches combined (at least when the matches are not inside one another). -- David Kastrup