From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Greg Hill Newsgroups: gmane.emacs.help Subject: Re: Problem with re-search-backward and "\\=" Date: Tue, 16 Sep 2003 11:57:03 -0700 Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-Trace: sea.gmane.org 1063738769 23446 80.91.224.253 (16 Sep 2003 18:59:29 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 16 Sep 2003 18:59:29 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Sep 16 20:59:23 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19zL2p-0005aA-01 for ; Tue, 16 Sep 2003 20:59:23 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.22) id 19zL2X-0007Ay-Gz for geh-help-gnu-emacs@m.gmane.org; Tue, 16 Sep 2003 14:59:05 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.22) id 19zL2I-0007Ag-Ql for help-gnu-emacs@gnu.org; Tue, 16 Sep 2003 14:58:50 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.22) id 19zL2H-0007AV-3r for help-gnu-emacs@gnu.org; Tue, 16 Sep 2003 14:58:49 -0400 Original-Received: from [153.105.4.30] (helo=synergymicro.com) by monty-python.gnu.org with esmtp (Exim 4.22) id 19zL2G-00076Z-Ks for help-gnu-emacs@gnu.org; Tue, 16 Sep 2003 14:58:48 -0400 Original-Received: from synergy.synergy.encinitas.ca.us ([153.105.4.29]) by synergymicro.com (8.9.3/8.9.3) with ESMTP id MAA25483 for ; Tue, 16 Sep 2003 12:00:08 -0700 Original-Received: from [198.17.100.22] (G_Hill_Mac [198.17.100.22]) by synergy.synergy.encinitas.ca.us (8.12.8/8.12.8) with ESMTP id h8GIwgn4022262 for ; Tue, 16 Sep 2003 11:58:42 -0700 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:12554 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:12554 >GNU Emacs 21.1 > >Suppose I have this in a buffer: > >foo bar > >If point is immediately after foo, then (re-search-forward "\\= *") >leaves point immediately before bar, as one would expect. > >However, with point immediately before bar (re-search-backward " *\\=") >fails. I would have expected this search to have succeeded, leaving >point just after foo. > >The definition of `\=' in the elisp info page "Regexp Backslash" is: > >> matches the empty string, but only at point. (This construct is not >> defined when matching against a string.) > >Is this a bug, or have I misunderstood something? Alan, You have misunderstood the nature of the "greediness" of the '*' -- and probably also the '+' -- postfix operator when applied to backward searches. It is not "symmetrical" with its effect on forward searches. I suggest you do some experimentation with these operators, never minding the "\\=" for the moment, to better understand the way these postfix operators work. I may not have this completely right, but this is the way I conceptualize it. When searching forward, the match-beginning advances forward from point until the first possible match is found; then match-beginning is fixed and match-end advances until going any farther would break the rule or exceed the specified limit. In searching backward, the match-beginning moves backward until the first possible match is found; then match-beninning is fixed and the match-end advances forward until going any farther would break the rule, using the initial value of point as the limit to how far the match-end is allowed to advance. I have never experimented with the "non-greedy" postfix operators '*?' '+?' and '??', so I can't tell you how using them effects the conceptualization described above. I hope this helps. --Greg