From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Stephen J. Turnbull" Newsgroups: gmane.emacs.devel Subject: Document that failed search/match preserves match data Date: Fri, 09 May 2003 23:14:05 +0900 Organization: The XEmacs Project Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <87d6isi4wi.fsf@tleepslib.sk.tsukuba.ac.jp> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1052490130 2622 80.91.224.249 (9 May 2003 14:22:10 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 9 May 2003 14:22:10 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Fri May 09 16:22:08 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19E8jx-0000ar-00 for ; Fri, 09 May 2003 16:20:49 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 19E8ow-00070e-00 for ; Fri, 09 May 2003 16:25:58 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 19E8iO-0000PY-00 for emacs-devel@quimby.gnus.org; Fri, 09 May 2003 10:19:12 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 19E8hC-0007yA-00 for emacs-devel@gnu.org; Fri, 09 May 2003 10:17:58 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 19E8h5-0007uu-00 for emacs-devel@gnu.org; Fri, 09 May 2003 10:17:52 -0400 Original-Received: from tleepslib.sk.tsukuba.ac.jp ([130.158.98.109]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 19E8eH-0006KA-00 for emacs-devel@gnu.org; Fri, 09 May 2003 10:14:57 -0400 Original-Received: from steve by tleepslib.sk.tsukuba.ac.jp with local (Exim 3.36 #1 (Debian)) id 19E8dU-0002jk-00 for ; Fri, 09 May 2003 23:14:08 +0900 Original-To: emacs-devel@gnu.org User-Agent: Gnus/5.090016 (Oort Gnus v0.16) XEmacs/21.5 (cabbage) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Emacs development discussions. List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:13785 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:13785 Currently in both XEmacs and Emacs a failed search will preserve the match data from the last successful search (this is true for XEmacs from regression testing and verifying the code, and if I interpreted a communication with Stefan Monnier correctly, it is true for Emacs). However, until now the documentation for both Emacsen strongly implied (to my mind) that any call to a search or match function would clobber the match data. As an experiment, in XEmacs I changed it to clear the match data even on failure, and (as you would expect) got a bunch of bug reports. This led me to some elegant examples (the function `w3-configuration-data' in "w3-cfg" is a good one, I think) which depend on match failure preserving previous match data in an essential way. (Of course you could work around it but it would be real ugly.) I propose that the docstrings and Info documentation for both Emacsen be amended to reflect the (common) behavior of the implementations, since it seems to be useful. That is, we state that "On success, a search or match sets the match data for the whole expression and any matched subexpressions. If the search or match fails, the match data from the most recent successful search will be preserved. (You should not depend on the match data being preserved in case of an error in the search function.)"[1] Footnotes: [1] In the case of XEmacs, I'm pretty sure that even on errors the previous match data is preserved, but of course that's a little harder to be sure of than with normal termination. -- Institute of Policy and Planning Sciences http://turnbull.sk.tsukuba.ac.jp University of Tsukuba Tennodai 1-1-1 Tsukuba 305-8573 JAPAN Ask not how you can "do" free software business; ask what your business can "do for" free software.