unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Yuan Fu <casouri@gmail.com>
To: Abin Simon <mail@meain.io>
Cc: emacs-devel@gnu.org
Subject: Re: Question on getting tree-sitter matches
Date: Sun, 12 Mar 2023 19:34:59 -0700	[thread overview]
Message-ID: <C096BA3A-17DD-4C42-A249-6B7C89B6B8FB@gmail.com> (raw)
In-Reply-To: <87cz5ekpl9.fsf@meain.io>



> On Mar 12, 2023, at 7:32 AM, Abin Simon <mail@meain.io> wrote:
> 
> 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>)
>    )
> 

Unfortunately, that’s currently not possible. Could you elaborate on why you need such feature?

Thanks,
Yuan




  reply	other threads:[~2023-03-13  2:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-12 14:32 Question on getting tree-sitter matches Abin Simon
2023-03-13  2:34 ` Yuan Fu [this message]
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=C096BA3A-17DD-4C42-A249-6B7C89B6B8FB@gmail.com \
    --to=casouri@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=mail@meain.io \
    /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).