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 #160 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: Mickey Petersen <mickey <at> masteringemacs.org>, Yuan Fu <casouri <at> gmail.com>,
 Theodor Thornhill <theo <at> thornhill.no>, 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: Mon, 30 Dec 2024 20:59:23 +0200
>> 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'.
>
> I don't have a good suggestion for the actual naming.
>
> Regarding the fact that this arg can take a either symbol or a function
> (which suffers from a risk of ambiguity, like you discovered), I think
> it's very important to try and avoid the intersection of the two, and
> a "standard" way to do that is to use keywords, like `:list`.

Then for backward-compatibility for existing things could
support both variants, e.g. 'sentence' and ':sentence',
'text' and ':text' (luckily no one yet defined such functions).
And for the new thing to use ':list', e.g.

  (setq-local treesit-thing-settings
              `((html
                 (:sexp ,(regexp-opt '("element" "text" "attribute" "value")))
                 (:list ,(regexp-opt '("element"")))
                 (:sentence "tag")
                 (:text ,(regexp-opt '("comment" "text"))))))

Another variant to avoid ambiguity would be to use a special syntax
in calls, e.g. instead of  (treesit-thing-next pos 'list)
to use (treesit-thing-next pos '(thing 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.