Function: treesit-show-paren-data--categorize
treesit-show-paren-data--categorize is a byte-compiled function
defined in treesit.el.gz.
Signature
(treesit-show-paren-data--categorize POS &optional END-P)
Documentation
Return a list suitable for show-paren-data-function (which see).
If the optional argument END-P is non-nil, interpret the position POS as belonging to the node that ends before POS (by subtracting 1 from POS).
Source Code
;; Defined in /usr/src/emacs/lisp/treesit.el.gz
;;; Show paren mode
(defun treesit-show-paren-data--categorize (pos &optional end-p)
"Return a list suitable for `show-paren-data-function' (which see).
If the optional argument END-P is non-nil, interpret the position POS
as belonging to the node that ends before POS (by subtracting 1 from POS)."
(let* ((pred 'list)
(parent (when (treesit-thing-defined-p
pred (treesit-language-at (if end-p (1- pos) pos)))
(treesit-parent-until
(treesit-node-at (if end-p (1- pos) pos)) pred)))
(first (when parent (treesit-node-child parent 0)))
(first-start (when first (treesit-node-start first)))
(first-end (when first (treesit-node-end first)))
(last (when parent (treesit-node-child parent -1)))
(last-start (when last (treesit-node-start last)))
(last-end (when last (treesit-node-end last)))
(dir (if show-paren-when-point-inside-paren
(cond
((and first (<= first-start pos first-end)) 1)
((and last (<= last-start pos last-end)) -1))
(cond
((and first (= first-start pos)) 1)
((and last (= pos last-end)) -1)))))
(cond
((eq dir 1) (list first-start first-end last-start last-end))
((eq dir -1) (list last-start last-end first-start first-end)))))