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: Mon, 14 Nov 2022 00:44:59 -0800 Message-ID: <7333D25E-DFC5-4720-867F-1FFFE3B0B12B@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> <7B22DC5E-CCC6-4981-AC61-7774FE2846AA@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="21578"; 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 Tue Nov 15 01:58:04 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 1oukH6-0005SL-2d for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 15 Nov 2022 01:58:04 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ouiq3-0002xj-2N; Mon, 14 Nov 2022 18:26:03 -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 1ouigb-0004sJ-J5 for bug-gnu-emacs@gnu.org; Mon, 14 Nov 2022 18:16:20 -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 1ouV6Q-0001EH-DH for bug-gnu-emacs@gnu.org; Mon, 14 Nov 2022 03:46:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ouV6Q-0002uD-2R for bug-gnu-emacs@gnu.org; Mon, 14 Nov 2022 03:46: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: Mon, 14 Nov 2022 08:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58711 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 58711-submit@debbugs.gnu.org id=B58711.166841551411110 (code B ref 58711); Mon, 14 Nov 2022 08:46:02 +0000 Original-Received: (at 58711) by debbugs.gnu.org; 14 Nov 2022 08:45:14 +0000 Original-Received: from localhost ([127.0.0.1]:48875 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ouV5e-0002t7-4l for submit@debbugs.gnu.org; Mon, 14 Nov 2022 03:45:14 -0500 Original-Received: from mail-pg1-f177.google.com ([209.85.215.177]:37400) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ouV5Z-0002sm-J8 for 58711@debbugs.gnu.org; Mon, 14 Nov 2022 03:45:13 -0500 Original-Received: by mail-pg1-f177.google.com with SMTP id v3so9674468pgh.4 for <58711@debbugs.gnu.org>; Mon, 14 Nov 2022 00:45:09 -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=EoCPztDSYqbmtWv9A7rVJedxlhcab6MX3TSB+UBvz/M=; b=OS7r9KeHKwssQZNO3yQ+9GQpFBjvXo1jmOEQqRV0RLpEKQw0LgXrx3gB7o0/a4/6Wc UwW9Sj0Uqb5p3MlEZZ3LwunSxBXRe1726F04nqYTBZquSKDoeftK59S9GXBTaypU+VEx yqOMCoPjOPD61jqG9/V4EbaONxnVcRx8AwaIt3JHxDKMGgtZBdE/tTdybLqwwrrrPCRR 6SqzVr8jME+f5XIw/rRDhfLfnBjo025mgs2sX6qIpJvG6XniBZzyasIVlNrA63r2y+Df YGfLkiZh+wJyDJDu5Dsj89XOPCrRy+vJTPwQt02kzo0IR9RvdCXIZUHzl6GCy/RHChD4 ZBfA== 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=EoCPztDSYqbmtWv9A7rVJedxlhcab6MX3TSB+UBvz/M=; b=x6jW2sThd9pNVVHaB55hmc7nWmaYjIUzWfFs86UVXYaZaymrCG/13xeX77EKXvWdcQ vLzUYFrAhhqf2uHQPEDmWONs9VsYeAcqFrRa+lYInCLjLeTew8Y3fmJo3Zx2EH0Gl0fq 7SU4akmPgyiu+930F7XGvcYaZJ29GVejgtF3Acg5d4phCqiDg0vTYuWd/q7nQpP6VnzM RAER8HM2bIxFXlTRTz+ZxdR47uxnNJyf95aAyUKypZs2K920sJ0vNpwWXnICcYWurNQg dR2nPRBXr6O3/8Tl3xTqTPSdw+57RpZOYDEUmijw/G+QFO9WiRX9XTUOj8sLkBWLHL5r uipA== X-Gm-Message-State: ANoB5pkqZ1YJzj6pY9J1dpswzUBkL4p13jv/ThVXnFUKIAoHdSEoNpb9 yV5VY2O+qMas0Ihas27VWec= X-Google-Smtp-Source: AA0mqf76oXLo4Nr5D8xrZsdeHyIMxJhP+C5w4VUk0hotcZLhxW7nQ3Y2HiN8WhvBMMRSugzqq/vx7g== X-Received: by 2002:a63:d457:0:b0:476:837b:7a08 with SMTP id i23-20020a63d457000000b00476837b7a08mr3306371pgj.430.1668415503733; Mon, 14 Nov 2022 00:45:03 -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 y16-20020a17090322d000b00186f0f59c85sm6814212plg.235.2022.11.14.00.45.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Nov 2022 00:45:01 -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:247876 Archived-At: > On Nov 13, 2022, at 10:32 PM, Wilhelm Kirschbaum = wrote: >=20 > This works for me for all cases I managed to test: >=20 > ( I have to keep track of the EOL and BOL to ensure that we don't jump = to parents or children. ) >=20 > (defun heex--treesit-largest-node-at-point (&optional node) > "Find the largest node at point or from specified NODE." > (save-excursion > (forward-comment (point-max)) > (let ((node-list > (cl-loop for node =3D (or node (treesit-node-at (point))) > then (treesit-node-parent node) > while (and node (not (equal (treesit-node-type = node) "fragment"))) > if (eq (treesit-node-start node) > (point)) > collect node))) > (car (last node-list))))) For largest node at point, you can probably use something like (treesit-parent-while (or node (treesit-node-at (point))) (lambda (n) (eq (treesit-node-start n) (point)))) Yuan=