all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Barry Margolin <barry.margolin@level3.com>
Subject: Re: re-search-backward does not properly report starting point or matching string
Date: Thu, 09 Oct 2003 18:49:12 GMT	[thread overview]
Message-ID: <I4ihb.267$pd.46@news.level3.com> (raw)
In-Reply-To: mailman.1430.1065723442.21628.bug-gnu-emacs@gnu.org

In article <mailman.1430.1065723442.21628.bug-gnu-emacs@gnu.org>,
>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.

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

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

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

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

  git send-email \
    --in-reply-to='I4ihb.267$pd.46@news.level3.com' \
    --to=barry.margolin@level3.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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.