all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Paul Pogonyshev <pogonyshev@gmx.net>
Cc: juri@jurta.org, rms@gnu.org, emacs-devel@gnu.org
Subject: Re: [patch] Re: regexp repacement, how to present replacement to user?
Date: Sun, 21 Oct 2007 21:22:54 -0400	[thread overview]
Message-ID: <jwvve90ynjf.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <200710212200.38685.pogonyshev@gmx.net> (Paul Pogonyshev's message of "Sun\, 21 Oct 2007 22\:00\:38 +0300")

> These functions basically perform part of what `replace-match' does.
> The latter substitutes replacement group references (`\N' and `\&')
> and replaces match in the buffer with the result text.  Proposed
> functions only generate and return that text, without modyfing the
> buffer.

I think the main part of it is the offsetting and that may be used at
other places.  So it's the only part we want to provide.  Then the user can
combine it with replace-match.

I suggest something like

  (defun match-data-move-base (start)
    "Change the `match-data' such that it assumes START to be at position 0.
  It can be combined for example as in:

    (progn
      (match-data-move-base (match-beginning 0))
      (replace-match (match-string 0)))"

    (set-match-data (mapcar (lambda (x)
				(if (numberp x)
				    (- x start)
				  x))
			      (match-data t))))

It could even take an `end' argument and clip the match-data to fit
within start..end.


        Stefan

  parent reply	other threads:[~2007-10-22  1:22 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-13 14:00 regexp repacement, how to present replacement to user? Paul Pogonyshev
2007-10-14 22:50 ` Juri Linkov
2007-10-15  3:20   ` Stefan Monnier
2007-10-15  5:57     ` David Kastrup
2007-10-15 20:28       ` Paul Pogonyshev
2007-10-16 23:54         ` Juri Linkov
2007-10-17  6:06           ` David Kastrup
2007-10-17 19:25           ` Paul Pogonyshev
2007-10-20 13:53             ` [patch] " Paul Pogonyshev
2007-10-21 16:26               ` Richard Stallman
2007-10-21 19:00                 ` Paul Pogonyshev
2007-10-21 20:43                   ` Juri Linkov
2007-10-21 21:15                     ` Paul Pogonyshev
2007-10-22  1:22                   ` Stefan Monnier [this message]
2007-10-26  3:48                     ` Richard Stallman
2007-10-28 14:41                       ` Paul Pogonyshev
2007-10-29  9:22                         ` Richard Stallman
2007-10-30 14:16                           ` Juri Linkov
2007-10-31  7:46                             ` Richard Stallman
2007-10-31 21:39                               ` Paul Pogonyshev
2007-11-01  7:32                                 ` Richard Stallman
2007-11-02 20:58                                   ` Paul Pogonyshev
2007-11-10 15:01                                     ` Paul Pogonyshev
2007-11-11  5:21                                       ` Richard Stallman
2007-11-10 21:54                                     ` Juri Linkov
2007-10-23  7:12                   ` Richard Stallman
2007-10-23  8:16                     ` David Kastrup
2007-10-23 17:53                       ` Richard Stallman
2007-10-23 19:03                         ` Lennart Borgman (gmail)
2007-10-24  8:32                           ` Richard Stallman

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=jwvve90ynjf.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=juri@jurta.org \
    --cc=pogonyshev@gmx.net \
    --cc=rms@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.