From: Noam Postavsky <npostavs@gmail.com>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: Eric Abrahamsen <eric@ericabrahamsen.net>, 31584@debbugs.gnu.org
Subject: bug#31584: 27.0.50; Document again what match re-search-backward finds
Date: Thu, 24 May 2018 19:55:18 -0400 [thread overview]
Message-ID: <87o9h4fw2h.fsf@gmail.com> (raw)
In-Reply-To: <87po1kekmi.fsf@web.de> (Michael Heerdegen's message of "Fri, 25 May 2018 00:47:49 +0200")
[-- Attachment #1: Type: text/plain, Size: 471 bytes --]
Michael Heerdegen <michael_heerdegen@web.de> 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:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 1984 bytes --]
From 8caeb0df40fc1cc34cd165d68238216198e01169 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
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
next prev parent reply other threads:[~2018-05-24 23:55 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-24 21:31 bug#31584: 27.0.50; Document again what match re-search-backward finds Michael Heerdegen
2018-05-24 21:42 ` Eric Abrahamsen
2018-05-24 21:59 ` Michael Heerdegen
2018-05-24 22:10 ` Eric Abrahamsen
2018-05-24 22:14 ` Noam Postavsky
2018-05-24 22:47 ` Eric Abrahamsen
2018-05-24 22:47 ` Michael Heerdegen
2018-05-24 23:55 ` Noam Postavsky [this message]
2018-05-25 0:22 ` Michael Heerdegen
2018-05-25 0:31 ` Noam Postavsky
2018-05-25 0:36 ` Eric Abrahamsen
2018-05-25 1:10 ` Michael Heerdegen
2018-05-25 1:27 ` Noam Postavsky
2018-05-25 1:48 ` Michael Heerdegen
2018-05-25 6:23 ` Eli Zaretskii
2018-05-25 11:59 ` Noam Postavsky
2018-05-25 0:28 ` Drew Adams
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87o9h4fw2h.fsf@gmail.com \
--to=npostavs@gmail.com \
--cc=31584@debbugs.gnu.org \
--cc=eric@ericabrahamsen.net \
--cc=michael_heerdegen@web.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.