Function: thing-at-point-looking-at
thing-at-point-looking-at is a byte-compiled function defined in
thingatpt.el.gz.
Signature
(thing-at-point-looking-at REGEXP &optional DISTANCE)
Documentation
Return non-nil if point is in or just after a match for REGEXP.
Set the match data from the earliest such match ending at or after point.
Optional argument DISTANCE limits search for REGEXP forward and back from point.
Source Code
;; Defined in /usr/src/emacs/lisp/thingatpt.el.gz
;; The normal thingatpt mechanism doesn't work for complex regexps.
;; This should work for almost any regexp wherever we are in the
;; match. To do a perfect job for any arbitrary regexp would mean
;; testing every position before point. Regexp searches won't find
;; matches that straddle the start position so we search forwards once
;; and then back repeatedly and then back up a char at a time.
(defun thing-at-point-looking-at (regexp &optional distance)
"Return non-nil if point is in or just after a match for REGEXP.
Set the match data from the earliest such match ending at or after
point.
Optional argument DISTANCE limits search for REGEXP forward and
back from point."
(let* ((old (point))
(beg (if distance (max (point-min) (- old distance)) (point-min)))
(end (if distance (min (point-max) (+ old distance))))
prev match)
(save-excursion
(goto-char beg)
(while (and (setq prev (point)
match (re-search-forward regexp end t))
(< (match-end 0) old))
(goto-char (match-beginning 0))
;; Avoid inflooping when `regexp' matches the empty string.
(unless (< prev (point)) (forward-char))))
(and match (<= (match-beginning 0) old (match-end 0)))))