From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Barry Margolin Newsgroups: gmane.emacs.bugs Subject: Re: re-search-backward does not properly report starting point or matching string Date: Thu, 09 Oct 2003 18:49:12 GMT Organization: Level(3) Communications, Woburn, MA Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1065725433 21735 80.91.224.253 (9 Oct 2003 18:50:33 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 9 Oct 2003 18:50:33 +0000 (UTC) Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Oct 09 20:50:31 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1A7frr-0002a2-00 for ; Thu, 09 Oct 2003 20:50:31 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1A7frg-0004bb-0a for geb-bug-gnu-emacs@m.gmane.org; Thu, 09 Oct 2003 14:50:20 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1A7frb-0004aQ-N2 for bug-gnu-emacs@prep.ai.mit.edu; Thu, 09 Oct 2003 14:50:15 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1A7fr5-0004P7-Bx for bug-gnu-emacs@prep.ai.mit.edu; Thu, 09 Oct 2003 14:50:14 -0400 Original-Received: from [199.171.54.202] (helo=sac1-1.relay.mail.uu.net) by monty-python.gnu.org with esmtp (Exim 4.24) id 1A7fr4-0004MP-PQ for bug-gnu-emacs@prep.ai.mit.edu; Thu, 09 Oct 2003 14:49:42 -0400 Original-Received: from cc26-01.idc1.level3.com by sosrv31.sac1.maint.ops.us.uu.net with ESMTP (peer crosschecked as: machine77.Level3.com [209.244.4.106]) id QQpjrv20655 for ; Thu, 9 Oct 2003 18:49:30 GMT Original-Received: from cc26-01.idc1.level3.com (localhost [127.0.0.1]) by localhost.level3.com (Postfix) with ESMTP id 70F7E87120 for ; Thu, 9 Oct 2003 18:49:14 +0000 (GMT) Original-Received: from f10211-05.adc1.level3.com (mailmgmt.l3.com [10.1.24.134]) by cc26-01.idc1.level3.com (Postfix) with ESMTP id E7B2C85829 for ; Thu, 9 Oct 2003 18:49:13 +0000 (GMT) Original-Received: by f10211-05.adc1.level3.com (8.11.6+Sun/8.11.6) id h99InD503454; Thu, 9 Oct 2003 18:49:13 GMT X-Authentication-Warning: f10211-05.adc1.level3.com: news set sender to planet-newscrap using -f Original-To: gnu-emacs-bug@moderators.isc.org Original-Path: 53ab2750!not-for-mail Original-Newsgroups: gnu.emacs.bug Mail-Copies-To: never X-Newsreader: trn 4.0-test72 (19 April 1999) Originator: barmar@genuity.net (Barry Margolin) Original-Lines: 35 Original-NNTP-Posting-Host: 171.78.176.30 Original-X-Trace: news.level3.com 1065725352 171.78.176.30 (Thu, 09 Oct 2003 18:49:12 GMT) Original-NNTP-Posting-Date: Thu, 09 Oct 2003 18:49:12 GMT X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Bug reports for GNU Emacs, the Swiss army knife of text editors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.bugs:5950 X-Report-Spam: http://spam.gmane.org/gmane.emacs.bugs:5950 In article , >Eval the following, trivial, test function: > >(defun z-test () > (interactive) > (re-search-backward "[a-z]+") > (message (format "point: %d, beginning: %d, end: %d, string: %s" >(point) (match-beginning 0) (match-end 0) (match-string 0))) > ) > >Then, place cursor at the end of the string "sdfds" and run >z-test. A message like this will show up: > >point: 1446, beginning: 1446, end: 1447, string: s > >It reports only on the last character matched by the pattern. > >It seems to me that re-search-backward works conceptually differently >from an search-backward, search-forward and re-search-forward. It does >not "advance" (backwards) the cursor to the real beginning of the >pattern, like the other functions, including search-backward do (see >more on this at *1*). But, whatever justification there might be for >that (if there is any), clearly, the "match-string" is incorrect. A search stops as soon as it finds a string that matches the pattern. When starting from the end of the string "sdfds", it goes back one character and discovers that it has a match, so it stops immediately. The fact that it would also have a match that ends at the same place if it kept searching backward is irrelevant. -- Barry Margolin, barry.margolin@level3.com Level(3), Woburn, MA *** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups. Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.