all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Yuan Fu <casouri@gmail.com>
To: Wilhelm Kirschbaum <wilhelm@floatpays.co.za>
Cc: 58711@debbugs.gnu.org
Subject: bug#58711: Treesit hangs when calling treesit-search-forward
Date: Mon, 14 Nov 2022 00:44:59 -0800	[thread overview]
Message-ID: <7333D25E-DFC5-4720-867F-1FFFE3B0B12B@gmail.com> (raw)
In-Reply-To: <CAJbepr-q-9beiko_QmKLVjNmfP8+QepWwwAZJ3OyWqd3UNxE0g@mail.gmail.com>



> On Nov 13, 2022, at 10:32 PM, Wilhelm Kirschbaum <wilhelm@floatpays.co.za> wrote:
> 
> This works for me for all cases I managed to test:
> 
> ( I have to keep track of the EOL and BOL to ensure that we don't jump to parents or children. )
> 
> (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 = (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




  reply	other threads:[~2022-11-14  8:44 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-22  9:53 bug#58711: Treesit hangs when calling treesit-search-forward Wilhelm Kirschbaum
2022-10-22 10:26 ` bug#58711: The full tree-sitter parse output Wilhelm Kirschbaum
2022-10-23  6:42 ` bug#58711: Treesit hangs when calling treesit-search-forward Yuan Fu
2022-10-23 23:20   ` Yuan Fu
2022-10-24 17:06     ` Wilhelm Hugo Kirschbaum
2022-10-24 20:19       ` Yuan Fu
2022-11-10  6:44         ` Wilhelm Kirschbaum
2022-11-10  8:14           ` Yuan Fu
2022-11-10 19:03             ` Wilhelm Kirschbaum
2022-11-10 19:05               ` Wilhelm Kirschbaum
2022-11-10 19:32                 ` Wilhelm Kirschbaum
2022-11-10 20:43                   ` Wilhelm Kirschbaum
2022-11-10 22:07                     ` Yuan Fu
2022-11-11  6:30                       ` Wilhelm Kirschbaum
2022-11-14  6:32                         ` Wilhelm Kirschbaum
2022-11-14  8:44                           ` Yuan Fu [this message]
2022-11-14 10:03                             ` Wilhelm Kirschbaum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7333D25E-DFC5-4720-867F-1FFFE3B0B12B@gmail.com \
    --to=casouri@gmail.com \
    --cc=58711@debbugs.gnu.org \
    --cc=wilhelm@floatpays.co.za \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.