From 7608b77d9ee54e26ac61abb5132ac8c3c13f906a Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sat, 29 Jan 2022 16:39:48 +0100 Subject: [PATCH] Clarify Fmatch_data doc string * src/search.c (Fmatch_data): Note quirk about non-matching optional groups in the doc string (bug#29343). --- src/search.c | 8 ++++++++ 1 file changed, 8 insertions(+) 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 -- 2.39.5