all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: David Kastrup <dak@gnu.org>
To: emacs-devel@gnu.org
Cc: ding@gnus.org
Subject: Re: replace matches in any string
Date: Thu, 02 Sep 2010 20:04:39 +0200	[thread overview]
Message-ID: <87r5hcc98o.fsf@lola.goethe.zz> (raw)
In-Reply-To: 87k4n42fw4.fsf@lifelogs.com

Ted Zlatanov <tzz@lifelogs.com> writes:

> On Thu, 02 Sep 2010 19:22:35 +0200 David Kastrup <dak@gnu.org> wrote: 
>
> DK> Ted Zlatanov <tzz@lifelogs.com> 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




  reply	other threads:[~2010-09-02 18:04 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87ab3gfb41.fsf@hati.baby-gnu.org>
     [not found] ` <87r5wrgg8w.fsf@lifelogs.com>
     [not found]   ` <87y6gvwryp.fsf@hati.baby-gnu.org>
     [not found]     ` <87d3y7p1ie.fsf@gnu.org>
     [not found]       ` <87633y7v02.fsf@hati.baby-gnu.org>
     [not found]         ` <m2aatadtda.fsf@igel.home>
     [not found]           ` <87vdbyccgg.fsf@hati.baby-gnu.org>
     [not found]             ` <m21vemdo67.fsf@igel.home>
     [not found]               ` <87eiikdfub.fsf@hati.baby-gnu.org>
     [not found]                 ` <87ocf18ntz.fsf@hati.baby-gnu.org>
2010-07-08 13:57                   ` [PATCH] Use replace-match in posting-style Ted Zlatanov
2010-07-12 19:43                     ` Daniel Dehennin
2010-07-30 17:43                       ` replace matches in any string (was: [PATCH] Use replace-match in posting-style.) Ted Zlatanov
2010-09-01 13:55                         ` replace matches in any string Ted Zlatanov
2010-09-02 11:29                           ` Stefan Monnier
2010-09-02 13:10                             ` Ted Zlatanov
2010-09-02 14:44                               ` Lars Magne Ingebrigtsen
2010-09-02 16:21                               ` Stefan Monnier
2010-09-02 16:45                                 ` David Kastrup
2010-09-02 17:08                                 ` Ted Zlatanov
2010-09-02 17:22                                   ` David Kastrup
2010-09-02 17:51                                     ` Ted Zlatanov
2010-09-02 18:04                                       ` David Kastrup [this message]
2010-09-02 19:12                                         ` Ted Zlatanov
2010-09-02 19:17                                           ` Recommended gnus spam filter system? Camm Maguire
2010-09-02 19:42                                             ` Thorsten Bonow
2010-09-02 20:31                                             ` Frank Schmitt
2010-09-02 20:38                                             ` Karl Fogel
2010-09-02 20:27                                     ` replace matches in any string Stefan Monnier
2010-09-02 22:18                                       ` Lars Magne Ingebrigtsen
2010-09-02 22:40                                         ` Davis Herring
2010-09-03  5:33                                       ` David Kastrup
2010-09-03 17:06                                         ` Lars Magne Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r5hcc98o.fsf@lola.goethe.zz \
    --to=dak@gnu.org \
    --cc=ding@gnus.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.