all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "João Paulo Labegalini de Carvalho" <jaopaulolc@gmail.com>
To: Yuan Fu <casouri@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: Tree-sitter modes and nested functions
Date: Sat, 3 Dec 2022 13:00:17 -0700	[thread overview]
Message-ID: <CAGjvy29kjz6sJ6M0QtUgMiKTjLO7oOt2hyNmLiPHr+UjoPVBcA@mail.gmail.com> (raw)
In-Reply-To: <E04E69B6-CC3B-4DEE-BD16-94882293C963@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1473 bytes --]

Thanks Yuan.

The word forward made me confused but the behavior is described in the
docstring.



On Thu, Dec 1, 2022 at 7:51 PM Yuan Fu <casouri@gmail.com> wrote:

>
>
> > On Dec 1, 2022, at 1:55 PM, João Paulo Labegalini de Carvalho <
> jaopaulolc@gmail.com> wrote:
> >
> > Hi,
> >
> > While working on code navigation for sh-mode with tree-sitter I think I
> found a bug.
> >
> > When invoking `treesit-search-forward' the deepest nested function is
> returned instead of the first found node.
> >
> > ;; Contests of test.py
> > #!/usr/bin/env python
> >                          <---- Point position 1
> > def foo():
> >     def bar():           <---- Point destination 1
> >         return 21
> >     return 2 * bar()
> >                          <---- Point position 2
> > def fuz():
> >     def bur():
> >       def buz():         <---- Point destination 2
> >         return 21
> >       return buz() + buz()
> >     return 1 * bur()
>
> Yeah this is expected, treesit-search-forward searches leaf nodes first
> and then parent nodes. If you want to implement beginning/end-of-defun I
> suggest taking a look at treesit-defun-type-regexp and
> treesit-defun-prefer-top-level.
>
> Yuan



-- 
João Paulo L. de Carvalho
Ph.D Computer Science |  IC-UNICAMP | Campinas , SP - Brazil
Postdoctoral Research Fellow | University of Alberta | Edmonton, AB - Canada
joao.carvalho@ic.unicamp.br
joao.carvalho@ualberta.ca

[-- Attachment #2: Type: text/html, Size: 2316 bytes --]

  reply	other threads:[~2022-12-03 20:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-01 21:55 Tree-sitter modes and nested functions João Paulo Labegalini de Carvalho
2022-12-02  2:51 ` Yuan Fu
2022-12-03 20:00   ` João Paulo Labegalini de Carvalho [this message]
2022-12-05 20:56     ` Yuan Fu

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=CAGjvy29kjz6sJ6M0QtUgMiKTjLO7oOt2hyNmLiPHr+UjoPVBcA@mail.gmail.com \
    --to=jaopaulolc@gmail.com \
    --cc=casouri@gmail.com \
    --cc=emacs-devel@gnu.org \
    /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.