Function: embark-define-overlay-target

embark-define-overlay-target is a macro defined in embark.el.

Signature

(embark-define-overlay-target NAME PROP &optional PRED TYPE TARGET)

Documentation

Define a target finder for NAME that targets overlays with property PROP.

The function defined is named embark-target-NAME-at-point and it returns Embark targets based on the overlays around point. An overlay provides a target if its property named PROP is non-nil.

If the optional PRED argument is given, it should be an expression and it further restricts the targets to only those overlays for which PRED evaluates to non-nil.

The target finder returns target type NAME or optional symbol TYPE if given.

The target finder returns the substring of the buffer covered by the overlay as the target string or the result of evaluating the optional TARGET expression if given.

PRED and TARGET are expressions (not functions) and when evaluated the symbols %o and %p are bound to the overlay and the overlay's property respectively.

Source Code

;; Defined in ~/.emacs.d/elpa/embark-20260610.302/embark.el
(defmacro embark-define-overlay-target (name prop &optional pred type target)
  "Define a target finder for NAME that targets overlays with property PROP.
The function defined is named embark-target-NAME-at-point and it
returns Embark targets based on the overlays around point.  An
overlay provides a target if its property named PROP is non-nil.

If the optional PRED argument is given, it should be an
expression and it further restricts the targets to only those
overlays for which PRED evaluates to non-nil.

The target finder returns target type NAME or optional symbol
TYPE if given.

The target finder returns the substring of the buffer covered by
the overlay as the target string or the result of evaluating the
optional TARGET expression if given.

PRED and TARGET are expressions (not functions) and when evaluated the
symbols `%o' and `%p' are bound to the overlay and the overlay's
property respectively."
  `(defun ,(intern (format "embark-target-%s-at-point" name)) ()
     ,(format "Target %s at point." name)
     (when-let* ((%o (seq-find
                      (lambda (%o)
                        (when-let* ((%p (overlay-get %o ',prop)))
                          (ignore %p)
                          ,(or pred t)))
                      (overlays-in (max (point-min) (1- (point)))
                                   (min (point-max) (1+ (point))))))
                 (%p (overlay-get %o ',prop)))
       (ignore %p)
       (cons ',(or type name)
             (cons ,(or target `(buffer-substring-no-properties
                                 (overlay-start %o) (overlay-end %o)))
                   (cons (overlay-start %o) (overlay-end %o)))))))