Subject: bug#75609: Hideshow support for treesitter

From: Juri Linkov <[email-masked]>
Date: Sat, 18 Jan 2025 19:43:19 +0200

>> +(defun treesit-hs-inside-comment-p ()
>> +  (let ((thing (or (treesit-thing-at (point) "comment")
>> +                   (unless (bobp)
>> +                     (treesit-thing-at (1- (point)) "comment")))))
>> +    (when thing
>> +      (list (treesit-node-start thing) (treesit-node-end thing)))))
>> +
>
> FYI some grammar calls comments line_comment and block_comment.
> Maybe use the comment thing first, and then match “comment” with the node type?

We need to introduce the new thing named "comment".
It's necessary to add treesit support for 'forward-comment'
that is used in many packages including 'hideshow'.

This means adding the variable 'forward-comment-function'
with the default value 'forward-comment-default-function'.
Then will override it with 'treesit-forward-comment' that
uses the comment thing.

>> @@ -644,6 +648,9 @@ hs-inside-comment-p
>> beginning.  If we are inside of a comment but this condition is not met,
>> we return a list having a nil as its car and the end of comment position
>> as cdr."
>> +  (cond ((functionp hs-inside-comment-p-func)
>> +         (funcall hs-inside-comment-p-func))
>> +  (t
>
> Did you do this indentation on purpose to make a easier-to-read diff?

Indeed, this was to make it easier-to-read.  And in the next patch
I will just rename the default function to 'hs-inside-comment-p--default'.