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

From: Stefan Monnier <[email-masked]>
Date: Mon, 06 Jan 2025 15:07:28 -0500

> The main problem with empty opening and closing keywords is that
> nodes from different levels all end up at the same position,
> and currently treesit prefers a higher-level node.  This means
> that the sequence of `C-M-f C-M-b` is not idempotent anymore:
> `C-M-b` might jump to the start of a higher-level node.

It's never been idempotent, tho, e.g. in cases like:

    ;; Starting from before this comment
    ;; `C-M-f C-M-b` will end up after it.
    (hello world)

or

    + x

But indeed for list operations in indentation-based languages like
Haskell/Python/Coffeescript/YAML, we're faced again with the fact that
a closing LF can close several nested lists, so when going backward
there is some amount of ambiguity (and I'd argue that it's preferable
(and closer to the historical behavior) to choose to jump less far,
e.g. so that `C-M-n C-M-p` never moves backward).

> Also in treesit.el, forward-sexp and forward-list could share the
> same implementation.

[ I assume you mean "share *some* of the implementation", rather than
  being literally aliases of each other.  ]

        Stefan