unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Jack Duthen <duthen.mac.01@gmail.com>
To: 11025@debbugs.gnu.org
Subject: bug#11025: Fwd: bug#9681: Broken behaviour of re-search-backward (.+ matching only a single character)
Date: Fri, 16 Mar 2012 17:29:20 +0100	[thread overview]
Message-ID: <CALGVPOogv+D847F0-Z+0XetXxFGNjKXSDUgNoUWM=nG7N2pe0g@mail.gmail.com> (raw)
In-Reply-To: <CALGVPOqN9zv_vdhrMxQ8e0Ai-EsB9pu8=_MtrFfXd61NArA+SQ@mail.gmail.com>

Oops!  It's a feature, not a bug...
Sorry for the noise.

I just found the same problem addressed in bug#9681.
I understood the current behavior of re-search-backward.
see my reply.
sincerely
)jack(

---------- Forwarded message ----------
From: Jack Duthen <duthen.mac.01@gmail.com>
Date: 2012/3/16
Subject: Re: bug#9681: Broken behaviour of re-search-backward (.+
matching only a single character)
To: bug-gnu-emacs@gnu.org

On Thu, Oct 06, 2011 at 08:57:09AM -0400, Stefan Monnier wrote:
> re-search-* stops at the first character position that has a match.
> And then it chooses the longest match at that position.

Stepan wrote:
> So, again: it definitely needs better documentation,
> and IMO it also needs fixing.

Hi!

For my own imenu-prev-index-position-function, I needed
a backward regexp search which would match something like ".+"
the way one (like Stepan) can expect rather than the way it actually
does (as described by Stefan).

So, I just wrote a function to do that.

The way it handles the COUNT variable is not as good as one could want
but, as I almost never use it, I don't care.
It's not very efficient but, since I can't notice the time it takes
when used in the "*rescan" menu and since I can't imagine a better algorithm,
it's ok for me.

(defun jd-re-search-backward (regexp &optional bound noerror count)
 (let ((orig-point (point)) bom)
   (when (re-search-backward regexp bound noerror count)
     (setq bom (point)) ; should not be useful
     (goto-char (point-min))
     (while (re-search-forward regexp orig-point 'noerror)
       ;; remember the last beginning of match
       (setq bom (match-beginning 0)))
     (goto-char bom)
     ;; set match data (erased by the last failing search) and return T
     (looking-at regexp))))

HTH
)jack(





      reply	other threads:[~2012-03-16 16:29 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
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   ` Jack Duthen [this message]

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='CALGVPOogv+D847F0-Z+0XetXxFGNjKXSDUgNoUWM=nG7N2pe0g@mail.gmail.com' \
    --to=duthen.mac.01@gmail.com \
    --cc=11025@debbugs.gnu.org \
    /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).