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 14:07:40 -0800 Message-ID: <7B22DC5E-CCC6-4981-AC61-7774FE2846AA@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> <82A013FB-9A94-4E57-9FD2-AF8E892241A9@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="12437"; 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 23:08:18 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 1otFic-00033A-H8 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 10 Nov 2022 23:08:18 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otFiQ-0008WN-H8; Thu, 10 Nov 2022 17:08:06 -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 1otFiN-0008VO-Px for bug-gnu-emacs@gnu.org; Thu, 10 Nov 2022 17:08:03 -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 1otFiM-0007b9-Of for bug-gnu-emacs@gnu.org; Thu, 10 Nov 2022 17:08:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1otFiM-0005Iq-8q for bug-gnu-emacs@gnu.org; Thu, 10 Nov 2022 17:08: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 22:08: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.166811807220367 (code B ref 58711); Thu, 10 Nov 2022 22:08:02 +0000 Original-Received: (at 58711) by debbugs.gnu.org; 10 Nov 2022 22:07:52 +0000 Original-Received: from localhost ([127.0.0.1]:44569 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1otFiB-0005IR-OT for submit@debbugs.gnu.org; Thu, 10 Nov 2022 17:07:52 -0500 Original-Received: from mail-pj1-f48.google.com ([209.85.216.48]:43729) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1otFi8-0005ID-HS for 58711@debbugs.gnu.org; Thu, 10 Nov 2022 17:07:50 -0500 Original-Received: by mail-pj1-f48.google.com with SMTP id d13-20020a17090a3b0d00b00213519dfe4aso3104375pjc.2 for <58711@debbugs.gnu.org>; Thu, 10 Nov 2022 14:07:48 -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=WqQ7y9zw8KVyzW9vq+ehuTVMmcPt3decTX1QKNhQOgg=; b=f8sTU/LU2G16f3KoSHO/10QFsupkQkmeFDSvGlW7rLIq5lIjSP27kW9ZpU0+FuULld oKCmrATC9c84PGJNnsVxreOwxfnXXnGl6ljEJGJW4RWCWcEYWFRVONDGsaGyMXoSSWZc UGWyHIo1tNrQmBl6go26gEJilOF/3OFrD/5ngHtvY03r7PXQP6Bn7+N8Sf9ytRl2jnlC OlEufz6OTPmWIJQzStiavb7lf5sjjUog4+9iYBfOIZzzItm0RmmV4omU2tWSvietae9P e7WDQSKZp0MYkIFn9z+I8FMqt/S63UcWMwz0yE9GCqoaw6s43fBSvSDkfCfcLdys3BoR jLwQ== 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=WqQ7y9zw8KVyzW9vq+ehuTVMmcPt3decTX1QKNhQOgg=; b=bmfBEUmrq7KTHa4b+Nz/yRWEl7v4pzAq5SSqsM4ZDVNZO8EF0BJHQSvFBg2Sv1olCk dRy+/OY4V87kjWVDdMvI82kU3k41Qd4zTFlnBmMnU2q+d6dqNHf4TU3cC39mn/I3mQuS aplZxnPa1DZ+VBzRRP63f1fg74aD4E3pCl0tRTFl97iArjrpizsGS6QIQkl7SUcCSHet 4fHiCtVRrUzU/oCNjP/R4i1oDkQaflSQtLM+Jd+yDG/iGa5IvHQZF9+R1kYtjOczMFT5 3krq75mwy9C3s2AJP1xCYAOHyc3ZzNXXcALZTCKHF6s4VRBpaJRTbSOerB5r2TAYo1qf Ljtg== X-Gm-Message-State: ACrzQf3NlLH6HBz6/4VDF+ywTOv3a8hVec8PS6fpVA93GzN7aDqGzae1 oVa+skfAUu39IIN0cC1M4w8= X-Google-Smtp-Source: AMsMyM6o5kVr5JzCVQmNwJsm3dJNX1Og+6EbryOMvDld2Cz9RAYwGx61ZrKkTXNiKr1hwmvYhRnLTQ== X-Received: by 2002:a17:90a:f305:b0:214:150f:1d54 with SMTP id ca5-20020a17090af30500b00214150f1d54mr2225812pjb.219.1668118062324; Thu, 10 Nov 2022 14:07:42 -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 b4-20020a1709027e0400b00188a1ae94bbsm187098plm.23.2022.11.10.14.07.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Nov 2022 14:07:41 -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:247555 Archived-At: > On Nov 10, 2022, at 12:43 PM, Wilhelm Kirschbaum = wrote: >=20 > Given the following code >=20 > <.foo> ;; component, start_component > ;; tag, start_tag > ;; [cursor here 1)] end_tag=20 > ;; [cursor here 2] end_component >=20 > and ast >=20 > (fragment [0, 0] - [5, 0] > (component [0, 0] - [3, 7] > (start_component [0, 0] - [0, 6] > (component_name [0, 1] - [0, 5] > (function [0, 2] - [0, 5]))) > (tag [1, 2] - [2, 8] > (start_tag [1, 2] - [1, 7] > (tag_name [1, 3] - [1, 6])) > (end_tag [2, 2] - [2, 8] > (tag_name [2, 4] - [2, 7]))) > (end_component [3, 0] - [3, 7] > (component_name [3, 2] - [3, 6] > (function [3, 3] - [3, 6]))))) >=20 > I do not know how to reliably move from cursor position 1 to start of = and from cursor position 2 to start of <.foo> The snippet below should take you to the corresponding open tag. (let ((end-node (treesit-search-forward-goto (treesit-node-at (point)) (rx (or "end_tag" "end_component" "end_slot")) t t))) ;; Go to the corresponding start tag. (goto-char (treesit-node-start (treesit-node-parent end-node)))) >=20 > as (treesit-search-forward (treesit-node-at (point)) (rx (or "end_tag" = "end_component" "end_slot")) t) on position 1 will not look backwards, = but find the <./foo> end_component.=20 >=20 > if i am at the point after the node, how do I find the node before the = point? once we have the node before the point we can find the correct = parent and then find the prev sibling to goto.=20 >=20 > Hope this makes sense.=20 Yeah, if there is a function that gives you the node right before point, = treesit-search-forward would work as expected. I=E2=80=99ll see how to = add this functionality. Yuan=