From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jack Duthen Newsgroups: gmane.emacs.bugs 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 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1331915466 8164 80.91.229.3 (16 Mar 2012 16:31:06 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 16 Mar 2012 16:31:06 +0000 (UTC) To: 11025@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Mar 16 17:31:03 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1S8a3T-0003w8-Bd for geb-bug-gnu-emacs@m.gmane.org; Fri, 16 Mar 2012 17:31:03 +0100 Original-Received: from localhost ([::1]:37412 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S8a3S-00053k-OE for geb-bug-gnu-emacs@m.gmane.org; Fri, 16 Mar 2012 12:31:02 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:43434) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S8a3K-00050o-Qx for bug-gnu-emacs@gnu.org; Fri, 16 Mar 2012 12:31:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S8a3E-0008SH-EI for bug-gnu-emacs@gnu.org; Fri, 16 Mar 2012 12:30:54 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:46856) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S8a3E-0008SA-5O for bug-gnu-emacs@gnu.org; Fri, 16 Mar 2012 12:30:48 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1S8aWT-00069m-JC for bug-gnu-emacs@gnu.org; Fri, 16 Mar 2012 13:01:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jack Duthen Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 16 Mar 2012 17:01:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11025 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 11025-submit@debbugs.gnu.org id=B11025.133191720923601 (code B ref 11025); Fri, 16 Mar 2012 17:01:01 +0000 Original-Received: (at 11025) by debbugs.gnu.org; 16 Mar 2012 17:00:09 +0000 Original-Received: from localhost ([127.0.0.1]:53688 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1S8aVc-00068b-JJ for submit@debbugs.gnu.org; Fri, 16 Mar 2012 13:00:09 -0400 Original-Received: from mail-gx0-f172.google.com ([209.85.161.172]:48707) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1S8aVP-00067G-Me for 11025@debbugs.gnu.org; Fri, 16 Mar 2012 13:00:06 -0400 Original-Received: by ggmi1 with SMTP id i1so4268108ggm.3 for <11025@debbugs.gnu.org>; Fri, 16 Mar 2012 09:29:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:content-type :content-transfer-encoding; bh=fAlN8UMtH5JR3NQq2h7s2vZqEtpXHjadw9eMcZzeuS8=; b=vmsvYQIdda5DxDBGCCWZcJDKSb39BkkYIe9faeKYMc0G4TSrb3yj2SCtU6KGJ/aNDE zHJOQy+0B608r7w9nD9TJpsubvQGh3HAhHJL75xjz5oyeHn2TbQG4lmeW01pAa8lJj5W 5AenuUeDBey/QpWcSqD3C6JcfTS39doRrt+u2MW4c+Rn3Qt79dBuUXBIkePLh7BDr+SM MYKOPyHs1stJ25ksIfaWUBUZa8H1HuD2Y1kkCR+lp7GiKBq3dMaS6rN2YH1eQa3uYLaW qEus9SGUqOgzkfJS1EIjLkgNzgR5jeuUKzm/GAu9fXkOXlacM7VQCwf/mgZI4V8VQquA EgLw== Original-Received: by 10.60.22.233 with SMTP id h9mr3997739oef.30.1331915380662; Fri, 16 Mar 2012 09:29:40 -0700 (PDT) Original-Received: by 10.182.171.97 with HTTP; Fri, 16 Mar 2012 09:29:20 -0700 (PDT) In-Reply-To: X-Google-Sender-Auth: hYdT2kM8V1CGT_cMQtIDBxsyZgw X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org 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 Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:57828 Archived-At: 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 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 algorith= m, it's ok for me. (defun jd-re-search-backward (regexp &optional bound noerror count) =A0(let ((orig-point (point)) bom) =A0 =A0(when (re-search-backward regexp bound noerror count) =A0 =A0 =A0(setq bom (point)) ; should not be useful =A0 =A0 =A0(goto-char (point-min)) =A0 =A0 =A0(while (re-search-forward regexp orig-point 'noerror) =A0 =A0 =A0 =A0;; remember the last beginning of match =A0 =A0 =A0 =A0(setq bom (match-beginning 0))) =A0 =A0 =A0(goto-char bom) =A0 =A0 =A0;; set match data (erased by the last failing search) and return= T =A0 =A0 =A0(looking-at regexp)))) HTH )jack(