Function: embark-define-regexp-target
embark-define-regexp-target is a macro defined in embark.el.
Signature
(embark-define-regexp-target NAME REGEXP &optional TYPE TARGET BOUNDS LIMIT)
Documentation
Define a target finder for matches of REGEXP around point.
The function defined is named embark-target-NAME-at-point and it uses (thing-at-point-looking-at REGEXP) to find its targets.
The target finder returns target type NAME or optional symbol TYPE if given.
The target finder returns the substring of the buffer matched by
REGEXP as the target string or the result of evaluating the
optional TARGET expression if given. In the expression TARGET
you can use match-string to recover the match of the REGEXP or
of any sub-expressions it has.
BOUNDS is an optional expression to compute the bounds of the target and defaults to (cons (match-beginning 0) (match-end 0)).
The optional LIMIT is the number of characters before and after point to limit the search to. If LIMIT is nil, search a little more than the current line (more precisely, the smallest interval centered at point that includes the current line).
Source Code
;; Defined in ~/.emacs.d/elpa/embark-20260610.302/embark.el
(defmacro embark-define-regexp-target
(name regexp &optional type target bounds limit)
"Define a target finder for matches of REGEXP around point.
The function defined is named embark-target-NAME-at-point and it
uses (thing-at-point-looking-at REGEXP) to find its targets.
The target finder returns target type NAME or optional symbol
TYPE if given.
The target finder returns the substring of the buffer matched by
REGEXP as the target string or the result of evaluating the
optional TARGET expression if given. In the expression TARGET
you can use `match-string' to recover the match of the REGEXP or
of any sub-expressions it has.
BOUNDS is an optional expression to compute the bounds of the
target and defaults to (cons (match-beginning 0) (match-end 0)).
The optional LIMIT is the number of characters before and after
point to limit the search to. If LIMIT is nil, search a little
more than the current line (more precisely, the smallest interval
centered at point that includes the current line)."
`(defun ,(intern (format "embark-target-%s-at-point" name)) ()
,(format "Target %s at point." name)
(save-match-data
(when (thing-at-point-looking-at
,regexp
,(or limit '(max (- (pos-eol) (point)) (- (point) (pos-bol)))))
(cons ',(or type name)
(cons ,(or target '(match-string 0))
,(or bounds
'(cons (match-beginning 0) (match-end 0)))))))))