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 #256 received at 73404 <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Theodor Thornhill <theo <at> thornhill.no>, Eli Zaretskii <eliz <at> gnu.org>,
 Mickey Petersen <mickey <at> masteringemacs.org>, 73404 <at> debbugs.gnu.org,
 Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#73404: 30.0.50; [forward/kill/etc]-sexp commands do not
 behave as expected in tree-sitter modes
Date: Tue, 7 Jan 2025 18:27:13 -0800

> On Jan 7, 2025, at 11:25 AM, Stefan Monnier <monnier <at> iro.umontreal.ca> wrote:
> 
>> Indeed, symbols are more traditional.
>> 
>> However, the problem arose only because
>> 'treesit_traverse_validate_predicate' accepts a symbol
>> for both a function and a thing, that caused ambiguity.
>> 
>> So there are two variants to resolve this ambiguity:
>> 
>> 1. use keywords like
>> 
>>  (setq-local treesit-thing-settings
>>              `((html
>>                 (:sexp ,(regexp-opt '("element" "text" "attribute" "value")))
>>                 (:list ,(regexp-opt '("element"")))
>>                 (:sentence "tag")
>>                 (:text ,(regexp-opt '("comment" "text"))))))
>> 
>> 2. use a symbol property like (put 'list 'treesit-thing t)
>> 
>> You decide ;-)
> 
> Of course, there are more alternatives:
> 
> - Use a symbol property like (put 'list 'treesit--this-is-a-function t)
> - Refuse functions represented as symbols (callers need to use an
>  eta-wrapper).
> - Distinguish the two cases via a more verbose representation like
>  `(thing list)` vs `(function list)`.
> - Use a string rather than a symbol.
> - <I'm sure you can come up with more options>

Thanks. IMHO it’s best to keep it simple and familiar, so let’s keep using symbols and use a symbol property to solve this edge case. I think this problem is rare enough that we don’t need any fancy solutions for it.

Juri, please feel free to apply your symbol property patch. For the symbol property name, I feel that something like treesit-symbol-predicate/treesit-use-as-symbol-predicate would be more descriptive. Since we don’t have docstrings for symbol properties (right?). Also it’d be nice to document this in the manual, maybe in the manual section for treesit-thing-settings. The docstring probably don’t need this niche detail.

Yuan



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.