From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#31584: 27.0.50; Document again what match re-search-backward finds Date: Thu, 24 May 2018 19:55:18 -0400 Message-ID: <87o9h4fw2h.fsf@gmail.com> References: <87in7cg2qw.fsf@web.de> <87wovsg27f.fsf@ericabrahamsen.net> <87wovsg0q3.fsf@gmail.com> <87po1kekmi.fsf@web.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1527206045 7235 195.159.176.226 (24 May 2018 23:54:05 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 24 May 2018 23:54:05 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: Eric Abrahamsen , 31584@debbugs.gnu.org To: Michael Heerdegen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri May 25 01:54: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 1fM03U-0001nR-Nq for geb-bug-gnu-emacs@m.gmane.org; Fri, 25 May 2018 01:54:00 +0200 Original-Received: from localhost ([::1]:41138 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fM05b-0004lE-Hu for geb-bug-gnu-emacs@m.gmane.org; Thu, 24 May 2018 19:56:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48545) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fM05V-0004kj-P9 for bug-gnu-emacs@gnu.org; Thu, 24 May 2018 19:56:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fM05S-0005EC-P4 for bug-gnu-emacs@gnu.org; Thu, 24 May 2018 19:56:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:39159) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fM05S-0005Di-II for bug-gnu-emacs@gnu.org; Thu, 24 May 2018 19:56:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fM05R-00014D-LL for bug-gnu-emacs@gnu.org; Thu, 24 May 2018 19:56:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 24 May 2018 23:56:01 +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.15272061284062 (code B ref 31584); Thu, 24 May 2018 23:56:01 +0000 Original-Received: (at 31584) by debbugs.gnu.org; 24 May 2018 23:55:28 +0000 Original-Received: from localhost ([127.0.0.1]:47056 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fM04t-00013S-OO for submit@debbugs.gnu.org; Thu, 24 May 2018 19:55:27 -0400 Original-Received: from mail-io0-f169.google.com ([209.85.223.169]:34794) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fM04s-00013G-HW for 31584@debbugs.gnu.org; Thu, 24 May 2018 19:55:26 -0400 Original-Received: by mail-io0-f169.google.com with SMTP id p124-v6so4429130iod.1 for <31584@debbugs.gnu.org>; Thu, 24 May 2018 16:55:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=M1ptF38p1zGGODAtBS+2vPBCjtmolSCNdejE2JvmokM=; b=Q2TqmviujffATtbMfE/X6LUCxQF/kOMImK1dZoWXsEoVS5uwvu+Q2c7Jm7YC1eA5h+ urdEuhD8BAt5JBp5IjxvcYg8oTEU5/I5UiuHx1fTGe7Tf0pjLb+Rivi5Xpg8rorXithL ooJn0U9C41qdFpjVzJUpYUIaIBQFUo/3nzkHo0xcQrHn2B/H0VLV0bYIQ87hc0WQszVd HQpM3sU1sUZLPNhgv5rUn1/MMh5Fr5VboGR8bDfR8W48Z11K4v2ZT/R9y0qxeUaF3VTc fUaMLVh7fo+CaZxP08tpAoD0C9i0RKjNF/czPiWJJ0IsY+D4MprITokNRO4Ra5nQ0U/r 5cNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=M1ptF38p1zGGODAtBS+2vPBCjtmolSCNdejE2JvmokM=; b=V2D4L1Si/91AquwkXdKJe7dxqrelQc5aw/zyPCqvThh+0oobhoXnKC1MNZMaS8jgAl ifVCke0p4IDNXfkW+s66N+49Wfeu4M1saFFriyMJzu/XtjHQkQQpXioNVHEl55+CW8AB ttU41rp3gvCQ+WXZj8pD4Fa8loKbq/M2+hGcUvxF6sYIq20LaA4YJfZRyZNT6s8gEnCG RrRH9ixy4qdPoFuEhpfBttMVicy5fNN1h91DGPdTe177Jn9TK3z+Ue+cCZnCjl9kaMTq 4K5D6TgwN3I+2nvo07aKt4alpkxX29yFD/83EQ4OrvZppS9zTODohPXHsic/fv+tq5hA 3cUw== X-Gm-Message-State: ALKqPwea0CulpLkxMPonJzFr8o2zs+XeAowhNKN5c1bLT4JHoBkZxRVB okaGhySNo1/qeFrLaN6AvrrXYA== X-Google-Smtp-Source: ADUXVKLwydAGbKePwVPPftE0GOElSZiPhBNFVNF2TaKBKBev8hXUW8NR/6nfGWXpmMn1b49Kd8kg4Q== X-Received: by 2002:a6b:db15:: with SMTP id t21-v6mr90287ioc.224.1527206120601; Thu, 24 May 2018 16:55:20 -0700 (PDT) Original-Received: from zebian (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.googlemail.com with ESMTPSA id w73-v6sm3185693itb.19.2018.05.24.16.55.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 May 2018 16:55:19 -0700 (PDT) In-Reply-To: <87po1kekmi.fsf@web.de> (Michael Heerdegen's message of "Fri, 25 May 2018 00:47:49 +0200") 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:146511 Archived-At: --=-=-= Content-Type: text/plain Michael Heerdegen writes: >> (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... > > Ok, good example. You convinced me that the sentence we once had was > actually quite good. Actually, the manual has a pretty good explanation, maybe we can just link to it: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v1-0001-Note-caveat-for-backward-regexp-searching-in-docs.patch Content-Description: patch >From 8caeb0df40fc1cc34cd165d68238216198e01169 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Thu, 24 May 2018 19:49:11 -0400 Subject: [PATCH v1] Note caveat for backward regexp searching in docstring (Bug#31584) * src/search.c (Fre_search_backward): Emphasize that backwards searches may give shorter than expected matches. * doc/lispref/searching.texi (Regexp Search): Add an anchor for re-search-backward to reference. --- doc/lispref/searching.texi | 2 ++ src/search.c | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/lispref/searching.texi b/doc/lispref/searching.texi index fca877117d..6c1ebb22b5 100644 --- a/doc/lispref/searching.texi +++ b/doc/lispref/searching.texi @@ -1102,6 +1102,8 @@ Regexp Search @end example @end deffn +@c This anchor is referenced by re-search-backward's docstring. +@anchor{re-search-backward} @deffn Command re-search-backward regexp &optional limit noerror count This function searches backward in the current buffer for a string of text that is matched by the regular expression @var{regexp}, leaving diff --git a/src/search.c b/src/search.c index 842e9309a2..0600e1a4e3 100644 --- a/src/search.c +++ b/src/search.c @@ -2233,8 +2233,11 @@ DEFUN ("re-search-backward", Fre_search_backward, Sre_search_backward, 1, 4, This function is almost identical to `re-search-forward', except that by default it searches backward instead of forward, and the sign of COUNT also indicates exactly the opposite searching direction. +See `re-search-forward' for details. -See `re-search-forward' for details. */) +Note that searching backwards may give a shorter match than expected, +because the matching still happens in the forward direction. See Info +anchor `(elisp) re-search-backward' for details. */) (Lisp_Object regexp, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) { return search_command (regexp, bound, noerror, count, -1, 1, 0); -- 2.11.0 --=-=-=--