From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Wilhelm Hugo Kirschbaum Newsgroups: gmane.emacs.bugs Subject: bug#58711: Treesit hangs when calling treesit-search-forward Date: Mon, 24 Oct 2022 19:06:58 +0200 Message-ID: <3054006.Zh9iicr411@melissa.local> References: <895A3C87-507A-4FC5-8BAE-B138B35CD40C@gmail.com> <46B629C0-1413-41CE-BDA8-CE14C12B4449@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39012"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 58711@debbugs.gnu.org To: Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Oct 24 20:58:46 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1on2er-0009vj-EZ for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 24 Oct 2022 20:58:45 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1on24R-00071H-Md; Mon, 24 Oct 2022 14:21:07 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1on24N-00070E-D3 for bug-gnu-emacs@gnu.org; Mon, 24 Oct 2022 14:21:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1on24N-0007ZA-5W for bug-gnu-emacs@gnu.org; Mon, 24 Oct 2022 14:21:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1on24M-0006F2-Vz for bug-gnu-emacs@gnu.org; Mon, 24 Oct 2022 14:21:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Wilhelm Hugo Kirschbaum Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 24 Oct 2022 18:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58711 X-GNU-PR-Package: emacs Original-Received: via spool by 58711-submit@debbugs.gnu.org id=B58711.166663561623898 (code B ref 58711); Mon, 24 Oct 2022 18:21:02 +0000 Original-Received: (at 58711) by debbugs.gnu.org; 24 Oct 2022 18:20:16 +0000 Original-Received: from localhost ([127.0.0.1]:49526 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1on23b-0006DM-NZ for submit@debbugs.gnu.org; Mon, 24 Oct 2022 14:20:16 -0400 Original-Received: from mail-wm1-f50.google.com ([209.85.128.50]:52142) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1on0uq-0004NY-PQ for 58711@debbugs.gnu.org; Mon, 24 Oct 2022 13:07:10 -0400 Original-Received: by mail-wm1-f50.google.com with SMTP id v11so6954635wmd.1 for <58711@debbugs.gnu.org>; Mon, 24 Oct 2022 10:07:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=floatpays.co.za; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zu8DoA7ENLGKOaa84h4iclAzB+EgAQ0ADNcFN+tToPc=; b=Yr9QLH3tObR/veAkrI91zvBCtwzVAT3klkiDextTCv6bs1ZWcfVhcY6JW27cDfCx5c r7XEdBNMpcZ/wqVuVSBTJyhOay9lNGR44Blk8Ra0jewo10ecveW+qSy6CIlwAR7OUF11 JvGHMw0K7axrDyt7aQapoyebLLrVeaubALt8k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zu8DoA7ENLGKOaa84h4iclAzB+EgAQ0ADNcFN+tToPc=; b=TtDaxoOUie63GuTGTtH8i3gOT+ukckMWyh9BKAHpzG7ip0SznO+vwNDXNrVu/NWd8v JFPAJv7UEE6S9zybzepciwG02M5EpCrsCDgdPCTeVhfnyGDrJ11kPXLwmYZvmwNw4sR9 Ps4IG7KdIX74zaFGzpN6lBXK0rjbqORWrRn5Sil9NngG71MBrj0jTjFbaBfIEN2TOCy2 ktbAQ3U9Eyg1fj43LNrA7MiJKAF4V0nE+IIz2yDMZlxWTBHM+7OKCWcD1ijcaQ191/hQ NoAhYTHvjTxrd0YN7rn9nbgR3bTwjZ4g+vXHRJR/POejD8wQkiDana3cWNKzHd0iKfpl c26g== X-Gm-Message-State: ACrzQf3Jt5STwyk6Boiy5BKOi7StmC6Fk0Ju09W1sk7v+IHuSmt7wUx/ yCQqSfvp6eetmR7ZcP9d+cTZUA== X-Google-Smtp-Source: AMsMyM5A4jgnKgC0TWeinKBIbveb6286OrcdOC9J9PIaWMhu4MQP1E0VOs9VchliYhdkkWdz68oOKg== X-Received: by 2002:a05:600c:35c8:b0:3c8:33dc:c262 with SMTP id r8-20020a05600c35c800b003c833dcc262mr10949602wmq.206.1666631222681; Mon, 24 Oct 2022 10:07:02 -0700 (PDT) Original-Received: from melissa.local ([2c0f:ef18:1431:0:b09:9616:db04:c248]) by smtp.gmail.com with ESMTPSA id k11-20020a056000004b00b0023657e1b97esm183848wrx.11.2022.10.24.10.07.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 10:07:02 -0700 (PDT) X-Google-Original-From: Wilhelm Hugo Kirschbaum In-Reply-To: <46B629C0-1413-41CE-BDA8-CE14C12B4449@gmail.com> X-Mailman-Approved-At: Mon, 24 Oct 2022 14:20:15 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: "bug-gnu-emacs" Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:246117 Archived-At: On Monday, 24 October 2022 01:20:01 SAST Yuan Fu wrote: > > On Oct 22, 2022, at 11:42 PM, Yuan Fu wrote: > >> On Oct 22, 2022, at 2:53 AM, Wilhelm Kirschbaum > >> 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 > >> > >> <>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|defn > >> p)$")) @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 > > Just a heads up: I changed the function signature of > treesit-search-forward-goto in the latest commit. > > Yuan Thanks, I would need some time to have a proper look. The reporting issue seems to have been fixed. There are some complications to identify the appropriate node for defun in elixir as a "call" node might, or might not be defun, depending on its child identifier ( i currently have to do a query on cycling up the parent ), but will try the respond in more detail in another thread.