unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>, Ergus <spacibba@aol.com>,
	Yuan Fu <casouri@gmail.com>
Cc: 61374@debbugs.gnu.org
Subject: bug#61374: 30.0.50; Wrong mark-sexp with tree-sitter
Date: Thu, 09 Feb 2023 09:42:43 +0100	[thread overview]
Message-ID: <871qmzb56k.fsf@thornhill.no> (raw)
In-Reply-To: <BBF567ED-1891-44CA-916D-B057D23F08A9@thornhill.no>

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	other threads:[~2023-02-09  8:42 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <875ycbitav.fsf.ref@aol.com>
2023-02-09  0:19 ` bug#61374: 30.0.50; Wrong mark-sexp with tree-sitter Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-09  6:40   ` Eli Zaretskii
2023-02-09  6:49     ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-09  8:42       ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-02-09  8:54         ` Eli Zaretskii
2023-02-09  9:41           ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-09 10:52             ` Eli Zaretskii
2023-02-09 11:08               ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-09 16:14                 ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-09 17:47             ` Juri Linkov
2023-02-09 19:53               ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-14  8:50                 ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-14 10:50                   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-19  2:15                     ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-19  6:22                       ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-20 20:19                     ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871qmzb56k.fsf@thornhill.no \
    --to=bug-gnu-emacs@gnu.org \
    --cc=61374@debbugs.gnu.org \
    --cc=casouri@gmail.com \
    --cc=eliz@gnu.org \
    --cc=spacibba@aol.com \
    --cc=theo@thornhill.no \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).