Commit 3de3e773 authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(Finding Overlays): Write better example.

parent 0c47ccd4
......@@ -1527,26 +1527,25 @@ end of an overlay, before @var{pos}. If there is none, it returns
@end defun
Here's a function which uses @code{next-overlay-change} to search
for the next character which gets a given property @code{prop} from
either its overlays or its text properties (@pxref{Property Search}):
As an example, here's a simplified (and inefficient) version of the
primitive function @code{next-single-char-property-change}
(@pxref{Property Search}). It searches forward from position
@var{pos} for the next position where the value of a given property
@code{prop}, as obtained from either overlays or text properties,
(defun find-overlay-prop (prop)
(defun next-single-char-property-change (position prop)
(while (and (not (eobp))
(not (get-char-property (point) prop)))
(goto-char (min (next-overlay-change (point))
(next-single-property-change (point) prop))))
(goto-char position)
(let ((propval (get-char-property (point) prop)))
(while (and (not (eobp))
(eq (get-char-property (point) prop) propval))
(goto-char (min (next-overlay-change (point))
(next-single-property-change (point) prop)))))
@end smallexample
Now you can search for a @code{happy} property like this:
(find-overlay-prop 'happy)
@end smallexample
@node Width
@section Width
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment