aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2007-03-04 18:00:37 +0000
committerRichard M. Stallman2007-03-04 18:00:37 +0000
commit3de3e773a656100b1810eaf5a1b4f9d63f1469e9 (patch)
tree66e240fc76ede7dbe05f2f86b2e530ca8d1b0416
parent0c47ccd44ef2de6c7df6241b46bb99977251427b (diff)
downloademacs-3de3e773a656100b1810eaf5a1b4f9d63f1469e9.tar.gz
emacs-3de3e773a656100b1810eaf5a1b4f9d63f1469e9.zip
(Finding Overlays): Write better example.
-rw-r--r--lispref/display.texi27
1 files changed, 13 insertions, 14 deletions
diff --git a/lispref/display.texi b/lispref/display.texi
index 02491c422d9..f485829725a 100644
--- a/lispref/display.texi
+++ b/lispref/display.texi
@@ -1527,26 +1527,25 @@ end of an overlay, before @var{pos}. If there is none, it returns
1527@code{(point-min)}. 1527@code{(point-min)}.
1528@end defun 1528@end defun
1529 1529
1530 Here's a function which uses @code{next-overlay-change} to search 1530 As an example, here's a simplified (and inefficient) version of the
1531for the next character which gets a given property @code{prop} from 1531primitive function @code{next-single-char-property-change}
1532either its overlays or its text properties (@pxref{Property Search}): 1532(@pxref{Property Search}). It searches forward from position
1533@var{pos} for the next position where the value of a given property
1534@code{prop}, as obtained from either overlays or text properties,
1535changes.
1533 1536
1534@smallexample 1537@smallexample
1535(defun find-overlay-prop (prop) 1538(defun next-single-char-property-change (position prop)
1536 (save-excursion 1539 (save-excursion
1537 (while (and (not (eobp)) 1540 (goto-char position)
1538 (not (get-char-property (point) prop))) 1541 (let ((propval (get-char-property (point) prop)))
1539 (goto-char (min (next-overlay-change (point)) 1542 (while (and (not (eobp))
1540 (next-single-property-change (point) prop)))) 1543 (eq (get-char-property (point) prop) propval))
1544 (goto-char (min (next-overlay-change (point))
1545 (next-single-property-change (point) prop)))))
1541 (point))) 1546 (point)))
1542@end smallexample 1547@end smallexample
1543 1548
1544 Now you can search for a @code{happy} property like this:
1545
1546@smallexample
1547(find-overlay-prop 'happy)
1548@end smallexample
1549
1550@node Width 1549@node Width
1551@section Width 1550@section Width
1552 1551