From: Juri Linkov <juri@linkov.net>
To: Yuan Fu <casouri@gmail.com>
Cc: 68824@debbugs.gnu.org
Subject: bug#68824: treesitter support for outline-minor-mode
Date: Thu, 01 Feb 2024 19:12:17 +0200 [thread overview]
Message-ID: <868r44ryzb.fsf@mail.linkov.net> (raw)
In-Reply-To: <86y1c6q7oh.fsf@mail.linkov.net> (Juri Linkov's message of "Wed, 31 Jan 2024 09:32:46 +0200")
Yuan, do you think it makes sense to add a new optional arg to
'treesit-search-forward' that will define the traversal order?
The problem is that to search the next outline heading in
outline-minor-mode, there is a need to visit headings in
the same order as they appear in the buffer
where a parent is located before its children:
* Parent
** Child 1
** Child 2
Currently 'treesit-search-forward' returns "Child 1" before "Parent".
This means that 'treesit-search-forward' should return the
topmost matched parent instead of starting to traverse children
from the deepest leaf.
IOW, it's necessary to traverse nodes in this order:
o
|
о---------------------11
| |
o--------S----------3 12
| | |
o--o-+--o 1--+--2 4--+-----7
| | | |
o o +-+-+ +--+--+
| | | | |
5 6 8 9 10
Please note there is no 11 or 12 at the parent of S node because
it should traverse only the remaining siblings of the parent.
This is because remaining parent siblings have treesit-node-start
positions greater than treesit-node-start of S node.
> +(defun treesit-outline-search (&optional bound move backward looking-at)
> + (let* ((current (treesit-node-at (pos-bol)))
> + (current (or (treesit-parent-until current treesit-outline-predicate)
> + current))
> + (node (treesit-search-forward
> + current treesit-outline-predicate backward))
next prev parent reply other threads:[~2024-02-01 17:12 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-30 17:37 bug#68824: treesitter support for outline-minor-mode Juri Linkov
2024-01-30 18:46 ` john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-31 7:20 ` Juri Linkov
2024-01-30 19:21 ` Eli Zaretskii
2024-01-31 7:32 ` Juri Linkov
2024-02-01 17:12 ` Juri Linkov [this message]
2024-02-02 0:34 ` Yuan Fu
2024-02-02 7:05 ` Eli Zaretskii
2024-02-02 7:27 ` Yuan Fu
2024-02-02 7:34 ` Eli Zaretskii
2024-02-02 7:53 ` Juri Linkov
2024-02-04 17:15 ` Juri Linkov
2024-02-05 4:34 ` Yuan Fu
2024-02-05 7:22 ` Juri Linkov
2024-02-06 7:21 ` Yuan Fu
2024-02-08 7:40 ` Juri Linkov
2024-02-08 8:30 ` Eli Zaretskii
2024-02-08 17:20 ` Juri Linkov
2024-02-08 18:56 ` Eli Zaretskii
2024-02-09 7:07 ` Juri Linkov
2024-02-09 19:25 ` Eli Zaretskii
2024-02-10 17:29 ` Juri Linkov
2024-02-10 17:57 ` Eli Zaretskii
2024-02-11 17:34 ` Juri Linkov
2024-02-11 19:22 ` Eli Zaretskii
2024-02-12 1:07 ` Yuan Fu
2024-02-12 12:59 ` Eli Zaretskii
2024-02-12 18:16 ` Juri Linkov
2024-02-13 17:02 ` Juri Linkov
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=868r44ryzb.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=68824@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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).