Function: treesit-thing-at-point

treesit-thing-at-point is a byte-compiled function defined in treesit.el.gz.

Signature

(treesit-thing-at-point THING TACTIC)

Documentation

Return the THING at point, or nil if none is found.

THING can be a symbol, a regexp, a predicate function, and more; see treesit-thing-settings for details.

Return the top-level THING if TACTIC is top-level(var)/top-level(fun); return the smallest enclosing THING as POS if TACTIC is nested.

View in manual

Probably introduced at or before Emacs version 30.1.

Source Code

;; Defined in /usr/src/emacs/lisp/treesit.el.gz
;; TODO: In corporate into thing-at-point.
(defun treesit-thing-at-point (thing tactic)
  "Return the THING at point, or nil if none is found.

THING can be a symbol, a regexp, a predicate function, and more;
see `treesit-thing-settings' for details.

Return the top-level THING if TACTIC is `top-level'; return the
smallest enclosing THING as POS if TACTIC is `nested'."

  (let ((node (treesit-thing-at (point) thing)))
    (if (eq tactic 'top-level)
        (treesit-node-top-level node thing t)
      node)))