unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Abin Simon <mail@meain.io>
To: emacs-devel@gnu.org
Subject: Question on getting tree-sitter matches
Date: Sun, 12 Mar 2023 20:02:18 +0530	[thread overview]
Message-ID: <87cz5ekpl9.fsf@meain.io> (raw)

Hey,

How would I get the set of matches from tree-sitter with items from the
same query together.

For example if I have a query of the following form:

    (function_declaration (identifier) @id) @func

elisp-tree-sitter returns this as the output of `tsc-query-matches`:

    [(0 . [
           (func . #<user-ptr ptr=0x4f7fa40 finalizer=0x7f2173b15780>)
           (id . #<user-ptr ptr=0x4f7fa00 finalizer=0x7f2173b15780>)
          ]
     )
     (0 . [
           (func . #<user-ptr ptr=0x10043a0 finalizer=0x7f2173b15780>)
           (id . #<user-ptr ptr=0x7b9a660 finalizer=0x7f2173b15780>)
          ]
     )
    ]


This groups the matches from the same "query" together.

I could only find `treesit-query-capture` which just returns a list of
captures items in the following form:

    (
     (func . #<treesit-node function_declaration in 441-791>)
     (id . #<treesit-node identifier in 446-460>)
     (func . #<treesit-node function_declaration in 865-1052>)
     (id . #<treesit-node identifier in 870-888>)
    )



             reply	other threads:[~2023-03-12 14:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-12 14:32 Abin Simon [this message]
2023-03-13  2:34 ` Question on getting tree-sitter matches Yuan Fu
2023-03-13  3:29   ` Abin Simon
2023-03-14 23:31     ` Yuan Fu
2023-03-15  4:24       ` Abin Simon
2023-03-19 21:59         ` Yuan Fu
2023-03-20  4:09           ` Abin Simon
2023-03-20 20:27           ` Ergus
2023-03-20 23:25             ` Yuan Fu
2023-03-21  3:29               ` Eli Zaretskii

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=87cz5ekpl9.fsf@meain.io \
    --to=mail@meain.io \
    --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 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).