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: conceptional problem solvable at Emacs' level? Date: Sat, 11 Feb 2023 09:41:40 +0100 Message-ID: References: <87zg9n45ig.fsf@yahoo.com> <0DDF6978-D75A-4137-9D93-6200908675B6@gmail.com> <837cwplxni.fsf@gnu.org> <83zg9lkagi.fsf@gnu.org> <87ttzt0wtv.fsf@yahoo.com> <357e68eacfb7931fae08704ebfcbe1178a08fd69.camel@yandex.ru> <0768E0D7-6D58-40AC-A1D4-784C27CE0D7F@thornhill.no> <1f06600f6fcffebff90234bf4875c89b747a8841.camel@yandex.ru> 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="6451"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Holger Schurig To: Konstantin Kharlamov , emacs-devel@gnu.org, Po Lu , Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Feb 11 09:42:28 2023 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 1pQlSl-0001Qt-AO for ged-emacs-devel@m.gmane-mx.org; Sat, 11 Feb 2023 09:42:27 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pQlSF-000850-AG; Sat, 11 Feb 2023 03:41:55 -0500 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 1pQlSD-00083w-TC for emacs-devel@gnu.org; Sat, 11 Feb 2023 03:41:53 -0500 Original-Received: from out-14.mta1.migadu.com ([95.215.58.14]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pQlSA-0007o3-SW for emacs-devel@gnu.org; Sat, 11 Feb 2023 03:41:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1676104907; 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=0rel56Ww3JEDumAn147AyQXlRapXr4U4sVjKpP6BiFY=; b=k5z9gKe+ERT9jbrgVX7Y0gpOahWUXy3f2+tk9cr4ztqGJxuBT4EghuuEBFmzNTY5lsG+cq uOBrpcv6bbuwMgiEzWnJ0MLS6FVFWJ+a8eW/vBUuEldsSROez6khrlTom15e0LAfDDHK2V sZKJgRsJn7noxHt0zDbK4Ld14FNebC4YkXgY39BtIxmjJX6QI9llITgX53JmkLBTW3A+2V 4ExzdkgDVnM5sONADGIH1PmsKEvCxYGzStIqfVVUChNqlGIGlIlNYKPtlhCGT3fumpqtxq LQ77VPO5/CRv3K7dPmNpRtRnXf+H0H1NA3dQ9VL/rpgtdACygmN/B8psNjWZGQ== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. In-Reply-To: <1f06600f6fcffebff90234bf4875c89b747a8841.camel@yandex.ru> X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=95.215.58.14; envelope-from=theo@thornhill.no; helo=out-14.mta1.migadu.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, 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: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:303129 Archived-At: On 11 February 2023 09:22:06 CET, Konstantin Kharlamov wrote: >On Sat, 2023-02-11 at 10:11 +0300, Konstantin Kharlamov wrote: >> On Sat, 2023-02-11 at 07:51 +0100, Theodor Thornhill wrote: >> >=20 >> >=20 >> > On 11 February 2023 07:36:26 CET, Konstantin Kharlamov >> > wrote: >> > > On Sat, 2023-02-11 at 09:25 +0300, Konstantin Kharlamov wrote: >> > > > On Sat, 2023-02-11 at 10:17 +0800, Po Lu wrote: >> > > > > Eli Zaretskii writes: >> > > > >=20 >> > > > > > However, I meant the IDEs which are using tree-sitter and sup= port >> > > > > > developing C/C++ programs=2E=C2=A0 I believe some do=2E >> > > > >=20 >> > > > > I think most of those have similar problems supporting macros= =2E >> > > > > Who knows their names? I may be able to ask some of their users= =2E >> > > >=20 >> > > > From my experience on and off work, there are just two IDEs (as i= n, not >> > > > editors) >> > > > used most widely for C++ code: QtCreator and Visual Studio=2E The= first >> > > > you >> > > > discussed, the second is proprietary=2E >> > > >=20 >> > > > Then again, people most often code in C++ and C with text editors= , in >> > > > that >> > > > case >> > > > popular choices from my experience: Sublime Text and VS Code=2E T= hese two >> > > > have >> > > > don't use tree-sitter either=2E >> > >=20 >> > > I installed Sublime Text on my Archlinux and tested with the C++ co= de OP >> > > posted=2E >> > >=20 >> > > What I see is that ST does seem confused about indentation, while t= rying >> > > to >> > > make >> > > a newline right after `slots:` line=2E >> > >=20 >> > > However, if you try to make a newline after the `void someSlot() {}= ;` >> > > line, >> > > it >> > > will use the indentation used on the previous line=2E >> > >=20 >> > > The default cc-mode in Emacs works similarly=2E The cc-ts-mode on t= he other >> > > hand >> > > doesn't make use of the previous indentation, and I think it should= =2E It >> > > would >> > > resolve that problem and others, because in my experience it happen= s very >> > > often >> > > in C and C++ code that you want some custom indentation level, so y= ou just >> > > make >> > > one and you expect the editor to keep it while creating more new li= nes=2E >> > >=20 >> >=20 >> > That last statement sounds easily solvable=2E Can you send me a short= example >> > describing exactly what you want in a code snippet and I'll add it=2E >> >=20 >> > Thanks, >> > Theo >>=20 >> Thank you! The example is below, but please wait a bit just to make sur= e >> there's no opposition from other people, because I don't know if it wor= ks like >> this on purpose, or not=2E >>=20 >> Given this C++ code with weird class members indentation: >>=20 >> =C2=A0=C2=A0=C2=A0 class Foo { >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 int a; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 bool b; >> =C2=A0=C2=A0=C2=A0 }; >>=20 >> Now, suppose you put a caret after `bool b;` text and press Enter to ma= ke a >> new >> line (all tests are done with `emacs -Q`)=2E The behaviour: >>=20 >> * cc-mode and Sublime Text: creates a newline with the indentation exac= tly as >> on >> the previous one=2E >> * cc-ts-mode: re-indents the `bool b;` line, then creates a new one wit= h a >> custom indentation that is different from one on the `int a;` line=2E >>=20 >> The cc-mode and Sublime Text behaviour seems like less annoying to me, = because >> if I wanted to reindent the prev=2E line, most likely I'd did it by pre= ssing an >> indentation hotkey (e=2Eg=2E `=3D` in Evil mode I use)=2E > >Oh, wait, though I mistakengly used c-mode instead of c++-mode=2E The c-m= ode works this way, it keeps prev=2E indentation, however c++-mode instead = uses a new indentation=2E It's odd they behave differently, and it certainl= y is different from other modes (e=2Eg=2E emacs-lisp-mode)=2E In this case = I think the question of whether it should re-use prev=2E line indentation, = which I think the should=2E C-mode or c-ts-mode? Yeah, this is what I'm thinking too=2E I'll look at it tonight or tomorrow= :) Theo