From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: CC Mode -> Tree sitter challenge Date: Fri, 4 Nov 2022 16:10:06 -0700 Message-ID: <18BBE32B-6943-49B1-8C17-BD224633558C@gmail.com> References: <87v8nu1mt1.fsf@thornhill.no> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) 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="5148"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel , Eli Zaretskii , Stefan Monnier To: Theodor Thornhill Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Nov 05 00:11:34 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 1or5qY-0001AQ-Eq for ged-emacs-devel@m.gmane-mx.org; Sat, 05 Nov 2022 00:11:34 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1or5pH-00005u-A6; Fri, 04 Nov 2022 19:10:15 -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 1or5pG-000054-DO for emacs-devel@gnu.org; Fri, 04 Nov 2022 19:10:14 -0400 Original-Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1or5pD-0006BC-Iv; Fri, 04 Nov 2022 19:10:14 -0400 Original-Received: by mail-pl1-x62f.google.com with SMTP id d20so5135363plr.10; Fri, 04 Nov 2022 16:10:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=RU8fYsOhm9v33nrnCGfExSVP+pScPPlu3p1y4cnK7qY=; b=EjuY2X+NXcjB3v/tPOtK7vykkIvPMyiHgkUd7iv4lkPl1JvBsoPVurssBQGaehXLWH IfBZy4fwl+CiOP/Fu+4ECpKl9QSXWPO41DpkXRHnRm2kqdiyQ85j3yrjWGDqCmvyAdTQ yv6I8WIrnJN3Ei1Yw0jbSScE0xxspY8Xv5Tk4C+ZpNvlmfd4wtsKeNRA8dKJfwBSTxDK mtWHrIIM2qlubBfEaR79FrNdmunWyY1q+w/E0YKVR3saVYGlM7tcZa23Nr6UbhbG1Yg0 Ivb1KI4trdYmNxCcPyB6dCL9ZcWXtZCLe3XX365aE9RFAkpaMTRvNZdPq6OqIaw8ewR3 Nwdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RU8fYsOhm9v33nrnCGfExSVP+pScPPlu3p1y4cnK7qY=; b=LbXE5jAnvAo3ZlSl6wnq/+fpqDk8uuyjyw2FEyJzYMgkYHBp+vI9/npnRlp7B1CA5c yGecIg0K/9QnhsIdZO8U9QHnqMVdgmhf2NxmYpHOUhJjAjRyJ3oCoslyutwtEQQymt3T MDtJpN4hiZ+JcG6/teeyEwG7/25efogFNPt8yb7pso60u358FvvQPZpzENAyhTwsmzau gmQTHu6kzuwcqao4zyuebz8MYNKSrH9udUACP4A9Vu/xYRVKmqXscrRSr7EGVWbmLVsy EvVnITx3coIZP53dQ0lnN0n1A5g9A2f0hHCQOsR8jDSCRZxMHA63cEEq+tW+p9icU49R ltXQ== X-Gm-Message-State: ANoB5pl7ZrYAP3OUQRIPGTZ147MBl+NOu5HIF+xfoAEyYbsRvFbsq85c RnereZgAH0u4dGB09okZ20hP48D0y6Y= X-Google-Smtp-Source: AA0mqf4cRgz50mljUPJInfsvvomJMYfsKoaZwEOnkQcn1UmLKYK2cyKxwVnEsiQOGzHxL9ZNPUai8w== X-Received: by 2002:a17:902:a40a:b0:188:71b1:8f0f with SMTP id p10-20020a170902a40a00b0018871b18f0fmr582542plq.112.1667603408328; Fri, 04 Nov 2022 16:10:08 -0700 (PDT) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id k193-20020a6284ca000000b0056e8eb09d58sm139237pfd.170.2022.11.04.16.10.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Nov 2022 16:10:08 -0700 (PDT) In-Reply-To: <87v8nu1mt1.fsf@thornhill.no> X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=casouri@gmail.com; helo=mail-pl1-x62f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=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:299163 Archived-At: > On Nov 4, 2022, at 1:34 PM, Theodor Thornhill = wrote: >=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. I finally got some free hours, so here's > my first follow-up to your "show me the code". >=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. 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. >=20 > 2. I've focused mostly on indentation and font locking. Indentation = is > using xdisp code style and the gnu style in general. >=20 > 3. There's some support for navigation >=20 > 4. I'll make Imenu, which-func and other goodies later. I want it to = be > usable first. 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. >=20 > 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=E2=80=99t know cc-mode has white-space cleaning, I=E2=80=99ve = always used ws-butler.=20 >=20 > 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=E2=80=99ve 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=E2=80=99ll 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=E2=80=99s filling does a lot of invisible insertion and = edits in-place, and IIRC it caused problems with eglot before. [snip] Yuan=