From: Yuan Fu <casouri@gmail.com>
To: Wilhelm Kirschbaum <wkirschbaum@gmail.com>
Cc: 58711@debbugs.gnu.org
Subject: bug#58711: Treesit hangs when calling treesit-search-forward
Date: Sat, 22 Oct 2022 23:42:23 -0700 [thread overview]
Message-ID: <895A3C87-507A-4FC5-8BAE-B138B35CD40C@gmail.com> (raw)
In-Reply-To: <CAOS0-348zPFJEFNao2Ay06RKygsXv0WMFeLqquWBCJp5VgWbbw@mail.gmail.com>
> On Oct 22, 2022, at 2:53 AM, Wilhelm Kirschbaum <wkirschbaum@gmail.com> wrote:
>
> I am attempting to implement treesit for the current elixir-mode using the branch feature/trees-sitter. For implementing beginning-of-defun-function using treesit I am running into an issue where the Emacs will hang indefinitely. Using (setq-local treesit-defun-type-regexp (rx (or "call"))) yields the same result.
>
> For the following node-at-point output
>
> (do_block (call target: (identifier)))
>
> with Elixir code
>
> # foo.ex
> defmodule Foo do
> <<point/cursor here>>def bar(), do: "bar"
> end
>
> When I call `(treesit-search-forward-goto (rx (or "call")) 'start nil t)` the function `treesit-search-forward` seems to get stuck.
>
> Elixir does not strictly have a begin function, but can be determined as one of the following:
> ; * modules and protocols
> (call
> target: (identifier) @ignore
> (arguments (alias) @name)
> (#match? @ignore "^(defmodule|defprotocol)$")) @definition.module
>
> ; * functions/macros
> (call
> target: (identifier) @ignore
> (arguments
> [
> ; zero-arity functions with no parentheses
> (identifier) @name
> ; regular function clause
> (call target: (identifier) @name)
> ; function clause with a guard clause
> (binary_operator
> left: (call target: (identifier) @name)
> operator: "when")
> ])
> (#match? @ignore "^(def|defp|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp)$")) @definition.function
>
> The elixir tree sitter implementation is here: https://github.com/elixir-lang/tree-sitter-elixir
>
> I lack the knowledge to further debug this or find a clean workaround, but I'm almost sure that treesit-search-forward should never hang.
Thanks for reporting this. The way treesit-search-forward-goto works makes it very to have infinite loops. I revised the way it traverses the tree and now it should be impossible to fall into infinite loops.
Yuan
next prev parent reply other threads:[~2022-10-23 6:42 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 ` Yuan Fu [this message]
2022-10-23 23:20 ` bug#58711: Treesit hangs when calling treesit-search-forward 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
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
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=895A3C87-507A-4FC5-8BAE-B138B35CD40C@gmail.com \
--to=casouri@gmail.com \
--cc=58711@debbugs.gnu.org \
--cc=wkirschbaum@gmail.com \
/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).