From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: CC Mode -> Tree sitter challenge Date: Sat, 05 Nov 2022 11:13:52 +0200 Message-ID: <83eduh4vcf.fsf@gnu.org> References: <87v8nu1mt1.fsf@thornhill.no> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31121"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca To: Theodor Thornhill Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Nov 05 10:14:53 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 1orFGO-0007sa-LE for ged-emacs-devel@m.gmane-mx.org; Sat, 05 Nov 2022 10:14:52 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1orFFV-0007t5-Ob; Sat, 05 Nov 2022 05:13:57 -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 1orFFU-0007sy-Mi for emacs-devel@gnu.org; Sat, 05 Nov 2022 05:13:56 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1orFFT-0008Nr-Nu; Sat, 05 Nov 2022 05:13:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=b+U6yYgaCjl9Pv3XDckro9X8kWBxlV0e4EIJs8dUo18=; b=BhaEEt54rYvA cNpVUrzqqbpBnfkSedOHc47BDs6w5Ke7ygC48WapWn3wsgkbBxYGqrvaZPrRm972xcpR1iB5vGnqF 7Jn+fdeWU10GuB/r/Byw7degB+50vqZeCST7rMMb3InLfVoQ2h9gn7a/a8Uj9OXkH1pwWOauHays/ +vU5RW0cqOXhKvbc0bwrHKcRbf43BKmMCIyEsPJU3vEwXaYV6i0QVN5yBXqkFnaiERrI/1ZhAMbQc My09mF8yM9+oBgwD/f852j84sGlQmtvHxAvAo0Skyq5/3ESWJXvNAqf704xbwnC7AttVPbgxNeu4d rRasJQ+V9IgYlIDY/adVbw==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1orFFS-0004JV-RM; Sat, 05 Nov 2022 05:13:55 -0400 In-Reply-To: <87v8nu1mt1.fsf@thornhill.no> (message from Theodor Thornhill on Fri, 04 Nov 2022 21:34:18 +0100) 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:299176 Archived-At: > From: Theodor Thornhill > Cc: Eli Zaretskii , casouri@gmail.com, Stefan Monnier > > Date: Fri, 04 Nov 2022 21:34:18 +0100 > > > 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) Thanks. > 2. I've focused mostly on indentation and font locking. Indentation is > using xdisp code style and the gnu style in general. We should ideally support all the indentation styles supported by 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. We usually use something like the below: (defun scroll-up-benchmark () (interactive) (let ((oldgc gcs-done) (oldtime (float-time))) (condition-case nil (while t (scroll-up) (redisplay)) (error (message "GCs: %d Elapsed time: %f seconds" (- gcs-done oldgc) (- (float-time) oldtime)))))) (defun scroll-up-by-40-benchmark () (interactive) (let ((oldgc gcs-done) (oldtime (float-time))) (condition-case nil (while t (scroll-up 40) (redisplay)) (error (message "GCs: %d Elapsed time: %f seconds" (- gcs-done oldgc) (- (float-time) oldtime)))))) The instructions are: visit xdisp.c and immediately invoke one of these two functions; then record the time it took to scroll through the entire file. Compare to CC Mode. I think we also want to see the above modified to make some change to the buffer once in a while. For example, once in 100 lines insert a quote ", or a /* followed by */ after several lines, and see how that affects the scroll times with both modes. > Loading said file and immediately going to EOB is instant, but in CC > Mode takes a little less than a second. Timing this with benchmark-run and presenting the numbers is also interesting.