unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Luiz-Otavio Zorzella <z0116@zorzella.com>
Subject: re-search-backward does not properly report starting point or matching string
Date: Thu, 09 Oct 2003 11:16:34 -0700	[thread overview]
Message-ID: <3F85A602.8010100@zorzella.com> (raw)

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

             reply	other threads:[~2003-10-09 18:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-09 18:16 Luiz-Otavio Zorzella [this message]
     [not found] <mailman.1430.1065723442.21628.bug-gnu-emacs@gnu.org>
2003-10-09 18:49 ` re-search-backward does not properly report starting point or matching string Barry Margolin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3F85A602.8010100@zorzella.com \
    --to=z0116@zorzella.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).