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: Sat, 5 Nov 2022 18:01:13 -0700 Message-ID: References: <87v8nu1mt1.fsf@thornhill.no> <18BBE32B-6943-49B1-8C17-BD224633558C@gmail.com> 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="13610"; 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 Sun Nov 06 02:02:13 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 1orU3B-0003L5-Hy for ged-emacs-devel@m.gmane-mx.org; Sun, 06 Nov 2022 02:02:13 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1orU2N-0001oX-5F; Sat, 05 Nov 2022 21:01:23 -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 1orU2L-0001nh-PK for emacs-devel@gnu.org; Sat, 05 Nov 2022 21:01:21 -0400 Original-Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1orU2J-00018a-Rj; Sat, 05 Nov 2022 21:01:21 -0400 Original-Received: by mail-pf1-x436.google.com with SMTP id k22so7651207pfd.3; Sat, 05 Nov 2022 18:01:17 -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=D1zmUH5c2oDWEY98q3a9FcuoKWHCBi0CuxhOPSF/Nn4=; b=feZH5BrBcQRCwk5+zZL7EgHW+88G19WUrlT9yXDJgKBsM98fnee/h74FE1NrNdQzal 3cDZIISRKC4B9Pn5ffqP00d0+VsHWH5r82xq1ASYtbihyot10TyqaWvjbiWfylLnl4A5 kcJAsfpqK11M5HsASgHxQDHF7M5g+2+dDK8qN6tQ2+Bod49ZBGASejqNNX50O8g0Dazu p/PgeT9FTLEcRxh28g8cTKCKfeCV4WbiKgnzx9csrrIUzKURLwSjaZxLbvWicKj+Ko8v +y9tsxIs76ajlECULScu7jbFeGOcWuQGr5PWBoy+DBOvnwQtV51MA3lRn5svqKVo61a6 I9Ng== 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=D1zmUH5c2oDWEY98q3a9FcuoKWHCBi0CuxhOPSF/Nn4=; b=DX9n299QEVrEB54/weldvmmZZ1nJMmLyZaVSCMDy4lbd0LCmcU5hT+LA8YC8gS5mdC M8dQWP3ZvsNO1Cpzmph91W8fs7bnsfKyPDQ93Bdhpqxvi1lbdnFkEzbBdZgU8oFpFoxD fBjHdrShCDZfEWh+ankj1YvFLA0BvanP1JW7TdabI4ccPgVEUBzch4yxsDZgOXP72bcA O9bq3psAW/289hHJDC13FjmKkys+OzqX+1TwgI2SjW4vpOVWJ/WIvQoo4MqTbeDf4Ncg w2PyLseKR0k0QnvJLucxRbPOWeIdwSZf3Mnwv1Rp1Z6oN+F50EK/1IjMJN/eu7wYyOO6 ATJg== X-Gm-Message-State: ACrzQf2ovmSaQoH6bh9PeFk22EhPRLwRsE3htKlTVpiasf3koSTHhiux 844BvFtlcsTX2YVO534FYoA= X-Google-Smtp-Source: AMsMyM74oLRuqzszoHsxPmE53HzRsu/vVDcajbSyCEHRawIbW3lJKYsvR2e4aHCBDOZbOOxDALLV2Q== X-Received: by 2002:a05:6a00:1884:b0:56c:636a:d554 with SMTP id x4-20020a056a00188400b0056c636ad554mr42987366pfh.18.1667696476233; Sat, 05 Nov 2022 18:01:16 -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 i13-20020a170902c94d00b00172e19c5f8bsm2241881pla.168.2022.11.05.18.01.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 05 Nov 2022 18:01:15 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=casouri@gmail.com; helo=mail-pf1-x436.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:299235 Archived-At: > On Nov 5, 2022, at 12:56 AM, Theodor Thornhill = wrote: >=20 >=20 >=20 > On 5 November 2022 00:10:06 CET, Yuan Fu wrote: >>=20 >>=20 >>> 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) >>=20 >> Cool! >>=20 >>>=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. >>=20 >> 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 >=20 > Nice! I'll check it out. >>>=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. >>=20 >> Didn=E2=80=99t know cc-mode has white-space cleaning, I=E2=80=99ve = always used ws-butler.=20 >>=20 >=20 > It has some hungry delete and similar stuff >=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. >>=20 >> 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. >>=20 >=20 > Yeah, i tried too, hehe. >=20 >>> @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? >>=20 >> 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. >>=20 >=20 > 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. >=20 >=20 >=20 > 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=E2=80=99ve change it to not indent empty lines. Yuan=