Function: isearch-forward-thing-at-point

isearch-forward-thing-at-point is an interactive and byte-compiled function defined in isearch.el.gz.

Signature

(isearch-forward-thing-at-point)

Documentation

Do incremental search forward for the "thing" found near point.

Like ordinary incremental search except that the "thing" found at point is added to the search string initially. The "thing" is defined by bounds-of-thing-at-point. You can customize the variable isearch-forward-thing-at-point(var)/isearch-forward-thing-at-point(fun) to define a list of symbols to try to find a "thing" at point. For example, when the list contains the symbol region and the region is active, then text from the active region is added to the search string.

View in manual

Probably introduced at or before Emacs version 28.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/isearch.el.gz
(defun isearch-forward-thing-at-point ()
  "Do incremental search forward for the \"thing\" found near point.
Like ordinary incremental search except that the \"thing\" found at point
is added to the search string initially.  The \"thing\" is defined by
`bounds-of-thing-at-point'.  You can customize the variable
`isearch-forward-thing-at-point' to define a list of symbols to try
to find a \"thing\" at point.  For example, when the list contains
the symbol `region' and the region is active, then text from the
active region is added to the search string."
  (interactive)
  (isearch-forward nil 1)
  (let ((bounds (seq-some (lambda (thing)
                            (bounds-of-thing-at-point thing))
                          isearch-forward-thing-at-point)))
    (cond
     (bounds
      (when (use-region-p)
        (deactivate-mark))
      (when (< (car bounds) (point))
	(goto-char (car bounds)))
      (isearch-yank-string
       (buffer-substring-no-properties (car bounds) (cdr bounds))))
     (t
      (setq isearch-error "No thing at point")
      (isearch-push-state)
      (isearch-update)))))