From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Luiz-Otavio Zorzella Newsgroups: gmane.emacs.bugs Subject: re-search-backward does not properly report starting point or matching string Date: Thu, 09 Oct 2003 11:16:34 -0700 Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Message-ID: <3F85A602.8010100@zorzella.com> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1065723482 17791 80.91.224.253 (9 Oct 2003 18:18:02 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 9 Oct 2003 18:18:02 +0000 (UTC) Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Oct 09 20:17:59 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 1A7fMN-0000HT-00 for ; Thu, 09 Oct 2003 20:17:59 +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 1A7fMG-0000VN-0e for geb-bug-gnu-emacs@m.gmane.org; Thu, 09 Oct 2003 14:17:52 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1A7fLj-0000Q6-Qs for bug-gnu-emacs@gnu.org; Thu, 09 Oct 2003 14:17:19 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1A7fLD-0000JD-F4 for bug-gnu-emacs@gnu.org; Thu, 09 Oct 2003 14:17:18 -0400 Original-Received: from [209.10.220.200] (helo=whitney.iospanwireless.com) by monty-python.gnu.org with esmtp (Exim 4.24) id 1A7fLA-0000I1-7m for bug-gnu-emacs@gnu.org; Thu, 09 Oct 2003 14:16:44 -0400 Original-Received: from iospanwireless.com (k2.iospanwireless.com [192.168.0.46]) by whitney.iospanwireless.com (Postfix) with ESMTP id ECF213DE03B for ; Thu, 9 Oct 2003 11:16:32 -0700 (PDT) Original-Received: from zorzella.com (LZORZELLA.iospanwireless.com [192.168.0.72]) by iospanwireless.com (8.9.3/8.9.3) with ESMTP id LAA22861 for ; Thu, 9 Oct 2003 11:16:12 -0700 User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en Original-To: bug-gnu-emacs@gnu.org 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:5948 X-Report-Spam: http://spam.gmane.org/gmane.emacs.bugs:5948 This bug report will be sent to the Free Software Foundation, not to your local site managers! Please write in English, because the Emacs maintainers do not have translators to read other languages for them. Your bug report will be posted to the bug-gnu-emacs@gnu.org mailing list, and to the gnu.emacs.bug news group. In GNU Emacs 21.2.1 (i386-debian-linux-gnu, X toolkit, Xaw3d scroll bars) of 2002-03-22 on raven, modified by Debian configured using `configure i386-debian-linux-gnu --prefix=/usr --sharedstatedir=/var/lib --libexecdir=/usr/lib --localstatedir=/var/lib --infodir=/usr/share/info --mandir=/usr/share/man --with-pop=yes --with-x=yes --with-x-toolkit=athena --without-gif' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: nil value of $LC_CTYPE: nil value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: nil locale-coding-system: nil default-enable-multibyte-characters: nil Please describe exactly what actions triggered the bug and the precise symptoms of the bug: 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. Interestingly, the interactive version of the function that highlights the matched string as you type it can properly identify the boundaries of the correct "match-string". But even that is not always bug-free. Applying the trivial expression "a+b" to the string "aaab" only highlights the last "a" and the "b". As it is my understanding, regexps should match the largest possible matching set of characters. Using just "a+" as the expression will properly highlight all the "a"s, of course. (*1*) Not placing the cursor at the beginning of the pattern is bad for a number of reasons: (a) it makes it inconsistent with the behaviour of the other three functions; (b) it prevents the use of it for standard scripting like "(set-mark (point)) (re-search-backwards "a+") (kill-region (mark) (point))"; (c) it is outright silly that interactivelly doing a backwards search for "a+" would need 10 hits of "CTRL-R" to get past the string "aaaaaaaaaa". Thanks for the nice work with my beloved emacs, Zorzella