From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.devel Subject: Re: match-data confusion... Date: 18 Jun 2004 13:42:54 +0200 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1087559016 902 80.91.224.253 (18 Jun 2004 11:43:36 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 18 Jun 2004 11:43:36 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Fri Jun 18 13:43:30 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BbHmM-0001yt-00 for ; Fri, 18 Jun 2004 13:43:30 +0200 Original-Received: from lists.gnu.org ([199.232.76.165]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BbHmL-00061r-00 for ; Fri, 18 Jun 2004 13:43:29 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BbHnR-0007hg-9t for emacs-devel@quimby.gnus.org; Fri, 18 Jun 2004 07:44:37 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BbHnO-0007hb-PQ for emacs-devel@gnu.org; Fri, 18 Jun 2004 07:44:34 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BbHnO-0007hO-5X for emacs-devel@gnu.org; Fri, 18 Jun 2004 07:44:34 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BbHnO-0007hL-0t for emacs-devel@gnu.org; Fri, 18 Jun 2004 07:44:34 -0400 Original-Received: from [199.232.76.164] (helo=fencepost.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BbHlo-0005Yd-4j for emacs-devel@gnu.org; Fri, 18 Jun 2004 07:42:56 -0400 Original-Received: from localhost ([127.0.0.1] helo=lola.goethe.zz) by fencepost.gnu.org with esmtp (Exim 4.34) id 1BbHln-00008E-Dc for emacs-devel@gnu.org; Fri, 18 Jun 2004 07:42:56 -0400 Original-To: emacs-devel@gnu.org In-Reply-To: Original-Lines: 45 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:25081 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:25081 David Kastrup writes: > I am having a problem with getting stuff right in replace.el. > > The problem is that > > (match-data t) is basically dangerous since it is lacking the > information to restore last_thing_searched. But that means that > (set-match-data (match-data t)) is not a noop, even if the buffer is > not changed in between since the restored match-data stops being > adjusted when buffer changes occur before it. Well, ok, so this adjustment would not happen anyway as I see from the code, since last_thing_searched is only accessed in search.c. Let's put it differently: (match-data) is not equivalent to (progn (set-match-data (match-data t)) (match-data)) This means that I can't convert something fetched with (match-data t) into some set of markers in the simple way. Anyway, I see several ways round the problem I have in replace.el: a) ignore the problem. That means that if people edit before point and then perform this or a previous replacement, it will happen at the wrong point. b) set a read-only overlay on everything that could affect recorded buffer positions where replacements might still occur. c) set a modification-hook overlay on everything that could affect such buffer positions. When it triggers, convert all possibly affected match-data sets into markers manually. d) use markers in the first place for everything, but make sure to invalidate them as soon as they are not needed anymore. I think I tend to option d). The reason is that the only case where we get pending markers is that where a replacement was voted "n" by the user, in interactive use. But in that case, I don't think we are being overly time-critical, anyway. But I still think that a possibility for restoring last_thing_matched with set-match-data even in the case that the data was extracted using (match-data t) is warranted. -- David Kastrup, Kriemhildstr. 15, 44793 Bochum