Subject: bug#73404: 30.0.50; [forward/kill/etc]-sexp commands do not behave as expected in tree-sitter modes

From: Juri Linkov <[email-masked]>
Date: Mon, 30 Dec 2024 20:59:23 +0200

>> BTW, my initial intention was to add the thing 'list'.
>> But then I discovered that (treesit-thing-next (point) 'list)
>> uses the function 'list' instead of the thing 'list'.
>
> I don't have a good suggestion for the actual naming.
>
> Regarding the fact that this arg can take a either symbol or a function
> (which suffers from a risk of ambiguity, like you discovered), I think
> it's very important to try and avoid the intersection of the two, and
> a "standard" way to do that is to use keywords, like `:list`.

Then for backward-compatibility for existing things could
support both variants, e.g. 'sentence' and ':sentence',
'text' and ':text' (luckily no one yet defined such functions).
And for the new thing to use ':list', e.g.

  (setq-local treesit-thing-settings
              `((html
                 (:sexp ,(regexp-opt '("element" "text" "attribute" "value")))
                 (:list ,(regexp-opt '("element"")))
                 (:sentence "tag")
                 (:text ,(regexp-opt '("comment" "text"))))))

Another variant to avoid ambiguity would be to use a special syntax
in calls, e.g. instead of  (treesit-thing-next pos 'list)
to use (treesit-thing-next pos '(thing list)).