all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Yuan Fu <casouri@gmail.com>
To: Wilhelm Kirschbaum <wilhelm@floatpays.co.za>
Cc: 58711@debbugs.gnu.org
Subject: bug#58711: Treesit hangs when calling treesit-search-forward
Date: Thu, 10 Nov 2022 00:14:27 -0800	[thread overview]
Message-ID: <82A013FB-9A94-4E57-9FD2-AF8E892241A9@gmail.com> (raw)
In-Reply-To: <CAJbepr8aYrWRLQ8TTKU=97z+yqhVa=Fsw_Vxthu6EbYidvPNhQ@mail.gmail.com>



> On Nov 9, 2022, at 10:44 PM, Wilhelm Kirschbaum <wilhelm@floatpays.co.za> wrote:
> 
> I finally had some time to have a look. I don't see any more issues, thank you for the fantastic work on this. The defun-type-regexp is not enough to identify a defun in elixir this is the query I am using currently:
> 
> (defvar elixir--treesit-query-defun
>   (let ((query `((call
>      target: (identifier) @type
>      (arguments
>       [
>        (alias) @name
>        (identifier) @name
>        (call target: (identifier)) @name
>        (binary_operator
>         left: (call target: (identifier)) @name
>         operator: "when")
>        ])
>      (:match ,elixir--definition-keywords-re @type)
>      ))))
>     (treesit-query-compile 'elixir query)))
> 
> Regex will work in most cases I guess, but does not really deal with more complex queries for more complex cases like in elixir as there is not one type which is always the defun. elixir relies heavily on macros and different defun macros can be defined on the fly.

You can try the following procedure: use a regex to find the next/previous call, then perform some check on whether it’s indeed a defun, if not, keep searching for the next/previous call.


> Maybe if there is an option for using either a regex or a function? 

Yes, instead of a regex you can pass a predicate function.

> 
> I am also not sure how forward-sexp can work with the current treesit-search-forward-goto function as it does not take into consideration the level. Is there perhaps a way to move forward/backward, but do not jump to parents or children? 

If you want to move in the same level, perhaps you can use treesit-next/prev/sibling?

Yuan




  reply	other threads:[~2022-11-10  8:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-22  9:53 bug#58711: Treesit hangs when calling treesit-search-forward Wilhelm Kirschbaum
2022-10-22 10:26 ` bug#58711: The full tree-sitter parse output Wilhelm Kirschbaum
2022-10-23  6:42 ` bug#58711: Treesit hangs when calling treesit-search-forward Yuan Fu
2022-10-23 23:20   ` Yuan Fu
2022-10-24 17:06     ` Wilhelm Hugo Kirschbaum
2022-10-24 20:19       ` Yuan Fu
2022-11-10  6:44         ` Wilhelm Kirschbaum
2022-11-10  8:14           ` Yuan Fu [this message]
2022-11-10 19:03             ` Wilhelm Kirschbaum
2022-11-10 19:05               ` Wilhelm Kirschbaum
2022-11-10 19:32                 ` Wilhelm Kirschbaum
2022-11-10 20:43                   ` Wilhelm Kirschbaum
2022-11-10 22:07                     ` Yuan Fu
2022-11-11  6:30                       ` Wilhelm Kirschbaum
2022-11-14  6:32                         ` Wilhelm Kirschbaum
2022-11-14  8:44                           ` Yuan Fu
2022-11-14 10:03                             ` Wilhelm Kirschbaum

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=82A013FB-9A94-4E57-9FD2-AF8E892241A9@gmail.com \
    --to=casouri@gmail.com \
    --cc=58711@debbugs.gnu.org \
    --cc=wilhelm@floatpays.co.za \
    /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.