summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/text-property-search.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2021-05-11 14:30:00 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2021-05-11 14:30:00 +0200
commit6d225d82c8b472ff23525e9047d8a2dc8c363a43 (patch)
treeb824111714a5ed42b24c2755616ce160892e399a /lisp/emacs-lisp/text-property-search.el
parent6d24a8e626f1c7553c90b579c399aeae8c82dd8c (diff)
downloademacs-6d225d82c8b472ff23525e9047d8a2dc8c363a43.tar.gz
`text-property-search-forward' doc string improvement
* lisp/emacs-lisp/text-property-search.el (text-property-search-forward): Correct and clarify the doc string (bug#48317).
Diffstat (limited to 'lisp/emacs-lisp/text-property-search.el')
-rw-r--r--lisp/emacs-lisp/text-property-search.el35
1 files changed, 22 insertions, 13 deletions
diff --git a/lisp/emacs-lisp/text-property-search.el b/lisp/emacs-lisp/text-property-search.el
index 69943a83f1c..49e196d3bfc 100644
--- a/lisp/emacs-lisp/text-property-search.el
+++ b/lisp/emacs-lisp/text-property-search.el
@@ -32,27 +32,36 @@
(defun text-property-search-forward (property &optional value predicate
not-current)
"Search for the next region of text whose PROPERTY matches VALUE.
-
-If not found, return nil and don't move point.
-If found, move point to the start of the region and return a
-`prop-match' object describing the match. To access the details
-of the match, use `prop-match-beginning' and `prop-match-end' for
-the buffer positions that limit the region, and
-`prop-match-value' for the value of PROPERTY in the region.
-
PREDICATE is used to decide whether a value of PROPERTY should be
considered as matching VALUE.
-If PREDICATE is t, that means a value must `equal' VALUE to be
-considered a match.
-If PREDICATE is nil, a value will match if it is non-nil and
-is NOT `equal' to VALUE.
+
If PREDICATE is a function, it will be called with two arguments:
VALUE and the value of PROPERTY. The function should return
non-nil if these two values are to be considered a match.
+Two special values of PREDICATE can also be used:
+If PREDICATE is t, that means a value must `equal' VALUE to be
+considered a match.
+If PREDICATE is nil, a value will match if is not `equal' to
+VALUE. Furthermore, the match region is ended if the value
+changes. For instance, this means that if you loop with
+
+ (while (text-property-search-forward 'face)
+ ...)
+
+you will get all distinct regions with different `face' values in
+the buffer.
+
If NOT-CURRENT is non-nil, the function will search for the first
region that doesn't include point and has a value of PROPERTY
-that matches VALUE."
+that matches VALUE.
+
+If no matches can be found, return nil and don't move point.
+If found, move point to the start of the region and return a
+`prop-match' object describing the match. To access the details
+of the match, use `prop-match-beginning' and `prop-match-end' for
+the buffer positions that limit the region, and
+`prop-match-value' for the value of PROPERTY in the region."
(interactive
(list
(let ((string (completing-read "Search for property: " obarray)))