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

Previous Next

Package: emacs;

Reported by: Mickey Petersen <mickey <at> masteringemacs.org>

Date: Sat, 21 Sep 2024 05:13:01 UTC

Severity: normal

Merged with 74366

Found in version 30.0.50

Fixed in version 31.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

Full log


Message #142 received at 73404 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Theodor Thornhill <theo <at> thornhill.no>, Yuan Fu <casouri <at> gmail.com>,
 Mickey Petersen <mickey <at> masteringemacs.org>, Eli Zaretskii <eliz <at> gnu.org>,
 73404 <at> debbugs.gnu.org
Subject: Re: bug#73404: 30.0.50; [forward/kill/etc]-sexp commands do not
 behave as expected in tree-sitter modes
Date: Sun, 29 Dec 2024 19:58:01 +0200
> So clearly instead of overriding `scan-lists` and `scan-sexps`,
> better would be to add 3 new variables: `forward-list-function`,
> `down-list-function` and `up-list-function`.

Ok, now these 3 functions are added in lisp.el and overridden in treesit.el.

>> What I do know is that in general we'd also want an `up-sexp` operation.
>> Currently we have an ugly kludge in `up-list` to try and use
>> `forward-sexp-function` (which is ugly both because
>> `forward-sexp-function` doesn't really provide the functionality we
>> need, and because it mixes up sexp and list navigation), and it would be
>> good to clean it up.
>
> Agreed, this distinction is required for treesit.  Hopefully,
> this can be achieved by separating `forward-sexp-function`
> and `up-list-function` that in ts-modes could be set to new
> functions either `treesit-up-list` or `treesit-up-sexp`.

Like `treesit-forward-sexp-list` uses `forward-sexp-default-function`
to move between symbols inside lists, I'm going to add syntax-based
fallback in `treesit-down-list` and `treesit-up-list` as well.
This is useful in strings and comments.  This is what `up-list`
already does.  Unfortunately, currently there is such limitation
in `down-list`:

  (when (ppss-comment-or-string-start (syntax-ppss))
    (user-error "This command doesn't work in strings or comments"))

But this is not a problem for `treesit-down-list`.




This bug report was last modified 131 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.