emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CC Mode -> Tree sitter challenge


From: Yuan Fu
Subject: Re: CC Mode -> Tree sitter challenge
Date: Sat, 5 Nov 2022 18:01:13 -0700


> On Nov 5, 2022, at 12:56 AM, Theodor Thornhill <theo@thornhill.no> wrote:
> 
> 
> 
> 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 :)

Ahhh yes. I’ve change it to not indent empty lines.

Yuan


reply via email to

[Prev in Thread] Current Thread [Next in Thread]