Function: evil--find-thing

evil--find-thing is a byte-compiled function defined in evil-search.el.

Signature

(evil--find-thing FORWARD THING)

Documentation

Return a cons of THING near point as a string and its position.

THING should be a symbol understood by thing-at-point, e.g. symbol or word. If FORWARD is nil, search backward, otherwise forward. Returns nil if nothing is found.

Source Code

;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-search.el
(defun evil--find-thing (forward thing)
  "Return a cons of THING near point as a string and its position.
THING should be a symbol understood by `thing-at-point',
e.g. `symbol' or `word'.  If FORWARD is nil, search backward,
otherwise forward.  Returns nil if nothing is found."
  (let ((move (if forward #'forward-char #'backward-char))
        (end (if forward #'eobp #'bobp))
        string)
    (save-excursion
      (setq string (thing-at-point thing))
      ;; if there's nothing under point, go forwards
      ;; (or backwards) to find it
      (while (and (null string) (not (funcall end)))
        (funcall move)
        (setq string (thing-at-point thing)))
      (when (stringp string)
        (set-text-properties 0 (length string) nil string))
      (when (> (length string) 0)
        (cons string (point))))))