From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [patch] Re: regexp repacement, how to present replacement to user? Date: Sun, 21 Oct 2007 21:22:54 -0400 Message-ID: References: <200710131700.42100.pogonyshev@gmx.net> <200710201653.57778.pogonyshev@gmx.net> <200710212200.38685.pogonyshev@gmx.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1193016193 29995 80.91.229.12 (22 Oct 2007 01:23:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 22 Oct 2007 01:23:13 +0000 (UTC) Cc: juri@jurta.org, rms@gnu.org, emacs-devel@gnu.org To: Paul Pogonyshev Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Oct 22 03:23:12 2007 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.50) id 1Ijm0e-0003U1-0K for ged-emacs-devel@m.gmane.org; Mon, 22 Oct 2007 03:23:12 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ijm0W-0005hj-1Y for ged-emacs-devel@m.gmane.org; Sun, 21 Oct 2007 21:23:04 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ijm0S-0005eN-NF for emacs-devel@gnu.org; Sun, 21 Oct 2007 21:23:00 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ijm0R-0005cz-Ty for emacs-devel@gnu.org; Sun, 21 Oct 2007 21:23:00 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ijm0R-0005co-PR for emacs-devel@gnu.org; Sun, 21 Oct 2007 21:22:59 -0400 Original-Received: from tomts25.bellnexxia.net ([209.226.175.188] helo=tomts25-srv.bellnexxia.net) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Ijm0N-0002PX-MU; Sun, 21 Oct 2007 21:22:55 -0400 Original-Received: from pastel.home ([74.12.205.156]) by tomts25-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20071022012254.CJED19497.tomts25-srv.bellnexxia.net@pastel.home>; Sun, 21 Oct 2007 21:22:54 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 7494B7FBA; Sun, 21 Oct 2007 21:22:54 -0400 (EDT) In-Reply-To: <200710212200.38685.pogonyshev@gmx.net> (Paul Pogonyshev's message of "Sun\, 21 Oct 2007 22\:00\:38 +0300") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.50 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Solaris 8 (1) 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:81420 Archived-At: > 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