Subject: bug#74963: Ambiguous treesit named and anonymous nodes in ruby-ts-mode

From: Juri Linkov <[email-masked]>
Date: Thu, 30 Jan 2025 09:15:58 +0200

>>> Also, I finally added support for ‘and’, ‘named’ and ‘anonymous’. I haven’t test it yet (sorry).
>> 
>> Thanks!  Does it make sense also to add predicates to define
>> whether the node names should be matched completely?
>> Then maybe add two separate predicates for strict and lax matching,
>> e.g. for the same thing as above:
>> 
>>  (sentence
>>   (or (strict ,(rx (or "declaration"
>>                        "enum_specifier"
>>                        "union_specifier")))
>>       (lax ,(rx (or "preproc"
>>                     "statement")))))
>
> Hmm, I don’t know. Seems messy to implement, and we already have
> perfectly good solution: rx with bos or eos.

Ok, will use rx with bos and eos.

I have another question: in c-ts-mode forward-sentence
was intended to stop after a semicolon.  So I tried
to modify the sentence thing to match semicolons
inside the for_statement, e.g.:

  for (i = 0; i < 2; ++i)
=>
  (for_statement for (
   condition: (assignment_expression left: (identifier) operator: = right: (number_literal))
   ;
   body: (binary_expression left: (identifier) operator: < right: (number_literal))
   ;
   (update_expression operator: ++ argument: (identifier))
   )

where semicolons are after field names "condition" and "body".

But can't find a way to specify such field names for the node "for_statement".

Shouldn't treesit-thing-settings allow specifying field names as well?
Or this is achievable only by writing a lambda?