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: Fri, 4 Nov 2022 16:10:06 -0700


> 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.

> 
> 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. 

> 
> 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.

> @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.

[snip]

Yuan


reply via email to

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