bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#61374: 30.0.50; Wrong mark-sexp with tree-sitter


From: Theodor Thornhill
Subject: bug#61374: 30.0.50; Wrong mark-sexp with tree-sitter
Date: Thu, 09 Feb 2023 09:42:43 +0100

Theodor Thornhill <theo@thornhill.no> writes:

> On 9 February 2023 07:40:27 CET, Eli Zaretskii <eliz@gnu.org> wrote:
>>> Date: Thu, 09 Feb 2023 01:19:52 +0100
>>> From:  Ergus via "Bug reports for GNU Emacs,
>>>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>>> 
>>> Just trying tree-sitter with c++-mode is doing a wrong mark-sexp.
>>> 
>>> With this code:
>>> 
>>> {
>>>   vector<int> myvar;
>>> }
>>> 
>>> M-x c++-ts-mode
>>> 
>>> go to { and do C-M-SPC. The region marked goes from { up to > instead of
>>> the corresponding }
>>
>>The problem is in forward-sexp (try C-M-f from the same place), which
>>C-M-SPC calls.  This problem exists only on master, where forward-sexp
>>was modified to call treesit-forward-sexp; on emacs-29 the behavior is
>>as expected.
>>
>>CC'ing Yuan and Theo, who will probably find a fix in no time...
>>
>>Thanks.
>
> I'll look at it in just a bit :)
>
> Thanks for pinging!
>
> Theo


I think to remember why I decided on the current settings in
'treesit-sexp-type-regexp' - compound_statement is very frequently used
in the c/c++ grammars, and iirc that makes sexp-moving almost always
move to end of the next or current compound_statement.

try adding

```

  (setq-local treesit-sexp-type-regexp
              (regexp-opt '("preproc"
                            "declarator"
                            "qualifier"
                            "type"
                            "parameter"
                            "expression"
                            "literal"
                            "string"
                            "statement")))
```

and observe that mark-sexp and forward-sexp is ok now wrt this
bug-report, but running same commands inside of a scope may not.  I'm
not sure what the best combination of nodes for this particular regexp
is, but maybe you can give me some expectations, Ergus, and I can follow
up with some new settings?

Theo





reply via email to

[Prev in Thread] Current Thread [Next in Thread]