emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 866c1f5: Expand the `match-string' doc string


From: Lars Ingebrigtsen
Subject: master 866c1f5: Expand the `match-string' doc string
Date: Wed, 22 Sep 2021 18:10:23 -0400 (EDT)

branch: master
commit 866c1f56a3d7ecb02d58aa8ee2979cff0b1f044f
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Expand the `match-string' doc string
    
    * lisp/subr.el (match-string): Mention some caveats (bug#34214).
---
 lisp/subr.el | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/lisp/subr.el b/lisp/subr.el
index a6434bf..029302a 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -4667,13 +4667,23 @@ rather than your caller's match data."
              '(set-match-data save-match-data-internal 'evaporate))))
 
 (defun match-string (num &optional string)
-  "Return string of text matched by last search.
+  "Return the string of text matched by the previous search or regexp 
operation.
 NUM specifies which parenthesized expression in the last regexp.
- Value is nil if NUMth pair didn't match, or there were less than NUM pairs.
 Zero means the entire text matched by the whole regexp or whole string.
-STRING should be given if the last search was by `string-match' on STRING.
-If STRING is nil, the current buffer should be the same buffer
-the search/match was performed in."
+
+The return value is nil if NUMth pair didn't match, or there were
+less than NUM pairs.
+
+STRING should be given if the last search was by `string-match'
+on STRING.  If STRING is nil, the current buffer should be the
+same buffer the search/match was performed in.
+
+Note that many functions in Emacs modify the match data, so this
+function should be called \"close\" to the function that did the
+match.  In particular, saying (for instance)
+`M-: (looking-at \"[0-9]\") RET' followed by `M-: (match-string 0) RET'
+interactively is seldom meaningful, since the Emacs command loop
+may modify the match data."
   (declare (side-effect-free t))
   (if (match-beginning num)
       (if string



reply via email to

[Prev in Thread] Current Thread [Next in Thread]