GNU Info

Info Node: (elisp)Finding Overlays

(elisp)Finding Overlays


Prev: Managing Overlays Up: Overlays
Enter node , (file) or (file)node

Searching for Overlays
----------------------

 - Function: overlays-at pos
     This function returns a list of all the overlays that cover the
     character at position POS in the current buffer.  The list 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.  "Overlap" means that at least one
     character is contained within the overlay and also contained
     within the specified region; however, empty overlays are included
     in the result if they are located at BEG, or strictly between BEG
     and END.

 - Function: next-overlay-change pos
     This function returns the buffer position of the next beginning or
     end of an overlay, after POS.

 - Function: previous-overlay-change pos
     This function returns the buffer position of the previous
     beginning or end of an overlay, before POS.

   Here's an easy way to use `next-overlay-change' to search for the
next character which gets a non-`nil' `happy' property from either its
overlays or its text properties (Note: Property Search):

     (defun find-overlay-prop (prop)
       (save-excursion
         (while (and (not (eobp))
                     (not (get-char-property (point) 'happy)))
           (goto-char (min (next-overlay-change (point))
                           (next-single-property-change (point) 'happy))))
         (point)))


automatically generated by info2www version 1.2.2.9