unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Štěpán Němec" <stepnem@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 9681@debbugs.gnu.org
Subject: bug#9681: Broken behaviour of re-search-backward (.+ matching only a single character)
Date: Thu, 06 Oct 2011 20:48:51 +0200	[thread overview]
Message-ID: <87ty7mymzw.fsf@gmail.com> (raw)
In-Reply-To: <jwv8voyl1nl.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Thu, 06 Oct 2011 08:57:09 -0400")

[Stefan: sorry for two replies, I forgot to cc the bug list in my first
reply, also, I've changed my mind on some of the points since then, see
below.]

On Thu, Oct 06, 2011 at 08:57:09AM -0400, Stefan Monnier wrote:
> > If this curious inconsistency of `re-search-backward' with
> > `re-search-forward' is intentional (which I hope it is not), it should
> > be documented, but I couldn't find anything in the manuals or
> > docstrings.
>
> re-search-* stops at the first character position that has a match.
> And then it chooses the longest match at that position.

Thanks, but I'm not sure I understand what you mean here. Naturally, the
longest match for `re-search-backward' should be backward, not forward,
i.e. using your wording above, when searching _backward_ for \w+ in
"foobar|" where "|" is point, the "first character position that has a
match" might be "r", but it's hardly the longest match.

If I'm the only one who considers this behaviour broken (by design?[1]),
which I very much doubt, it definitely needs to at least be documented,
as I'm certainly not the only one who is very surprised by this
behaviour. In my opinion it should be fixed, though.

[1] Cf. e.g. ?\w\+ in Vim, which does the right thing.

--
Štěpán





  reply	other threads:[~2011-10-06 18:48 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-06  9:13 bug#9681: Broken behaviour of re-search-backward (.+ matching only a single character) Štěpán Němec
2011-10-06 12:57 ` Stefan Monnier
2011-10-06 18:48   ` Štěpán Němec [this message]
2011-10-07 13:02     ` Stefan Monnier
2011-10-07 13:19       ` Štěpán Němec
2011-10-11  2:03       ` Kenichi Handa
2011-10-11  3:56         ` Stefan Monnier
2011-10-06 19:46 ` Johan Bockgård
2012-03-16 15:49 ` Jack Duthen
2012-03-16 16:29   ` bug#11025: Fwd: " Jack Duthen

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=87ty7mymzw.fsf@gmail.com \
    --to=stepnem@gmail.com \
    --cc=9681@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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).