Function: c-ts-mode--emacs-defun-at-point
c-ts-mode--emacs-defun-at-point is a byte-compiled function defined in
c-ts-mode.el.gz.
Signature
(c-ts-mode--emacs-defun-at-point &optional RANGE)
Documentation
Return the defun node at point.
In addition to regular C functions, this function recognizes
definitions of Lisp primitrives in Emacs source files using DEFUN,
if c-ts-mode-emacs-sources-support is non-nil.
Note that DEFUN is parsed by tree-sitter as two separate nodes, one for the declaration and one for the body; this function returns the declaration node.
If RANGE is non-nil, return (BEG . END) where BEG end END encloses the whole defun. This is for when the entire defun is required, not just the declaration part for DEFUN.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/c-ts-mode.el.gz
(defun c-ts-mode--emacs-defun-at-point (&optional range)
"Return the defun node at point.
In addition to regular C functions, this function recognizes
definitions of Lisp primitrives in Emacs source files using DEFUN,
if `c-ts-mode-emacs-sources-support' is non-nil.
Note that DEFUN is parsed by tree-sitter as two separate
nodes, one for the declaration and one for the body; this
function returns the declaration node.
If RANGE is non-nil, return (BEG . END) where BEG end END
encloses the whole defun. This is for when the entire defun
is required, not just the declaration part for DEFUN."
(when-let* ((node (treesit-defun-at-point))
(defun-range (cons (treesit-node-start node)
(treesit-node-end node))))
;; Make some adjustment for DEFUN.
(when c-ts-mode-emacs-sources-support
(cond ((c-ts-mode--emacs-defun-body-p node)
(setq node (treesit-node-prev-sibling node))
(setcar defun-range (treesit-node-start node)))
((c-ts-mode--emacs-defun-p node)
(setcdr defun-range (treesit-node-end
(treesit-node-next-sibling node))))))
(if range defun-range node)))