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: CC Mode -> Tree sitter challenge Date: Fri, 04 Nov 2022 21:34:18 +0100 Message-ID: <87v8nu1mt1.fsf@thornhill.no> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8351"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , casouri@gmail.com, Stefan Monnier To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Nov 04 21:34:52 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 1or3Ot-0001rc-2j for ged-emacs-devel@m.gmane-mx.org; Fri, 04 Nov 2022 21:34:51 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1or3OY-0001VY-Cr; Fri, 04 Nov 2022 16:34:30 -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 1or3OW-0001UQ-RX for emacs-devel@gnu.org; Fri, 04 Nov 2022 16:34:28 -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 1or3OU-0002Xe-47; Fri, 04 Nov 2022 16:34:28 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1667594061; 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; bh=JrIPS39qTjhoVDdqXKPkbjNBugC9tNvzBCYO0y541NU=; b=T5KrPzlvdpuiSt2fdUWQRMZNGL8rMrZ5LidNpgxGfs/ftFNruT4p2jVi2E9qRh91SLhJJ+ FOdJSdL5qnsiPjVL5vQErsMFUmCVWsnhovKSNQIUL0eR0hRWoNqcW/axOSciVrVRFfbE9H bBpglt5hvubNCErPIEx1V5QxVACVPjklobV2vju8MJJSH2Gv70WEaYnC2A0HDrts0gksgy tn4QWktLZhjmYlSj6iDoLtvKd10wCxcNn74lxXb11wCAnqiqEk7dfUlu5CZyJR+1y4hYzV an7KyCVoC8QZr3w9SuD6XH0OFwxpDywULvc7E7ccJ2xV9gzp1Jp88mvW6IP8oA== 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:299151 Archived-At: 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) 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. 5. Most other CC mode features such as electric-foo and whitespace cleanup should be possible to do with constructs outside of cc mode. 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. @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? Please don't dismiss this with arguments such as "it's a fruit salad", "there's no indentation styles" and other arguments. These are things that can be adjusted as we move forward. I have a plan for indentation styles, but haven't made my initial suggestion there. If anyone on this list could try some of these I would be eternally grateful, please add suggestions and/or bug reports either here on this list or at the issue tracker[1]. I'll keep on pushing commits unless some of you say this is a non-starter. -- Theo [0]: https://git.sr.ht/~theo/tree-sitter-modes [1]: https://todo.sr.ht/~theo/tree-sitter