From unknown Wed Jun 18 23:04:14 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#9681 <9681@debbugs.gnu.org> To: bug#9681 <9681@debbugs.gnu.org> Subject: Status: Broken behaviour of re-search-backward (.+ matching only a single character) Reply-To: bug#9681 <9681@debbugs.gnu.org> Date: Thu, 19 Jun 2025 06:04:14 +0000 retitle 9681 Broken behaviour of re-search-backward (.+ matching only a sin= gle character) reassign 9681 emacs submitter 9681 =C5=A0t=C4=9Bp=C3=A1n N=C4=9Bmec severity 9681 minor tag 9681 notabug thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 06 05:19:19 2011 Received: (at submit) by debbugs.gnu.org; 6 Oct 2011 09:19:19 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RBk6n-0000Zn-VX for submit@debbugs.gnu.org; Thu, 06 Oct 2011 05:19:19 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RBk6k-0000ZV-SE for submit@debbugs.gnu.org; Thu, 06 Oct 2011 05:19:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RBk6T-0008A7-Ec for submit@debbugs.gnu.org; Thu, 06 Oct 2011 05:19:01 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([140.186.70.17]:34672) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RBk6T-0008A3-D8 for submit@debbugs.gnu.org; Thu, 06 Oct 2011 05:18:57 -0400 Received: from eggs.gnu.org ([140.186.70.92]:48242) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RBk6S-0001vm-5O for bug-gnu-emacs@gnu.org; Thu, 06 Oct 2011 05:18:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RBk6R-00089W-26 for bug-gnu-emacs@gnu.org; Thu, 06 Oct 2011 05:18:56 -0400 Received: from mail-ey0-f169.google.com ([209.85.215.169]:53969) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RBk6Q-00089Q-Rz for bug-gnu-emacs@gnu.org; Thu, 06 Oct 2011 05:18:55 -0400 Received: by eye13 with SMTP id 13so2793596eye.0 for ; Thu, 06 Oct 2011 02:18:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; bh=rpLETk11jL8pshwGx+xy1uuRCQJ/fjc1fLyw8Kr9u5o=; b=hz4pRW8a4IAxb1Ch0AC0ESCDA130uLs1uw0u0hj5aiiUXT92wgZqUsiqk1p4lOCWyh eLZLTegfjcIUqT6WxjsxwMzgjyTC9WDNkrGCG3yTeE+IgrEyVoN1jMJoYLOVWuKXfZLk 3W5mnpERq0RSQFOZKRulLcJ42bh7EF7Pin04w= Received: by 10.223.58.138 with SMTP id g10mr2370840fah.20.1317892733759; Thu, 06 Oct 2011 02:18:53 -0700 (PDT) Received: from localhost (176.119.broadband10.iol.cz. [90.177.119.176]) by mx.google.com with ESMTPS id w6sm6311263fah.0.2011.10.06.02.18.52 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 06 Oct 2011 02:18:52 -0700 (PDT) From: =?utf-8?B?xaB0xJtww6FuIE7Em21lYw==?= To: bug-gnu-emacs Subject: Broken behaviour of re-search-backward (.+ matching only a single character) Date: Thu, 06 Oct 2011 11:13:26 +0200 Message-ID: <8762k21o09.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -4.9 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.9 (----) Quoting from : =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > What am I doing wrong? Nothing, I think :-). I personally don't use fancy split- ting, but a deeper look at (at least Gnus 5.13's) code seems to locate the culprit in Emacs' *backward* regular expres- sion "non-greedity": Position point at the end of "bugzilla.gdm", C-u C-r "\w+" - et voil=C3=A0, only one character is matched. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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. --=20 =C5=A0t=C4=9Bp=C3=A1n From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 06 08:57:44 2011 Received: (at 9681) by debbugs.gnu.org; 6 Oct 2011 12:57:45 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RBnWC-0007Be-DZ for submit@debbugs.gnu.org; Thu, 06 Oct 2011 08:57:44 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RBnW7-0007BO-9L for 9681@debbugs.gnu.org; Thu, 06 Oct 2011 08:57:41 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgwKAFaljU7O+JxS/2dsb2JhbABEmQ2PIIEGgVMBAQQBViMFCws0EhQYDSSIEbcPhywEoQyERA X-IronPort-AV: E=Sophos;i="4.68,496,1312171200"; d="scan'208";a="140139862" Received: from 206-248-156-82.dsl.teksavvy.com (HELO pastel.home) ([206.248.156.82]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 06 Oct 2011 08:57:09 -0400 Received: by pastel.home (Postfix, from userid 20848) id A3A2A592D4; Thu, 6 Oct 2011 08:57:09 -0400 (EDT) From: Stefan Monnier To: =?utf-8?B?xaB0xJtww6FuIE7Em21lYw==?= Subject: Re: bug#9681: Broken behaviour of re-search-backward (.+ matching only a single character) Message-ID: References: <8762k21o09.fsf@gmail.com> Date: Thu, 06 Oct 2011 08:57:09 -0400 In-Reply-To: <8762k21o09.fsf@gmail.com> (=?utf-8?B?IsWgdMSbcMOhbiBOxJtt?= =?utf-8?B?ZWMiJ3M=?= message of "Thu, 06 Oct 2011 11:13:26 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.90 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.7 (--) X-Debbugs-Envelope-To: 9681 Cc: 9681@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.7 (--) > 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. Stefan From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 06 14:54:39 2011 Received: (at 9681) by debbugs.gnu.org; 6 Oct 2011 18:54:39 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RBt5a-0000Q4-OA for submit@debbugs.gnu.org; Thu, 06 Oct 2011 14:54:39 -0400 Received: from mail-bw0-f44.google.com ([209.85.214.44]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RBt5X-0000Pp-VI for 9681@debbugs.gnu.org; Thu, 06 Oct 2011 14:54:36 -0400 Received: by bkaq10 with SMTP id q10so3488038bka.3 for <9681@debbugs.gnu.org>; Thu, 06 Oct 2011 11:54:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version:content-type:content-transfer-encoding; bh=oQz1NFIxT1Ys0D+ZnBivNEiyiGG2ajCKFCZScrO9azk=; b=EgygNoY2fh4nS9r1xcOeUUPyX0sLuna3Ku1PvxnB8gHW0ZiXuW7sZwEgbdeZIljx+W ZxaNob1Znqz5gYSFBxif0dD5bnRZ4JdjEfFeLD3UgyNRVng2XAXRCKbaGp2uWW3ytjXO RgGRq0erJ5ti8jCiUFS8phCVybLlRpGGg3XL4= Received: by 10.204.137.208 with SMTP id x16mr786034bkt.373.1317927259989; Thu, 06 Oct 2011 11:54:19 -0700 (PDT) Received: from localhost (176.119.broadband10.iol.cz. [90.177.119.176]) by mx.google.com with ESMTPS id t13sm14026825fae.0.2011.10.06.11.54.18 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 06 Oct 2011 11:54:18 -0700 (PDT) From: =?utf-8?B?xaB0xJtww6FuIE7Em21lYw==?= To: Stefan Monnier Subject: Re: bug#9681: Broken behaviour of re-search-backward (.+ matching only a single character) In-Reply-To: (Stefan Monnier's message of "Thu, 06 Oct 2011 08:57:09 -0400") References: <8762k21o09.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) Date: Thu, 06 Oct 2011 20:48:51 +0200 Message-ID: <87ty7mymzw.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.8 (--) X-Debbugs-Envelope-To: 9681 Cc: 9681@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.8 (--) [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. -- =C5=A0t=C4=9Bp=C3=A1n From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 06 15:47:00 2011 Received: (at 9681) by debbugs.gnu.org; 6 Oct 2011 19:47:00 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RBtuG-0003vK-21 for submit@debbugs.gnu.org; Thu, 06 Oct 2011 15:47:00 -0400 Received: from smtprelay-b11.telenor.se ([62.127.194.20]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RBtuD-0003v5-Dg for 9681@debbugs.gnu.org; Thu, 06 Oct 2011 15:46:58 -0400 Received: from iph3.telenor.se (iph3.telenor.se [195.54.127.134]) by smtprelay-b11.telenor.se (Postfix) with ESMTP id 1D199EB57F for <9681@debbugs.gnu.org>; Thu, 6 Oct 2011 21:46:40 +0200 (CEST) X-SMTPAUTH-B2: [bocjoh] X-SENDER-IP: [85.228.201.51] X-LISTENER: [smtp.bredband.net] X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Au69AFsFjk5V5MkzPGdsb2JhbABChCZOhEePUgKPIxkBAQEBNzKBUwEBBAEMFzMjBQsJAhoCBSECAg8BBA0LAQwKGhOHfgKnN5FQgS2Ea4EUBJ4QhyY X-IronPort-AV: E=Sophos;i="4.68,498,1312149600"; d="scan'208";a="126621245" Received: from c-33c9e455.04-211-6c6b701.cust.bredbandsbolaget.se (HELO muon.localdomain) ([85.228.201.51]) by iph3.telenor.se with ESMTP; 06 Oct 2011 21:46:34 +0200 Received: by muon.localdomain (Postfix, from userid 1000) id B5CB54841CA; Thu, 6 Oct 2011 21:46:33 +0200 (CEST) From: =?utf-8?Q?Johan_Bockg=C3=A5rd?= To: =?utf-8?B?xaB0xJtww6FuIE7Em21lYw==?= Subject: Re: bug#9681: Broken behaviour of re-search-backward (.+ matching only a single character) References: <8762k21o09.fsf@gmail.com> Mail-Copies-To: never Date: Thu, 06 Oct 2011 21:46:32 +0200 In-Reply-To: <8762k21o09.fsf@gmail.com> (=?utf-8?B?IsWgdMSbcMOhbiBOxJtt?= =?utf-8?B?ZWMiJ3M=?= message of "Thu, 06 Oct 2011 11:13:26 +0200") Message-ID: <87d3e97vjb.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.90 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.4 (--) X-Debbugs-Envelope-To: 9681 Cc: 9681@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.4 (--) =C5=A0t=C4=9Bp=C3=A1n N=C4=9Bmec writes: > 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. Then you must not have looked very hard. From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 07 09:03:01 2011 Received: (at 9681) by debbugs.gnu.org; 7 Oct 2011 13:03:01 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RCA4o-0006cI-JI for submit@debbugs.gnu.org; Fri, 07 Oct 2011 09:03:01 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.183] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RCA4l-0006c0-Qz for 9681@debbugs.gnu.org; Fri, 07 Oct 2011 09:02:57 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EAB34jk7O+JxS/2dsb2JhbABEqDyBBoFTAQEEAVYjBQsLNBIUGA0kiBG5BocxBKEOhEU X-IronPort-AV: E=Sophos;i="4.68,502,1312171200"; d="scan'208";a="140241964" Received: from 206-248-156-82.dsl.teksavvy.com (HELO pastel.home) ([206.248.156.82]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 07 Oct 2011 09:02:19 -0400 Received: by pastel.home (Postfix, from userid 20848) id B3C9E592D6; Fri, 7 Oct 2011 09:02:18 -0400 (EDT) From: Stefan Monnier To: =?utf-8?B?xaB0xJtww6FuIE7Em21lYw==?= Subject: Re: bug#9681: Broken behaviour of re-search-backward (.+ matching only a single character) Message-ID: References: <8762k21o09.fsf@gmail.com> <87ty7mymzw.fsf@gmail.com> Date: Fri, 07 Oct 2011 09:02:18 -0400 In-Reply-To: <87ty7mymzw.fsf@gmail.com> (=?utf-8?B?IsWgdMSbcMOhbiBOxJtt?= =?utf-8?B?ZWMiJ3M=?= message of "Thu, 06 Oct 2011 20:48:51 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.90 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.7 (--) X-Debbugs-Envelope-To: 9681 Cc: 9681@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.7 (--) >> 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, Ah, yes, sorry for being unclear: the search for a match goes backward, but the matching itself goes forward. The docstring of re-search-backward is more clear about that: The match found is the one starting last in the buffer and yet ending before the origin of the search. > If I'm the only one who considers this behaviour broken (by design?[1]), It's not the ideal behavior, admittedly. It's even more obvious in `looking-back'. But fixing it would require the implementation of a backward regexp matcher. Stefan From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 07 09:25:50 2011 Received: (at 9681) by debbugs.gnu.org; 7 Oct 2011 13:25:51 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RCAQv-0007BP-9G for submit@debbugs.gnu.org; Fri, 07 Oct 2011 09:25:50 -0400 Received: from mail-yx0-f172.google.com ([209.85.213.172]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RCAQs-0007B7-9W for 9681@debbugs.gnu.org; Fri, 07 Oct 2011 09:25:47 -0400 Received: by yxt33 with SMTP id 33so3582870yxt.3 for <9681@debbugs.gnu.org>; Fri, 07 Oct 2011 06:25:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=xJu2fP/dTwdxs3rFGsZHI5Nmfd0jNYi2QTuNz38/9UE=; b=P6q6LuV05j4D3tRjUvC0uER5ay9oEZfk3kYmlujTeo1SMimCICB1yytGFMOO/2hU9e 5LijTi4EDyO6Y4+bDbcev/vy0DBqjDi2Yj6e+N7A4odWF7l6nj6BKF2rydEDpUD9OS07 /jeT2gXV9Yn83pSG4IgCalo8s6Bb5/A3uKKDs= Received: by 10.223.15.25 with SMTP id i25mr10747393faa.31.1317993925854; Fri, 07 Oct 2011 06:25:25 -0700 (PDT) Received: from localhost (176.119.broadband10.iol.cz. [90.177.119.176]) by mx.google.com with ESMTPS id h16sm12689961fab.19.2011.10.07.06.25.24 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 07 Oct 2011 06:25:24 -0700 (PDT) Date: Fri, 7 Oct 2011 15:19:56 +0200 From: =?utf-8?B?xaB0xJtww6FuIE7Em21lYw==?= To: Stefan Monnier Subject: Re: bug#9681: Broken behaviour of re-search-backward (.+ matching only a single character) Message-ID: <20111007131956.GA11154@headley> References: <8762k21o09.fsf@gmail.com> <87ty7mymzw.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Score: -3.7 (---) X-Debbugs-Envelope-To: 9681 Cc: 9681@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.7 (---) On Fri, Oct 07, 2011 at 09:02:18AM -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. > > 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, > > Ah, yes, sorry for being unclear: the search for a match goes backward, > but the matching itself goes forward. > > The docstring of re-search-backward is more clear about that: > > The match found is the one starting last in the buffer > and yet ending before the origin of the search. I suppose that is more clear if you already know the behaviour, but I didn't understand it that way, either. I think it should at least add that the match is still forward, not backward, and that it might not behave as expected for regexps containing constructs like * and +. > > If I'm the only one who considers this behaviour broken (by design?[1]), > > It's not the ideal behavior, admittedly. It's even more obvious in > `looking-back'. But fixing it would require the implementation of > a backward regexp matcher. Yeah, as I said above (and as is obvious in the message quoted in the bug report), the set of regexps usable with `re-search-backward' seems to be quite limited, and one has to be very careful when using it (and even some developers apparently fail at that). So, again: it definitely needs better documentation, and IMO it also needs fixing. -- Štěpán From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 10 22:03:49 2011 Received: (at 9681) by debbugs.gnu.org; 11 Oct 2011 02:03:49 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RDRh6-0004F8-MQ for submit@debbugs.gnu.org; Mon, 10 Oct 2011 22:03:49 -0400 Received: from mx1.aist.go.jp ([150.29.246.133]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RDRh3-0004Ew-5f for 9681@debbugs.gnu.org; Mon, 10 Oct 2011 22:03:47 -0400 Received: from rqsmtp1.aist.go.jp (rqsmtp1.aist.go.jp [150.29.254.115]) by mx1.aist.go.jp with ESMTP id p9B23RX4000761; Tue, 11 Oct 2011 11:03:27 +0900 (JST) env-from (handa@m17n.org) Received: from smtp1.aist.go.jp by rqsmtp1.aist.go.jp with ESMTP id p9B23RSl002010; Tue, 11 Oct 2011 11:03:27 +0900 (JST) env-from (handa@m17n.org) Received: by smtp1.aist.go.jp with ESMTP id p9B23QDG003405; Tue, 11 Oct 2011 11:03:26 +0900 (JST) env-from (handa@m17n.org) From: Kenichi Handa To: Stefan Monnier Subject: Re: bug#9681: Broken behaviour of re-search-backward (.+ matching only a single character) In-Reply-To: (message from Stefan Monnier on Fri, 07 Oct 2011 09:02:18 -0400) Date: Tue, 11 Oct 2011 11:03:26 +0900 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.8 (--) X-Debbugs-Envelope-To: 9681 Cc: 9681@debbugs.gnu.org, stepnem@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.8 (--) In article , Stefan Monnier writes: > It's not the ideal behavior, admittedly. It's even more obvious in > `looking-back'. But fixing it would require the implementation of > a backward regexp matcher. FYI, in Mule (the version before integrating into Emacs), we implemented such a feature by doing these: o Regular expression compiler written in Elisp which generates both forward matching and backward matching compiled patterns. o Modify regex.c to accept the above patterns and do backward matching if necessary. I vaguely remember that I discussed this feature with RMS when we were going to integrate Mule's multilingual feature into Emacs, and it was rejected because it's not related to multilingual feature. And actually, that feature had been used very rarely. --- Kenichi Handa handa@m17n.org From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 10 23:56:50 2011 Received: (at 9681) by debbugs.gnu.org; 11 Oct 2011 03:56:50 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RDTSU-0008I2-FB for submit@debbugs.gnu.org; Mon, 10 Oct 2011 23:56:50 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.183] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RDTSS-0008Hp-Be for 9681@debbugs.gnu.org; Mon, 10 Oct 2011 23:56:49 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EAGe9k05FxJoX/2dsb2JhbABDqBqBBoFTAQEEAVYjBQsLNBIUGA0kiBG5WodMBKEdhEU X-IronPort-AV: E=Sophos;i="4.68,521,1312171200"; d="scan'208";a="141082081" Received: from 69-196-154-23.dsl.teksavvy.com (HELO ceviche.home) ([69.196.154.23]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 10 Oct 2011 23:56:28 -0400 Received: by ceviche.home (Postfix, from userid 20848) id B312C660B6; Mon, 10 Oct 2011 23:56:27 -0400 (EDT) From: Stefan Monnier To: Kenichi Handa Subject: Re: bug#9681: Broken behaviour of re-search-backward (.+ matching only a single character) Message-ID: References: Date: Mon, 10 Oct 2011 23:56:27 -0400 In-Reply-To: (Kenichi Handa's message of "Tue, 11 Oct 2011 11:03:26 +0900") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.90 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 9681 Cc: 9681@debbugs.gnu.org, stepnem@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) >> It's not the ideal behavior, admittedly. It's even more obvious in >> `looking-back'. But fixing it would require the implementation of >> a backward regexp matcher. > FYI, in Mule (the version before integrating into Emacs), we > implemented such a feature by doing these: I actually think it would be nice to have such a thing, but I also think it'd be more important to have a non-backtracking regexp matcher. > multilingual feature. And actually, that feature had been > used very rarely. Indeed, it's not often needed, but those few cases can be significant. Stefan From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 16 12:49:51 2012 Received: (at submit) by debbugs.gnu.org; 16 Mar 2012 16:49:51 +0000 Received: from localhost ([127.0.0.1]:53676 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1S8aLf-0005sY-4f for submit@debbugs.gnu.org; Fri, 16 Mar 2012 12:49:51 -0400 Received: from eggs.gnu.org ([208.118.235.92]:53084) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1S8Zti-0005EN-O1 for submit@debbugs.gnu.org; Fri, 16 Mar 2012 12:20:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S8ZQO-0000eF-3z for submit@debbugs.gnu.org; Fri, 16 Mar 2012 11:50:44 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:47375) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S8ZQN-0000e8-Ml for submit@debbugs.gnu.org; Fri, 16 Mar 2012 11:50:39 -0400 Received: from eggs.gnu.org ([208.118.235.92]:50644) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S8ZQH-0008Gh-J5 for bug-gnu-emacs@gnu.org; Fri, 16 Mar 2012 11:50:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S8ZPr-0000b4-Ib for bug-gnu-emacs@gnu.org; Fri, 16 Mar 2012 11:50:33 -0400 Received: from mail-yx0-f169.google.com ([209.85.213.169]:62325) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S8ZPr-0000ZP-Bu for bug-gnu-emacs@gnu.org; Fri, 16 Mar 2012 11:50:07 -0400 Received: by yenm8 with SMTP id m8so5119137yen.0 for ; Fri, 16 Mar 2012 08:50:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:from:date:x-google-sender-auth:message-id :subject:to:content-type; bh=Lm0UpwSb021vULNXlf1+oZ9SLtDuAEIaHKIpVQUJgA8=; b=w06y61RJ9z1GwTjEVLvYzXkpvljVpQNJJ3WC+mihLWoiGXdDOd1XxuhTis+uCKSyb/ ePnv1hZnt0vpKhU6kNp0mlAtzhMEudf+lo+y3nxHmRU+SX0oLFUas53N26mckrJADHNl GHfM/MZlvWz5MHWlufzDCuL6lezvbXW5xrGM8DNfqVRtRjiEBfNp1CJfK+1F8t7eMwop lS/SM+oEb4JKrY+5pFPv080oJTr3NPSz61tXbx/X5YWF1JTuNfWvUBQ4DUnQhx0p8v33 z8T8l+tjuNJqv2fc0Si1820MAeGrHWVz8G3hMRWsxLCdBndVtIvW9qf8g6mgl15PHgCy 82KA== Received: by 10.182.41.6 with SMTP id b6mr3810206obl.10.1331912998187; Fri, 16 Mar 2012 08:49:58 -0700 (PDT) MIME-Version: 1.0 Received: by 10.182.171.97 with HTTP; Fri, 16 Mar 2012 08:49:37 -0700 (PDT) From: Jack Duthen Date: Fri, 16 Mar 2012 16:49:37 +0100 X-Google-Sender-Auth: GFq6eNTA054om_0svXYR6DWrbqk Message-ID: Subject: Re: bug#9681: Broken behaviour of re-search-backward (.+ matching only a single character) To: bug-gnu-emacs@gnu.org Content-Type: text/plain; charset=ISO-8859-1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 208.118.235.17 X-Spam-Score: -6.1 (------) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Fri, 16 Mar 2012 12:49:38 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.1 (------) 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( From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 16 13:48:23 2012 Received: (at control) by debbugs.gnu.org; 16 Mar 2012 17:48:23 +0000 Received: from localhost ([127.0.0.1]:53713 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1S8bGJ-0007Gi-D2 for submit@debbugs.gnu.org; Fri, 16 Mar 2012 13:48:23 -0400 Received: from fencepost.gnu.org ([208.118.235.10]:47403) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1S8bG8-0007GO-8B for control@debbugs.gnu.org; Fri, 16 Mar 2012 13:48:22 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1S8amq-0002tZ-84 for control@debbugs.gnu.org; Fri, 16 Mar 2012 13:17:56 -0400 Date: Fri, 16 Mar 2012 13:17:56 -0400 Message-Id: Subject: control message for bug 11025 To: X-Mailer: mail (GNU Mailutils 2.1) From: Glenn Morris X-Spam-Score: -6.9 (------) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) forcemerge 9681 11025 From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 28 21:18:42 2016 Received: (at control) by debbugs.gnu.org; 29 Oct 2016 01:18:42 +0000 Received: from localhost ([127.0.0.1]:34363 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c0IIE-0005cQ-H3 for submit@debbugs.gnu.org; Fri, 28 Oct 2016 21:18:42 -0400 Received: from mail-it0-f54.google.com ([209.85.214.54]:38727) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c0IID-0005cB-NF for control@debbugs.gnu.org; Fri, 28 Oct 2016 21:18:42 -0400 Received: by mail-it0-f54.google.com with SMTP id q124so7548647itd.1 for ; Fri, 28 Oct 2016 18:18:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=kINRb5hUqdiVE1lGU+PIDif5fQAx8LuN6Mbks1Y0I7M=; b=pifGr6Y6CErn+vdDLJtLQH4Rsw5S1FNsPii1bMLnY9OK4w0beyCAsIp9xgFZpnpq+t zuH9b7V9R+A+C+NAkKNeqG6ACHMTNOtiB1c+P3Ak+q3uAEclc7TY5A9E5tJJZq77Zp5r BPp2jtJKFJvfofrmXolGV4emj/Zr5Q9KAPh9lr3+QXyUWWKVtkfmqJeRuKqjGha1HyW4 EFj7oYwDU3GV6rGYESe/xLqTdDLoXtKE3XOCGG6EL1XXZduVnvz1pncafDQLKObrGb/v DVsgOG3HpEvN2m6sZioWL9JsaEJ+L+eV5zzNMynXcAt2Ia/EZLblh4CzpAmhyEhuVCJO 8Rcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=kINRb5hUqdiVE1lGU+PIDif5fQAx8LuN6Mbks1Y0I7M=; b=iVZDlvJJL+tdnFNbE6Im7bHtlon2HjwqQ825BtcDrq3y+dOckjDF5ff6SI5zAAfmg/ MR8YRyE0ABlP8Z+hdRoU+a/R401uq86F1yNO/SkUGiXsqH0EKJ5l8UWdXYb/Md5O483+ mFr/cIz2ZmSCUkIaM2vBoeChET4HnacGFAeVZNbnQgbfhzxoJq1DgDPBHOSCLSnD5CBm Gf5vs7L2U0Ws5HGEkRgE9+3MaCNSYnJdpODZUWXXCAd9LsXkrra7SVIhYdoYlM5LmM+m N1wq6uhHtG3x4cnaLALLzajSRB3KyTlaUxSKmPln1AGDCCIPCMgs0Q8CG4r4Mxka6C0R rjZw== X-Gm-Message-State: ABUngvfwEHAgZFCTIOh3zwdBt0ehB1jLwVJzg/ytNo8m3iJuoGE0iKv8z5PXRAJvP4db8w== X-Received: by 10.36.14.75 with SMTP id 72mr1010087ite.87.1477703915871; Fri, 28 Oct 2016 18:18:35 -0700 (PDT) Received: from zony ([45.2.7.130]) by smtp.googlemail.com with ESMTPSA id k81sm4562286iod.20.2016.10.28.18.18.35 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Oct 2016 18:18:35 -0700 (PDT) From: npostavs@users.sourceforge.net To: control@debbugs.gnu.org Subject: Re: bug#24801: 25.1; Reverse regexp search highlighting References: <4efa49bf-c223-4148-a291-12a722db033c@default> <8737jispf7.fsf@users.sourceforge.net> <5537d36d-a365-4a3f-97a3-78c32e86e7ea@default> <87zilqr8d1.fsf@users.sourceforge.net> <152b38c0-5aff-4c96-b976-8df0cbb3199a@default> Date: Fri, 28 Oct 2016 21:19:16 -0400 In-Reply-To: <152b38c0-5aff-4c96-b976-8df0cbb3199a@default> (Drew Adams's message of "Wed, 26 Oct 2016 18:51:53 -0700 (PDT)") Message-ID: <87twbwq7e3.fsf@users.sourceforge.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) # Emacs behaving as documented, therefore notabug tags 24801 notabug forcemerge 9681 24801 close 24801 quit Drew Adams writes: >> Isn't it? The match of aa.* "whose beginning is as close as >> possible" when point is at the of a line of a's, is "aa". So it seems >> expected that searching backwards would match pairs of a's. > > You are right. > >> Can you describe exactly how the behaviour is different in Emacs 22? > > I was mistaken. The same search hits are found in 22 (and before) > as now. Somehow I thought I was seeing something different when > I tried 22 and 20 earlier today. > >> Actually, this report looks similar to 9681, although I see no >> claims there that it worked in version 22. > > Yes, this is the same. I will close this bug. > > Funny that I never noticed this before. I guess that in practice > it doesn't bite that often. It is multiple matches in the same > line that makes this really stand out as weird behavior. From unknown Wed Jun 18 23:04:14 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 26 Nov 2016 12:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator