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

From: Theodor Thornhill <[email-masked]>
Date: Sun, 05 Jan 2025 12:46:03 +0100

Juri Linkov <[email-masked]> writes:

>>> >> 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'.
>>> >> 
>>> >> However, the current 'sexp-list' as a two-word composite is too ugly.
>>> >> Now I found a better replacement: 'group'.  This word is already used
>>> >> in lisp.el such as in the docstring of 'forward-list':
>>> >
>>> > I don’t have an opinion on this.  Groups sounds a bit abstract, but so
>>> > does sexp-list.
>>> 
>>> Indeed, the right name is 'list'.  So let's use it.
>>
>> Please don't change the terminology yet.
>
> This doesn't change the terminology.  The ugly name was added a week ago.
> We need to fix it to the right name.  The right name is 'list' to
> conform to the function name 'forward-list'.
>
>> I'd like to try these commands with some tree-sitter modes and see
>> what names we could use for them.
>
> The command is 'forward-list'.  With 'list' it will do in ts-modes
> the same that 'forward-list' already does in non-ts modes.

One issue I've had when exploring these things earlier is that I don't
know the "spec" for how navigation in programming languages should work
in Emacs. I mean, there are lots of examples in the source code, but no
true specification. Should we possibly try to define some sane defaults
here, so that it will be simpler to deal with idiosyncrasies of the tree
sitter parsers? Lisp isn't in my experience the best language to define
this, as it is just too simple. Also, many of the functions are related
to word processing, like sentence, word, paragraph etc, which aren't
really useful in programming, imo. What is a sentence in java, lisp, or
python, for example? Also, maybe sexp is too lisp/ast-like of a term, so
much so that it is hard to reason about what a sexp is or isn't.