Subject: Re: 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: Thu, 09 Jan 2025 09:42:14 +0200

>>> 1. use keywords like
>>> 
>>>  (setq-local treesit-thing-settings
>>>              `((html
>>>                 (:sexp ,(regexp-opt '("element" "text" "attribute" "value")))
>>>                 (:list ,(regexp-opt '("element"")))
>>>                 (:sentence "tag")
>>>                 (:text ,(regexp-opt '("comment" "text"))))))
>>> 
>>> 2. use a symbol property like (put 'list 'treesit-thing t)
>>> 
>>> You decide ;-)
>> 
>> Of course, there are more alternatives:
>> 
>> - Use a symbol property like (put 'list 'treesit--this-is-a-function t)
>> - Refuse functions represented as symbols (callers need to use an
>>  eta-wrapper).
>> - Distinguish the two cases via a more verbose representation like
>>  `(thing list)` vs `(function list)`.
>> - Use a string rather than a symbol.
>> - <I'm sure you can come up with more options>
>
> Thanks.  IMHO it’s best to keep it simple and familiar, so let’s keep
> using symbols and use a symbol property to solve this edge case.
> I think this problem is rare enough that we don’t need any fancy
> solutions for it.
>
> Juri, please feel free to apply your symbol property patch. For the symbol
> property name, I feel that something like
> treesit-symbol-predicate/treesit-use-as-symbol-predicate would be more
> descriptive.

If we settle on the variant that keeps the current format with symbols,
wouldn't it better to keep a symbol property name shorter?

First I proposed 'treesit-predicate', but then realized it's wrong
since it's opposite to the predicate function.
'treesit-thing' was better since it indicates that it's used in
'treesit-thing-settings'.

> Since we don’t have docstrings for symbol properties (right?).

There are no docstrings for symbol properties indeed.  But I think
the important property for the name is that it should be unique enough
to be easily greppable.  But I tried to grep, and 'treesit-thing' finds
too many matches.

So probably the most suitable symbol name would be 'treesit-thing-symbol',
that currently has no occurrences in source code.