From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/elisp/finding-overlays.html | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 devdocs/elisp/finding-overlays.html (limited to 'devdocs/elisp/finding-overlays.html') diff --git a/devdocs/elisp/finding-overlays.html b/devdocs/elisp/finding-overlays.html new file mode 100644 index 00000000..0fb6175f --- /dev/null +++ b/devdocs/elisp/finding-overlays.html @@ -0,0 +1,35 @@ +

Searching for Overlays

Function: overlays-at pos &optional sorted +
+

This function returns a list of all the overlays that cover the character at position pos in the current buffer. If sorted is non-nil, the list is in decreasing order of priority, otherwise it is in no particular order. An overlay contains position pos if it begins at or before pos, and ends after pos.

To illustrate usage, here is a Lisp function that returns a list of the overlays that specify property prop for the character at point:

(defun find-overlays-specifying (prop)
+  (let ((overlays (overlays-at (point)))
+        found)
+    (while overlays
+      (let ((overlay (car overlays)))
+        (if (overlay-get overlay prop)
+            (setq found (cons overlay found))))
+      (setq overlays (cdr overlays)))
+    found))
+
+
+
Function: overlays-in beg end +

This function returns a list of the overlays that overlap the region beg through end. An overlay overlaps with a region if it contains one or more characters in the region; empty overlays (see empty overlay) overlap if they are at beg, strictly between beg and end, or at end when end denotes the position at the end of the accessible part of the buffer.

+
Function: next-overlay-change pos +

This function returns the buffer position of the next beginning or end of an overlay, after pos. If there is none, it returns (point-max).

+
Function: previous-overlay-change pos +

This function returns the buffer position of the previous beginning or end of an overlay, before pos. If there is none, it returns (point-min).

+

As an example, here’s a simplified (and inefficient) version of the primitive function next-single-char-property-change (see Property Search). It searches forward from position pos for the next position where the value of a given property prop, as obtained from either overlays or text properties, changes.

(defun next-single-char-property-change (position prop)
+  (save-excursion
+    (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)))))
+    (point)))
+
+
+

+ Copyright © 1990-1996, 1998-2022 Free Software Foundation, Inc.
Licensed under the GNU GPL license.
+ https://www.gnu.org/software/emacs/manual/html_node/elisp/Finding-Overlays.html +

+
-- cgit v1.2.3