From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Theodor Thornhill Newsgroups: gmane.emacs.devel Subject: Re: CC Mode -> Tree sitter challenge Date: Sat, 05 Nov 2022 08:56:52 +0100 Message-ID: References: <87v8nu1mt1.fsf@thornhill.no> <18BBE32B-6943-49B1-8C17-BD224633558C@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36975"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel , Eli Zaretskii , Stefan Monnier To: Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Nov 05 08:58:15 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1orE4E-0009Qq-OS for ged-emacs-devel@m.gmane-mx.org; Sat, 05 Nov 2022 08:58:14 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1orE3N-0003jq-1U; Sat, 05 Nov 2022 03:57:21 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1orE3K-0003jg-T6 for emacs-devel@gnu.org; Sat, 05 Nov 2022 03:57:18 -0400 Original-Received: from out0.migadu.com ([2001:41d0:2:267::]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1orE3G-0005g2-Om; Sat, 05 Nov 2022 03:57:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1667635031; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Pvt1JO8OKgYfFFwj9VCxPGnQkzykHwVKWAtRtueCw8M=; b=ZAjtmRdfbegTLfAnGzIlVtoRKC6wjb2QX9rfUUDKzwNO6AFOsEu9KfyEqMHEJhSlXp9jkQ jS3AlKYP30xbp4zXhNlZFz3vCYdy60UjEt/7NAIqCjkdCrGXQYTquq4HymdbaeOhFQ/wWq fKar2B52oupRy+C/5d90RlkVfGnQ5pwWC1nASqDzjs6npehVgaOiX7MO6Ic8Ot1xcgoA1D qftY9fpptYtQxfq0l6iojgAzTAkmQ2uVl+Xmic4/QfaphFpx3z358WsBx2ufErNw6Gvgnc 8sOwJ4pUqORWfB7y7xhLJznGPNS1UPDA437mFDv8TYLRkNw9oBnnm5QmxkD8ww== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. In-Reply-To: <18BBE32B-6943-49B1-8C17-BD224633558C@gmail.com> X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=2001:41d0:2:267::; envelope-from=theo@thornhill.no; helo=out0.migadu.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: "Emacs-devel" Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:299174 Archived-At: On 5 November 2022 00:10:06 CET, Yuan Fu wrote: > > >> On Nov 4, 2022, at 1:34 PM, Theodor Thornhill wro= te: >>=20 >>=20 >> Hi Eli and others! >>=20 >> So you challenged me to add some more modes that are supported in CC >> Mode, but not using CC Mode=2E I finally got some free hours, so here'= s >> my first follow-up to your "show me the code"=2E >>=20 >> In this repo[0] you will find support for the following modes: >>=20 >> - 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! > >>=20 >> So - some notes: >>=20 >> 1=2E 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=2E C++ in particular is a language I don't code in, and is >> notoriously complex=2E >>=20 >> 2=2E I've focused mostly on indentation and font locking=2E Indentatio= n is >> using xdisp code style and the gnu style in general=2E >>=20 >> 3=2E There's some support for navigation >>=20 >> 4=2E I'll make Imenu, which-func and other goodies later=2E I want it = to be >> usable first=2E > >I learnt this from Jo=C3=A3o: you don=E2=80=99t need to write a dedicated= which-func function, it by default uses data from Imenu=2E > Nice! I'll check it out=2E >>=20 >> 5=2E Most other CC mode features such as electric-foo and whitespace >> cleanup should be possible to do with constructs outside of cc mode=2E > >Didn=E2=80=99t know cc-mode has white-space cleaning, I=E2=80=99ve always= used ws-butler=2E=20 > It has some hungry delete and similar stuff >>=20 >> When scrolling through xdisp with this variant of C support it is >> noticeably faster on my system=2E However, I'd like some guidance on h= ow >> to provide some benchmarks to prove my guess=2E Loading said file and >> immediately going to EOB is instant, but in CC Mode takes a little less >> than a second=2E > >I=E2=80=99ve done benchmarks, and tree-sitter is indeed much faster, you = can probably find them in the archive=2E Speaking of archive, how does you = guys find old messages in the archive? The search feature on the official a= rchive webpage is unusable=2E > Yeah, i tried too, hehe=2E >> @Stefan, you mentioned that filling could be extracted from cc >> mode=2E Could you point me either to what/where to look for/at, so that= I >> can make such an attempt? > >I=E2=80=99ll add that it might be a good idea to take out the whole comme= nt, insert them into a temp buffer, fill it with c-fill-paragraph or whatev= er, then go back and replace the whole comment in the original buffer=2E Cc= -mode=E2=80=99s filling does a lot of invisible insertion and edits in-plac= e, and IIRC it caused problems with eglot before=2E > Yeah, i was hoping that tree-sitter could do that, but I only tried briefl= y=2E Seems most of the (comment) nodes contain the comment prefix along wit= h the commented text=2E Would be nice to access the text without comment pr= efix, but I guess we can code or way out of that=2E 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