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: Tree-sitter indentation for js-mode & cc-mode Date: Thu, 27 Oct 2022 20:36:28 +0200 Message-ID: <541CF451-6FAC-4531-A8AF-8C86FBB9D40B@thornhill.no> References: <9AF8BFDC-C9A2-4AE5-A8D2-E6AA05DA3C91@gmail.com> <87k04lljh6.fsf@thornhill.no> 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="29986"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel , Stefan Monnier To: Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Oct 27 21:26:26 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 1oo8W1-0006kp-BS for ged-emacs-devel@m.gmane-mx.org; Thu, 27 Oct 2022 21:26:09 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oo7nI-0002ao-Lc; Thu, 27 Oct 2022 14:39:56 -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 1oo7kP-0001Rh-JA for emacs-devel@gnu.org; Thu, 27 Oct 2022 14:36:57 -0400 Original-Received: from out0.migadu.com ([94.23.1.103]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oo7kL-0003Mm-DW for emacs-devel@gnu.org; Thu, 27 Oct 2022 14:36:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1666895808; 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=hoHzetwToY7vrY0zltwkGHxuCpt5zYQkgwK0YoXShVU=; b=TXAeXgTBuVSi+BtkxOCi7FSXGOmbWvieVfWHoQDg+xAEUg+qw9w3J4gwIio0icploZ/e/N zyn2sLE1jOlLCHWuoMxeu6lkmRaiFnIjwkwbqeqCJsPNjaMPkwTdDCL6Ra2UQpebvKK6po 20TJv4dyo48s6TOdS+67oPvurCSL5+LYXegTF6EMl1opuqbXcDkdWSQKUkPqhxPk5c8AmK RR80KQbgN/z2ku8pOeVteIk6iYEAP6wshqkOrLEtq7/1BvO3SQME3cO/AzhocGdQHjaGyS Wbw/kjry8tdh8k9wSxv4cnsMiBDgS35m7LQSiOURumawqNeFktXzdDBEXwAp5Q== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. In-Reply-To: X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=94.23.1.103; 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:298638 Archived-At: >> This is cool, but do we really want/need this? I mean, now we're reall= y >> binding these implementations together and allowing all the legacy of C= C >> mode to blend in=2E We also need knowledge of how CC mode names their >> syntactic definitions=2E IMO one of the big selling points of tree sit= ter >> is that you can look at other editors implementation and get inspired >> immediately=2E Now we need deep knowledge of cc mode, don't we? Also, >> why would we want cc mode to calculate this for us? I see what you're >> trying to do, but _I_ think this is a step in the wrong direction=2E > >You have a point=2E I tried to blend in cc-mode because that=E2=80=99ll a= llow us support =E2=80=9Cstyles=E2=80=9D and existing user customization=2E= (Also I started out thinking it will be easier to write indentation rules = this way which turns out to be not true=2E) Perhaps it=E2=80=99s better to = come up with a new system for customizing indentation style=2E I=E2=80=99ll= revert this change=2E I think we can do something similar to the font lock features, can't we?= =20 >>=20 >> But the new one renders it like this: >> ``` >> const fooClient =3D new Foo({ >> bucket: process=2Eenv=2Efoo, >> region: process=2Eenv=2Efoo, >> }); >> ``` >>=20 >> I know this is a matter of tweaking, but it immediately makes me >> question the reasoning to blend them=2E > >It=E2=80=99s largely my slip-up rather than inherit defect of the system,= but I agree with your opinion above=2E Yes, absolutely=2E My intention was just to make the point with confusion = in mixing semantics etc=2E By the way - I think adding more helpers and anc= hors like you've done is nice, so don't just revert blindly, unless you hav= e to :-)=20 >> looking up way to much the root of the tree, but you know the internals >> here better than me=2E Is this something we can optimize away? See the >> attached report at the bottom=2E > >This is very strange, I need to look into it=2E > I'm happy to provide more info and profiling, as well as testing if need b= e!=20 >>=20 >> centralized variable to get most, if not all of the "auto-enabling" >> benefits by just lifting it up: >>=20 >> ``` >> ;;=2E=2E=2E=2E >>=20 >> (cond >> ;; Tree-sitter=2E >> ((treesit-ready-p 'js-mode 'javascript) >> ;; init all treesitter relevant stuff - can add in _some_ other >> ;; non-cc-mode settinigs, such as comment-start, etc above this=2E >> ;; We don't need the cache, detection of js-jsx or any of the >> ;; before-change-functions >>=20 >> (treesit-major-mode-setup)) >> ;; Elisp=2E >> (t >> ;; enable in normal cc mode stuff >> ))) >>=20 >> ``` >>=20 >> This way other hypothetical tree-sitter-v2 in the future is just a >> simple cond, and no need to worry=2E >>=20 >> If I'm missing something important here, please let me know, but I >> _really_ don't understand the reason for merging these implementations= =2E > >I don=E2=80=99t have an educated opinion on this=2E If no one has objecti= ons I=E2=80=99ll follow your professional advice ;-) > Hah - no professionalism here, but I've spent quite some time in the cc mo= de machinery=2E=20 >> Anyway, thanks for your continued hard work! > >Many thanks to you, too! > > My pleasure!=20 Theo