Function: treesit-hs-inside-comment-p
treesit-hs-inside-comment-p is a byte-compiled function defined in
treesit.el.gz.
Signature
(treesit-hs-inside-comment-p)
Documentation
Tree-sitter implementation of hs-inside-comment-predicate.
Source Code
;; Defined in /usr/src/emacs/lisp/treesit.el.gz
(defun treesit-hs-inside-comment-p ()
"Tree-sitter implementation of `hs-inside-comment-predicate'."
(when-let* ((comment-pred
(if (treesit-thing-defined-p 'comment (treesit-language-at (point)))
'comment "\\`comment\\'"))
(thing (or (treesit-thing-at (point) comment-pred)
(unless (bobp)
(treesit-thing-at (1- (point)) comment-pred))))
(beg (treesit-node-start thing))
(end (treesit-node-end thing)))
(unless (and (fboundp 'hs-hideable-region-p) (hs-hideable-region-p beg end))
(save-excursion
(goto-char beg)
(while (and (skip-chars-forward "[:blank:]")
(when-let* ((c (treesit-thing-at (point) comment-pred)))
(setq beg (treesit-node-start c)))
(not (bobp))
(forward-line -1)))
(goto-char beg)
(while (and (skip-chars-forward "[:blank:]")
(when-let* ((c (treesit-thing-at (point) comment-pred)))
(setq end (treesit-node-end c)))
(not (eobp))
(forward-line 1)))))
(list beg end)))