www.delorie.com/gnu/docs/elisp-manual-21/elisp_629.html   search  
 
Buy the book!


GNU Emacs Lisp Reference Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

38.9.3 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 (see section 32.19.3 Text Property Search Functions):

 
(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)))


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003