From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.bugs Subject: bug#58711: Treesit hangs when calling treesit-search-forward Date: Sun, 23 Oct 2022 16:20:01 -0700 Message-ID: <46B629C0-1413-41CE-BDA8-CE14C12B4449@gmail.com> References: <895A3C87-507A-4FC5-8BAE-B138B35CD40C@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23765"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 58711@debbugs.gnu.org To: Wilhelm Kirschbaum Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Oct 24 06:45:33 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 1ompL9-00061V-UE for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 24 Oct 2022 06:45:31 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1omnb9-0002WT-8P; Sun, 23 Oct 2022 22:53:55 -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 1omkH9-0008Q4-Pg for bug-gnu-emacs@gnu.org; Sun, 23 Oct 2022 19: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 1omkH8-0003Z2-Ng for bug-gnu-emacs@gnu.org; Sun, 23 Oct 2022 19:21:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1omkH8-0001Wd-Bp for bug-gnu-emacs@gnu.org; Sun, 23 Oct 2022 19:21:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 23 Oct 2022 23: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.16665672125781 (code B ref 58711); Sun, 23 Oct 2022 23:21:02 +0000 Original-Received: (at 58711) by debbugs.gnu.org; 23 Oct 2022 23:20:12 +0000 Original-Received: from localhost ([127.0.0.1]:46653 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1omkGJ-0001VB-O6 for submit@debbugs.gnu.org; Sun, 23 Oct 2022 19:20:12 -0400 Original-Received: from mail-pl1-f169.google.com ([209.85.214.169]:34719) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1omkGH-0001Uv-D1 for 58711@debbugs.gnu.org; Sun, 23 Oct 2022 19:20:10 -0400 Original-Received: by mail-pl1-f169.google.com with SMTP id n7so7129933plp.1 for <58711@debbugs.gnu.org>; Sun, 23 Oct 2022 16:20:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=s014aqWaGM4G4ZfToYWFeurVWzGqHeapX3xCPvUQdOA=; b=F9zSgfb4hFBuHppdEI0amc1kPYZSZMas6FLLMtWnRAjgyAvhmDhh0kOe21lKtlBI47 KmFGAEtr5sfo19k+VFYaEtxq3j+9Uf4Z9T5Be24xyEmt/A61DVsFDuh5+nX12h+hMLET tLpRK2K19HHzxWECg8rDL41twA8+okU/ohAUYNOEDKvc5Kx/Gu4RmLqu93FJZ/Map9h+ yWcR/PN3ll0nfMon8zpTJw8w8sUxXWjQZaEz8dXAOagIe4m+9mnFvFjwYh5fx1TWJffO fHujoZ7TofUp/s+BubZJAAEUegclwqHDsSaZQ4wM/vfIEEANPwxcNkw5vcpV2OD79Hj/ 0/VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=s014aqWaGM4G4ZfToYWFeurVWzGqHeapX3xCPvUQdOA=; b=75FPolwZptkIs4id87MDLSPhbUmtf16eExUVH8gnyrLiQhlGrEeVgtGbb5XKhS7Pp+ bnpOWL/ux30XNHX0UvLA2jdDpgrV/1LTZjT3oK70qcpLgGusM4DY63VjXXQI/jpXJMPE 1JODLvA5uU41CZLzbinhtZpOkxi3zEi8HjgdTBcIcB8c7p1rPFAGT6l8GRgOWoDss1gf iwTs9GBRvsI8HLGvIv2PJbkO1TlXwMfkL8NiQgJBuk7vlwIv/+J3t4M7oCrbYOnLSa33 WuIUaq0RfXVvNzXdxobDq0Gd96wPKw+IM0Hq4gxN0JFUY/+Cw5MAH57UMneb6jdt9ROn dgSA== X-Gm-Message-State: ACrzQf2pHszwoqntiWh2cZUPh0oEIV3VCmdf80sSdhQX+w0f9JhzJnfB f0jL72khsJbtUWlNiytzMGM= X-Google-Smtp-Source: AMsMyM4s/ke3FzTKXiJAUY7ENh9fAu6AWoLjbPeR0EsOyi9AKyrRTUSM7yuE/d4gIwacej/bTch8EQ== X-Received: by 2002:a17:902:e852:b0:186:96fe:56d9 with SMTP id t18-20020a170902e85200b0018696fe56d9mr7026526plg.69.1666567203449; Sun, 23 Oct 2022 16:20:03 -0700 (PDT) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id k17-20020a170902d59100b00186a8085382sm764742plh.43.2022.10.23.16.20.02 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 23 Oct 2022 16:20:03 -0700 (PDT) In-Reply-To: <895A3C87-507A-4FC5-8BAE-B138B35CD40C@gmail.com> X-Mailer: Apple Mail (2.3696.120.41.1.1) 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:246078 Archived-At: > On Oct 22, 2022, at 11:42 PM, Yuan Fu wrote: >=20 >=20 >=20 >> On Oct 22, 2022, at 2:53 AM, Wilhelm Kirschbaum = wrote: >>=20 >> 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. >>=20 >> For the following node-at-point output >>=20 >> (do_block (call target: (identifier))) >>=20 >> with Elixir code >>=20 >> # foo.ex >> defmodule Foo do >> <>def bar(), do: "bar" >> end >>=20 >> When I call `(treesit-search-forward-goto (rx (or "call")) 'start nil = t)` the function `treesit-search-forward` seems to get stuck.=20 >>=20 >> 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 >>=20 >> ; * 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 >>=20 >> The elixir tree sitter implementation is here: = https://github.com/elixir-lang/tree-sitter-elixir >>=20 >> 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.=20 >=20 > 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. >=20 > Yuan Just a heads up: I changed the function signature of = treesit-search-forward-goto in the latest commit. Yuan