all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Theodor Thornhill <theo@thornhill.no>
To: Yuan Fu <casouri@gmail.com>
Cc: emacs-devel@gnu.org, Eli Zaretskii <eliz@gnu.org>,
	monnier@iro.umontreal.ca
Subject: Re: CC Mode -> Tree sitter challenge
Date: Sun, 06 Nov 2022 07:04:47 +0100	[thread overview]
Message-ID: <C3493D84-6617-49D4-98DE-7AA6FB396A6B@thornhill.no> (raw)
In-Reply-To: <4E432374-A97A-48A0-A1C8-89C1DB47A7F8@gmail.com>



On 6 November 2022 02:13:14 CET, Yuan Fu <casouri@gmail.com> wrote:
>
>
>> On Nov 5, 2022, at 9:38 AM, Theodor Thornhill <theo@thornhill.no> wrote:
>> 
>> 
>> Hi again, Eli!
>> 
>>>> 
>>>> Interesting. My guess is that there are still some improvement possible in the indent-region code, considering that part of treesit.el is quite new.
>>>> 
>>>> What do you think, Yuan? Any thoughts?
>>>> 
>>>> Anyways, I'll keep working on this and see how far I get next coming weeks. At least in performance it seems I have a good thing going here :-)
>>>> 
>>> 
>>> Thinking of it, some of the indentation questions isn't compiled. I'll run it again later when they are compiled as well :-)
>>> 
>> 
>> Yes, that was the issue.  Now the scores are as follows:
>
>The indentation code has a list of rules, and it runs each rule top-to-bottom until one rules matches, then it uses that rule to determine how much to indent. The ordering of each rule could be tweaked so that most frequent case comes forward. We can also arrange these rules not linearly but in a tree, so if one rules matches/doesn’t match, some other rules can be skipped.

I think the system as it is now it fine, at least for the time being. But I hold no strong opinions there :)

>
>What exactly did you compile? I tried byte-compiling indentation rules before but didn’t see a significant speed-up.
>
>Yuan

See https://git.sr.ht/~theo/tree-sitter-modes/tree/master/item/c-ts-mode.el#L92

Sometimes when exploring indentation i use rules like this. Usually I try to find other ways after, but I just assumed they weren't perf problems. Apparently they are!

And by the way, i created an anchor like this: 
https://git.sr.ht/~theo/tree-sitter-modes/tree/master/item/c-ts-mode.el#L57

This is nice when you need to just move a token to col 0, such as preproc-directives. Maybe that should be a standard one? It could use the buffer-root-node, but this was so simple and fast that I just did it like that.

What do you think?

Theo



  reply	other threads:[~2022-11-06  6:04 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-04 20:34 CC Mode -> Tree sitter challenge Theodor Thornhill
2022-11-04 20:36 ` Theodor Thornhill
2022-11-04 20:38 ` Stefan Monnier
2022-11-04 20:44   ` Theodor Thornhill
2022-11-04 23:10 ` Yuan Fu
2022-11-05  7:56   ` Theodor Thornhill
2022-11-06  1:01     ` Yuan Fu
2022-11-06  5:54       ` Theodor Thornhill
2022-11-05  9:13 ` Eli Zaretskii
2022-11-05 13:12   ` Theodor Thornhill
2022-11-05 13:31     ` Eli Zaretskii
2022-11-05 13:42       ` Theodor Thornhill
2022-11-05 14:37       ` Theodor Thornhill
2022-11-05 14:55         ` Eli Zaretskii
2022-11-05 15:06           ` Theodor Thornhill
2022-11-05 15:27             ` Theodor Thornhill
2022-11-05 16:38               ` Theodor Thornhill
2022-11-05 16:43                 ` Eli Zaretskii
2022-11-06  1:13                 ` Yuan Fu
2022-11-06  6:04                   ` Theodor Thornhill [this message]
2022-11-07  0:11                     ` Yuan Fu
2022-11-07  8:05                       ` Theodor Thornhill
2022-11-05 14:34   ` Stefan Monnier
2022-11-05 14:46     ` Theodor Thornhill

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=C3493D84-6617-49D4-98DE-7AA6FB396A6B@thornhill.no \
    --to=theo@thornhill.no \
    --cc=casouri@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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.