all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Evgeni Kolev <evgenysw@gmail.com>
To: Yuan Fu <casouri@gmail.com>
Cc: Theodor Thornhill <theo@thornhill.no>, 61617@debbugs.gnu.org
Subject: bug#61617: M-x mark-defun doesn't work correctly in tree-sitter modes when comments exist between functions
Date: Mon, 27 Feb 2023 18:03:37 +0200	[thread overview]
Message-ID: <CAMCrgaUNkUGO4WsTRuKiS5sSN8L_VJ71N-TEONWAVh65s-_PuA@mail.gmail.com> (raw)
In-Reply-To: <E2B1E42E-D741-4AA2-9C6D-36521F02F5F2@gmail.com>

Great, thanks for the fix! I tested a few common (for me) scenarios
and mark-defun works as expected!

On Mon, Feb 27, 2023 at 11:24 AM Yuan Fu <casouri@gmail.com> wrote:
>
>
>
> > On Feb 26, 2023, at 4:42 PM, Yuan Fu <casouri@gmail.com> wrote:
> >
> >
> >
> >> On Feb 24, 2023, at 11:27 PM, Evgeni Kolev <evgenysw@gmail.com> wrote:
> >>
> >> On Sat, Feb 25, 2023 at 7:08 AM Yuan Fu <casouri@gmail.com> wrote:
> >>
> >>> Huh, with or without comments, mark-defun always includes the empty
> >>> lines before the defun for me. I get the same behavior in rust-ts-mode.
> >>> This seems intentional, because this is at the end of the definition of
> >>> mark-defun:
> >>>
> >>> (skip-chars-backward "[:space:]\n")
> >>> (unless (bobp)
> >>> (forward-line 1))
> >>
> >> Did you check with my example or another example? With my example, the
> >> issue I get is that only the empty lines are marked, without the
> >> defun, without the comments. I'm attaching two screenshots - before
> >> and after mark-defun.
> >>
> >> Note: I get the correct behaviour when there is just one defun in the
> >> file. But if there are more, or the defun at point is not at the top
> >> of the file - mark-defun does not work as expected.
> >
> > Sorry, I used wrong go mode when testing your recipe. I used go-mode thinking it is go-ts-mode :-( Using go-ts-mode, I can reproduce what you see, yes.
> >
> > The problem you discovered revealed some shortcoming in our tree-sitter navigation function, and requires quite a few non-trivial changes, I working on fixing it.
> >
> > The direct cause is that (treesit-beginning-of-defun -1) is supposed to go to the beginning of next defun, but instead goes to the beginning of next next defun. That was a design decision I made but I can see it causing old functions to misbehave.
> >
> > Yuan
>
> The fix is brain-twisting but don’t embody a lot of code, yay! This now should be fixed.
>
> Yuan





      reply	other threads:[~2023-02-27 16:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-19  8:39 bug#61617: M-x mark-defun doesn't work correctly in tree-sitter modes when comments exist between functions Evgeni Kolev
2023-02-20  8:30 ` Evgeni Kolev
2023-02-25  5:08 ` Yuan Fu
2023-02-25  7:27   ` Evgeni Kolev
2023-02-27  0:42     ` Yuan Fu
2023-02-27  9:24       ` Yuan Fu
2023-02-27 16:03         ` Evgeni Kolev [this message]

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

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

  git send-email \
    --in-reply-to=CAMCrgaUNkUGO4WsTRuKiS5sSN8L_VJ71N-TEONWAVh65s-_PuA@mail.gmail.com \
    --to=evgenysw@gmail.com \
    --cc=61617@debbugs.gnu.org \
    --cc=casouri@gmail.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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.