unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Theodor Thornhill <theo@thornhill.no>
To: Yuan Fu <casouri@gmail.com>
Cc: emacs-devel <emacs-devel@gnu.org>, Eli Zaretskii <eliz@gnu.org>,
	Stefan Monnier <monnier@iro.umontreal.ca>
Subject: Re: CC Mode -> Tree sitter challenge
Date: Sat, 05 Nov 2022 08:56:52 +0100	[thread overview]
Message-ID: <ACA18D80-EFF7-4BD7-B407-5191F3DB1AC6@thornhill.no> (raw)
In-Reply-To: <18BBE32B-6943-49B1-8C17-BD224633558C@gmail.com>



On 5 November 2022 00:10:06 CET, Yuan Fu <casouri@gmail.com> wrote:
>
>
>> On Nov 4, 2022, at 1:34 PM, Theodor Thornhill <theo@thornhill.no> wrote:
>> 
>> 
>> Hi Eli and others!
>> 
>> So you challenged me to add some more modes that are supported in CC
>> Mode, but not using CC Mode.  I finally got some free hours, so here's
>> my first follow-up to your "show me the code".
>> 
>> In this repo[0] you will find support for the following modes:
>> 
>> - javascript  (this is already in tree-sitter branch - but adding
>>  without cc mode here)
>> - c
>> - c++
>> - java
>> - css
>> - JSON
>> - TypeScript (left out, as it is in tree-sitter branch already)
>
>Cool!
>
>> 
>> So - some notes:
>> 
>> 1. This is still very early, but I wanted to put it out there so that
>> others more knowledgeable than me could chime in on some of the
>> languages. C++ in particular is a language I don't code in, and is
>> notoriously complex.
>> 
>> 2. I've focused mostly on indentation and font locking.  Indentation is
>> using xdisp code style and the gnu style in general.
>> 
>> 3. There's some support for navigation
>> 
>> 4. I'll make Imenu, which-func and other goodies later.  I want it to be
>> usable first.
>
>I learnt this from João: you don’t need to write a dedicated which-func function, it by default uses data from Imenu.
>

Nice! I'll check it out.
>> 
>> 5. Most other CC mode features such as electric-foo and whitespace
>> cleanup should be possible to do with constructs outside of cc mode.
>
>Didn’t know cc-mode has white-space cleaning, I’ve always used ws-butler. 
>

It has some hungry delete and similar stuff

>> 
>> When scrolling through xdisp with this variant of C support it is
>> noticeably faster on my system.  However, I'd like some guidance on how
>> to provide some benchmarks to prove my guess.  Loading said file and
>> immediately going to EOB is instant, but in CC Mode takes a little less
>> than a second.
>
>I’ve done benchmarks, and tree-sitter is indeed much faster, you can probably find them in the archive. Speaking of archive, how does you guys find old messages in the archive? The search feature on the official archive webpage is unusable.
>

Yeah, i tried too, hehe.

>> @Stefan, you mentioned that filling could be extracted from cc
>> mode. Could you point me either to what/where to look for/at, so that I
>> can make such an attempt?
>
>I’ll add that it might be a good idea to take out the whole comment, insert them into a temp buffer, fill it with c-fill-paragraph or whatever, then go back and replace the whole comment in the original buffer. Cc-mode’s filling does a lot of invisible insertion and edits in-place, and IIRC it caused problems with eglot before.
>

Yeah, i was hoping that tree-sitter could do that, but I only tried briefly. Seems most of the (comment) nodes contain the comment prefix along with the commented text. Would be nice to access the text without comment prefix, but I guess we can code or way out of that.



Btw, Yuan - could you tweak indent-region to that it doesn't insert spaces in empty lines? It creates a lot of whitespace changes now :)

Theo



  reply	other threads:[~2022-11-05  7:56 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 [this message]
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
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

  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=ACA18D80-EFF7-4BD7-B407-5191F3DB1AC6@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 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).