From: Lars Ingebrigtsen Date: Sat, 29 Jan 2022 15:39:48 +0000 (+0100) Subject: Clarify Fmatch_data doc string X-Git-Tag: emacs-29.0.90~2666 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7608b77d9ee54e26ac61abb5132ac8c3c13f906a;p=emacs.git Clarify Fmatch_data doc string * src/search.c (Fmatch_data): Note quirk about non-matching optional groups in the doc string (bug#29343). --- diff --git a/src/search.c b/src/search.c index a1adfa2d8ce..80541921de1 100644 --- a/src/search.c +++ b/src/search.c @@ -2827,6 +2827,14 @@ All the elements are markers or nil (nil if the Nth pair didn't match) if the last match was on a buffer; integers or nil if a string was matched. Use `set-match-data' to reinstate the data in this list. +Note that non-matching optional groups at the end of the regexp are +elided instead of being represented with two `nil's each. For instance: + + (progn + (string-match "^\\(a\\)?\\(b\\)\\(c\\)?$" "b") + (match-data)) + => (0 1 nil nil 0 1) + If INTEGERS (the optional first argument) is non-nil, always use integers (rather than markers) to represent buffer positions. In this case, and if the last match was in a buffer, the buffer will get