[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#74963: Ambiguous treesit named and anonymous nodes in ruby-ts-mode
From: |
Juri Linkov |
Subject: |
bug#74963: Ambiguous treesit named and anonymous nodes in ruby-ts-mode |
Date: |
Wed, 25 Dec 2024 19:39:28 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) |
>> Not sure if a possible flexibility is better than unintended matches.
>>
>> When the authors of a ts-mode carefully selected a list of named nodes to
>> match,
>> why treesit should try to match some random and unintended anonymous nodes?
>
> I don’t know and can’t prove how much the flexibility is worth, but the
> cost on complexity is real. If everywhere else uses thing predicates as-is,
> but sexp navigation auto-converts thing predicates into named predicate,
> that’s a cognitive burden and a special case that’s guaranteed to trip
> people over.
>
> OTOH, what’s the downside of wrapping the sexp predicate with (and named …),
> if you only want named nodes to match?
>
> I just think the cost outweighs the benefit, if there is any to begin with.
Actually, what I had in mind is not to enable named-only mode by default,
but only to allow the authors of ts-modes to specify this condition.
For example, if it will be possible to write
(setq-local treesit-thing-settings
`((typescript
(sexp (and named ,(regexp-opt typescript-ts-mode--sexp-nodes
'symbols))))))
this should be fine. This is similar to how the authors of ts-modes
decide whether to restrict matches to exact names by using
"^...$" with regexp-opt.
BTW, I'm thinking about adding such simple helper:
(defun treesit-regexp-opt (strings)
(concat "^" (regexp-opt strings) "$"))
to use like this:
(setq-local treesit-thing-settings
`((typescript
(sexp (and named ,(treesit-regexp-opt
typescript-ts-mode--sexp-nodes))))))
- bug#74963: Ambiguous treesit named and anonymous nodes in ruby-ts-mode, (continued)
- bug#74963: Ambiguous treesit named and anonymous nodes in ruby-ts-mode, Juri Linkov, 2024/12/24
- bug#74963: Ambiguous treesit named and anonymous nodes in ruby-ts-mode, Juri Linkov, 2024/12/24
- bug#74963: Ambiguous treesit named and anonymous nodes in ruby-ts-mode, Dmitry Gutov, 2024/12/24
- bug#74963: Ambiguous treesit named and anonymous nodes in ruby-ts-mode, Juri Linkov, 2024/12/25
- bug#74963: Ambiguous treesit named and anonymous nodes in ruby-ts-mode, Dmitry Gutov, 2024/12/25
- bug#74963: Ambiguous treesit named and anonymous nodes in ruby-ts-mode, Juri Linkov, 2024/12/27
- bug#74963: Ambiguous treesit named and anonymous nodes in ruby-ts-mode, Juri Linkov, 2024/12/24
- bug#74963: Ambiguous treesit named and anonymous nodes in ruby-ts-mode, Yuan Fu, 2024/12/24
- bug#74963: Ambiguous treesit named and anonymous nodes in ruby-ts-mode, Juri Linkov, 2024/12/25
- bug#74963: Ambiguous treesit named and anonymous nodes in ruby-ts-mode, Yuan Fu, 2024/12/25
- bug#74963: Ambiguous treesit named and anonymous nodes in ruby-ts-mode,
Juri Linkov <=
- bug#73404: 30.0.50; [forward/kill/etc]-sexp commands do not behave as expected in tree-sitter modes, Juri Linkov, 2024/12/19
- bug#73404: 30.0.50; [forward/kill/etc]-sexp commands do not behave as expected in tree-sitter modes, Juri Linkov, 2024/12/19
- bug#73404: 30.0.50; [forward/kill/etc]-sexp commands do not behave as expected in tree-sitter modes, Juri Linkov, 2024/12/24
- bug#73404: 30.0.50; [forward/kill/etc]-sexp commands do not behave as expected in tree-sitter modes, Yuan Fu, 2024/12/24
- bug#73404: 30.0.50; [forward/kill/etc]-sexp commands do not behave as expected in tree-sitter modes, Juri Linkov, 2024/12/25
- bug#73404: 30.0.50; [forward/kill/etc]-sexp commands do not behave as expected in tree-sitter modes, Yuan Fu, 2024/12/25
- bug#73404: 30.0.50; [forward/kill/etc]-sexp commands do not behave as expected in tree-sitter modes, Juri Linkov, 2024/12/25
- bug#73404: 30.0.50; [forward/kill/etc]-sexp commands do not behave as expected in tree-sitter modes, Juri Linkov, 2024/12/27
- bug#73404: 30.0.50; [forward/kill/etc]-sexp commands do not behave as expected in tree-sitter modes, Stefan Monnier, 2024/12/25
- bug#73404: 30.0.50; [forward/kill/etc]-sexp commands do not behave as expected in tree-sitter modes, Juri Linkov, 2024/12/25