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: Sat, 22 Oct 2022 23:42:23 -0700 Message-ID: <895A3C87-507A-4FC5-8BAE-B138B35CD40C@gmail.com> References: 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="5649"; 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 07:46:34 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 1omqIE-0001Gl-5e for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 24 Oct 2022 07:46:34 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1omksR-0001k4-NJ for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 23 Oct 2022 19:59:35 -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 1omUhN-00062A-Cw for bug-gnu-emacs@gnu.org; Sun, 23 Oct 2022 02:43:05 -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 1omUhL-0007B0-GH for bug-gnu-emacs@gnu.org; Sun, 23 Oct 2022 02:43:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1omUhK-0006NX-Dm for bug-gnu-emacs@gnu.org; Sun, 23 Oct 2022 02:43: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 06:43: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.166650735324482 (code B ref 58711); Sun, 23 Oct 2022 06:43:02 +0000 Original-Received: (at 58711) by debbugs.gnu.org; 23 Oct 2022 06:42:33 +0000 Original-Received: from localhost ([127.0.0.1]:42791 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1omUgr-0006Mn-DT for submit@debbugs.gnu.org; Sun, 23 Oct 2022 02:42:33 -0400 Original-Received: from mail-pj1-f42.google.com ([209.85.216.42]:37788) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1omUgp-0006MW-9k for 58711@debbugs.gnu.org; Sun, 23 Oct 2022 02:42:31 -0400 Original-Received: by mail-pj1-f42.google.com with SMTP id f9-20020a17090a654900b00210928389f8so10362245pjs.2 for <58711@debbugs.gnu.org>; Sat, 22 Oct 2022 23:42:31 -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=CcZ/3jMzxd314xd1qLRSVqSuXL6/zEVUg+LEKnnD4WE=; b=lG5mpGfvwYzC0F5I5ArsK0YlAcZqhG0RRlqZgC2G3X2ueudBLEnnBh0dUK8zXrFUeX mc+06qVe+AeOg9KxrHmMCW4NO5oSe52OCVQm2kF7Grj7supQU6Mmi+TDSB94V2Dx49JX IQ/x6fidoGlclnj6o2FYYBDry+6lXou/Cwd1ebkpTO4YZEVaVOEeiWUKFRiUh5AlMxGA Yt/pT+svWKQJc8FdoDoC7po22grtNd4TuxyLlxzyAg90XdEPsIJooqr+awLkm1pUYO0e 8IdoHVF6RC9nx1tzZIlqHtwQH53QnJFGEjDPkjZD6JkyIGtkPM6V2gcXsWanwdsSXl1r zs/g== 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=CcZ/3jMzxd314xd1qLRSVqSuXL6/zEVUg+LEKnnD4WE=; b=ayEUeWCJZ1nl/C4n/Ym8grdJpePjUpjWtlLN16ds32FlKAUDhubdPMbb7+3dfn0fMo MlSUB9t16lAzqgzmUWvWXhqmOhxw0JMQF8e2Hkw9jn6BqDdYz+Tt2gS61MGqcA7aUBPd poDtELkaLKVIJG9Qiqh/twwVXp6gtJYEV1VVIconU1UJoJ8l0wpMVQuRrT4vCA+L4VTD mRhxuW5qNLI6It13Exhx/eO6kDx1Ln4OwQAdclcELXzEXQqreGZHri0uBPVmPJ0LOUBF S6vkFeWGIaC7PwVDs7s7pTvgYHxNKBR9WvIvrOSnMUmoWL6PQZFdjNaMLjvjs+v/Eb3L mNLw== X-Gm-Message-State: ACrzQf1wgJf6KLBPg23yqyXUyLpD/hsGsU+BfMeFYtF1CFBXhi/DE5iW XHgj5pnHNBTWutFj8TEkc3Y= X-Google-Smtp-Source: AMsMyM5Of5ANGtmj/hU+WH7iKgifmN8FCyTsTY80O7PDcq1DkWkQbp6Lakr90qt5KB0fYUr/ANgtFg== X-Received: by 2002:a17:90b:2242:b0:20d:a2be:95a4 with SMTP id hk2-20020a17090b224200b0020da2be95a4mr32040299pjb.159.1666507345352; Sat, 22 Oct 2022 23:42:25 -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 x1-20020a17090a8a8100b00203917403ccsm4006139pjn.1.2022.10.22.23.42.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 22 Oct 2022 23:42:24 -0700 (PDT) In-Reply-To: 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: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:246088 Archived-At: > 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 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