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: Thu, 10 Nov 2022 00:14:27 -0800 Message-ID: <82A013FB-9A94-4E57-9FD2-AF8E892241A9@gmail.com> References: <895A3C87-507A-4FC5-8BAE-B138B35CD40C@gmail.com> <46B629C0-1413-41CE-BDA8-CE14C12B4449@gmail.com> <3054006.Zh9iicr411@melissa.local> <106B8822-FE37-4590-BC77-5FB24FB0758C@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5391"; 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 Thu Nov 10 09:15:25 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 1ot2ib-0001Cy-MZ for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 10 Nov 2022 09:15:25 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ot2iL-0003AD-G3; Thu, 10 Nov 2022 03:15:09 -0500 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 1ot2iF-00039V-1H for bug-gnu-emacs@gnu.org; Thu, 10 Nov 2022 03:15:04 -0500 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 1ot2iE-0000Hd-OX for bug-gnu-emacs@gnu.org; Thu, 10 Nov 2022 03:15:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ot2iE-0002LG-9r for bug-gnu-emacs@gnu.org; Thu, 10 Nov 2022 03:15:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 10 Nov 2022 08:15: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.16680680788958 (code B ref 58711); Thu, 10 Nov 2022 08:15:02 +0000 Original-Received: (at 58711) by debbugs.gnu.org; 10 Nov 2022 08:14:38 +0000 Original-Received: from localhost ([127.0.0.1]:41807 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ot2hq-0002KP-AA for submit@debbugs.gnu.org; Thu, 10 Nov 2022 03:14:38 -0500 Original-Received: from mail-pf1-f176.google.com ([209.85.210.176]:35573) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ot2hn-0002KC-QN for 58711@debbugs.gnu.org; Thu, 10 Nov 2022 03:14:36 -0500 Original-Received: by mail-pf1-f176.google.com with SMTP id k15so1286009pfg.2 for <58711@debbugs.gnu.org>; Thu, 10 Nov 2022 00:14:35 -0800 (PST) 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=IcGCtn0tR9k8kZq9kEkiPONjfMG/G2gaI4+kmDvI3AY=; b=M0sjuVCpwc1NLD+uU0I2f6Ohnt5CsW3ArfJSjE7CKrLWuJaiZJ2wgACJPdUJHjmqRR pPvpNssQ1f08fvWoFYN8OoHcVzl27nXvVoYYEaU+94eiwIIrzKKjCcKFzQo3JYKvb4Ol 1kGzZDDiQk1JLq47BwZQDWhZg91d7hge7mD7hQwvHe8fGrlwvWe9GOnqpdIay60MPplQ Pkxrcq8WldSB1/R203mtIieiHpZ2E/soFNS30qhEO1Q5ZjiLx+T9z1mx5G0XujnPzbE6 nbJ1zjXqzBB/NCW071odIxf1SEKgbhnqZrCg2uUuEDSvar8htTqZkZOOcQRY+tlVXSX9 2mXA== 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=IcGCtn0tR9k8kZq9kEkiPONjfMG/G2gaI4+kmDvI3AY=; b=rqo1CRcG2+Nw8s0rsDUhd/Yezgh5uSaxJL6qe+y9ntIUq7xcIneA2NcI0R8er+FdDC KGhRxtHgkUCxJ4cZWhhBsrhsEuD5f4Bw8+Gom+HFccLeHbXx9XYmAVhtKlExxmCzAscB 2Y2KPiUskBifCs4a2NEq4NOBGPhxaYX3IKzJGYFvmh/2Y1fHRe7Nrs3lkAokjRzcyxen izwfG2yMOQOXGwd1l2ZA5feAXZQjYNodyONmlKGqA4t1DzlWQHa/WFLhMKK4cn2GLK0g tC+E933mtUnlCJP+IsSvSGimml5T5MgTIDvks16UeYZGfoJtG+UbTzJZZVL+11nyexcf ExSQ== X-Gm-Message-State: ACrzQf2iwQmZjfyCZPDA7VnTTr5gHME9mo9+0kl3FovGbKzdAo91BPEH vp2mnnyFvVKh4NJQkcfBdfQ= X-Google-Smtp-Source: AMsMyM7Vj2AjQyvyKhRtMe8vXu7TydB/TkZA9adOlbNoCTe8ngz+PYSrepdelNs3gb3CXTEaymiBZA== X-Received: by 2002:a05:6a00:1950:b0:56e:1092:1272 with SMTP id s16-20020a056a00195000b0056e10921272mr1887560pfk.31.1668068069600; Thu, 10 Nov 2022 00:14:29 -0800 (PST) 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 c3-20020a17090a020300b00205d85cfb30sm2493791pjc.20.2022.11.10.00.14.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Nov 2022 00:14:29 -0800 (PST) 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:247491 Archived-At: > On Nov 9, 2022, at 10:44 PM, Wilhelm Kirschbaum = wrote: >=20 > 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: >=20 > (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))) >=20 > 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=E2=80=99s = 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?=20 Yes, instead of a regex you can pass a predicate function. >=20 > 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?=20 If you want to move in the same level, perhaps you can use = treesit-next/prev/sibling? Yuan=