From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.bugs Subject: bug#31584: 27.0.50; Document again what match re-search-backward finds Date: Thu, 24 May 2018 15:47:22 -0700 Message-ID: <87k1rsfz7p.fsf@ericabrahamsen.net> References: <87in7cg2qw.fsf@web.de> <87wovsg27f.fsf@ericabrahamsen.net> <87wovsg0q3.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1527202145 2739 195.159.176.226 (24 May 2018 22:49:05 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 24 May 2018 22:49:05 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 31584@debbugs.gnu.org To: Noam Postavsky Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri May 25 00:49:01 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fLz2a-0000Ye-R8 for geb-bug-gnu-emacs@m.gmane.org; Fri, 25 May 2018 00:49:01 +0200 Original-Received: from localhost ([::1]:40976 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fLz4h-0000gU-W2 for geb-bug-gnu-emacs@m.gmane.org; Thu, 24 May 2018 18:51:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38111) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fLz4b-0000gN-J0 for bug-gnu-emacs@gnu.org; Thu, 24 May 2018 18:51:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fLz4Y-0002gU-FB for bug-gnu-emacs@gnu.org; Thu, 24 May 2018 18:51:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:39146) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fLz4Y-0002gQ-Ae for bug-gnu-emacs@gnu.org; Thu, 24 May 2018 18:51:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fLz4Y-00086T-4J for bug-gnu-emacs@gnu.org; Thu, 24 May 2018 18:51:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eric Abrahamsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 24 May 2018 22:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31584 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 31584-submit@debbugs.gnu.org id=B31584.152720221731097 (code B ref 31584); Thu, 24 May 2018 22:51:02 +0000 Original-Received: (at 31584) by debbugs.gnu.org; 24 May 2018 22:50:17 +0000 Original-Received: from localhost ([127.0.0.1]:47043 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fLz3p-00085V-Gb for submit@debbugs.gnu.org; Thu, 24 May 2018 18:50:17 -0400 Original-Received: from mail.ericabrahamsen.net ([50.56.99.223]:54433) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fLz3o-00085O-J2 for 31584@debbugs.gnu.org; Thu, 24 May 2018 18:50:17 -0400 Original-Received: from localhost (97-113-251-151.tukw.qwest.net [97.113.251.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: eric@ericabrahamsen.net) by mail.ericabrahamsen.net (Postfix) with ESMTPSA id 8CB1BC293E; Thu, 24 May 2018 22:50:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mail.ericabrahamsen.net; s=mail; t=1527202215; bh=lD49MvZKmZKdB9hlxyeO9X4HJ0Z3dbZHt0wnZJwqVME=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=h2+dV0QDHIsCDXJ09CYryLVO/yrHQ5dhN9yiOnYVTO+Q65wl2JANA65aBYTPK1NTZ Ptn0+4T/gUAeBw+lz+V/b3Y9FZBBpcoC7nqr6/Jp9oUFNZYY47DLbBvSdkKDKhzUr3 6OnezfI+5tjybP2bTJ1kXwLEYc2YmKBrvTHOicwo= In-Reply-To: <87wovsg0q3.fsf@gmail.com> (Noam Postavsky's message of "Thu, 24 May 2018 18:14:44 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.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" Xref: news.gmane.org gmane.emacs.bugs:146509 Archived-At: On 05/24/18 18:14 PM, Noam Postavsky wrote: > The docstring should definitely be clarified, but technically it can > still be answered, if you read very carefully: If reading the documentation takes only a little less effort than reading the code... >> I've been bitten by this before. I'm sure the sentence you cite is, >> correct, but I would suggest something more explicit about backwards >> searches. The most useful thing I could have read when I was wondering >> why this didn't work would be something like: "re-search-backward always >> behaves "non-greedily", i.e., it will find the shortest match before >> point". > > It is greedy: > > (with-temp-buffer > (insert "xxxxyyyy") > (and (re-search-backward "x+y*" nil t) > (match-string 0))) ;=> "xyyyy" > > Non-greedy wouldn't match any "y"s. It's a bit tricky to explain both > correctly and clearly... Yeah, my wording is bad. I think an example might be most clear. Maybe: #+BEGIN_SRC elisp (with-temp-buffer (let ((re "x+y+")) (insert "xxxxyyyy") (goto-char (point-min)) (re-search-forward re nil t) (match-string 0) => "xxxxyyyy" (goto-char (point-max)) (re-search-backward re nil t) (match-string 0))) => "xyyyy" #+END_SRC Or if there's something more concise...