From: Wilhelm Kirschbaum <wilhelm@floatpays.co.za>
To: Yuan Fu <casouri@gmail.com>
Cc: 58711@debbugs.gnu.org
Subject: bug#58711: Treesit hangs when calling treesit-search-forward
Date: Fri, 11 Nov 2022 08:30:56 +0200 [thread overview]
Message-ID: <CAJbepr-SBuNO4mqwOsTiy91dvJ_sqycMzGqatgcj9v9G=3AjXg@mail.gmail.com> (raw)
In-Reply-To: <7B22DC5E-CCC6-4981-AC61-7774FE2846AA@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2083 bytes --]
Thank you. I will spend some time over the weekend to try and have a look.
On Fri, 11 Nov 2022 at 00:07, Yuan Fu <casouri@gmail.com> wrote:
>
>
> > On Nov 10, 2022, at 12:43 PM, Wilhelm Kirschbaum <
> wilhelm@floatpays.co.za> wrote:
> >
> > Given the following code
> >
> > <.foo> ;; component, start_component
> > <bar> ;; tag, start_tag
> > </bar>;; [cursor here 1)] end_tag
> > </.foo> ;; [cursor here 2] end_component
> >
> > and ast
> >
> > (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])))))
> >
> > I do not know how to reliably move from cursor position 1 to start of
> <bar> 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))))
>
> >
> > 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.
> >
> > 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.
> >
> > Hope this makes sense.
>
> Yeah, if there is a function that gives you the node right before point,
> treesit-search-forward would work as expected. I’ll see how to add this
> functionality.
>
> Yuan
[-- Attachment #2: Type: text/html, Size: 2781 bytes --]
next prev parent reply other threads:[~2022-11-11 6:30 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 [this message]
2022-11-14 6:32 ` Wilhelm Kirschbaum
2022-11-14 8:44 ` Yuan Fu
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='CAJbepr-SBuNO4mqwOsTiy91dvJ_sqycMzGqatgcj9v9G=3AjXg@mail.gmail.com' \
--to=wilhelm@floatpays.co.za \
--cc=58711@debbugs.gnu.org \
--cc=casouri@gmail.com \
/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.