|
From: | Stefan Monnier |
Subject: | Re: [patch] Re: regexp repacement, how to present replacement to user? |
Date: | Sun, 21 Oct 2007 21:22:54 -0400 |
User-agent: | Gnus/5.11 (Gnus v5.11) Emacs/23.0.50 (gnu/linux) |
> 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
[Prev in Thread] | Current Thread | [Next in Thread] |