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>, emacs-devel@gnu.org
Subject: Tree-sitter modes and nested functions
Date: Thu, 1 Dec 2022 14:55:28 -0700	[thread overview]
Message-ID: <CAGjvy29iOYv9M7fyvywo=TaS6ZMaQQhc-wumvQyMMmYpbRj8Sw@mail.gmail.com> (raw)

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

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()

Step to reproduce:
emacs -nw -Q  ;; built from master
M-: (require 'treesit)
C-x C-f test.py
M-x python-ts-mode
;; move point to position 1
M-:  (goto-char (treesit-node-start (treesit-search-forward
(treesit-node-at (point)) "function_definition")))
;; point is now at destination 1
;; move point to position 2
M-:  (goto-char (treesit-node-start (treesit-search-forward
(treesit-node-at (point)) "function_definition")))
;; point is now at destination 2

Is this the intended behaviour?

-- 
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: 2015 bytes --]

             reply	other threads:[~2022-12-01 21:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-01 21:55 João Paulo Labegalini de Carvalho [this message]
2022-12-02  2:51 ` Tree-sitter modes and nested functions Yuan Fu
2022-12-03 20:00   ` João Paulo Labegalini de Carvalho
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='CAGjvy29iOYv9M7fyvywo=TaS6ZMaQQhc-wumvQyMMmYpbRj8Sw@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.