From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Konstantin Kharlamov Newsgroups: gmane.emacs.devel Subject: Re: tree-sitter: conceptional problem solvable at Emacs' level? Date: Sat, 11 Feb 2023 10:11:24 +0300 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> 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="31811"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.46.3 Cc: Holger Schurig To: Theodor Thornhill , 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 08:12:33 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 1pQk3l-00084h-5d for ged-emacs-devel@m.gmane-mx.org; Sat, 11 Feb 2023 08:12:33 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pQk2z-0003CN-4E; Sat, 11 Feb 2023 02:11:45 -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 1pQk2o-0003Bu-Vz for emacs-devel@gnu.org; Sat, 11 Feb 2023 02:11:41 -0500 Original-Received: from forward500b.mail.yandex.net ([178.154.239.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pQk2l-0002Fj-Pa; Sat, 11 Feb 2023 02:11:34 -0500 Original-Received: from iva5-344f444591f3.qloud-c.yandex.net (iva5-344f444591f3.qloud-c.yandex.net [IPv6:2a02:6b8:c0c:687:0:640:344f:4445]) by forward500b.mail.yandex.net (Yandex) with ESMTP id 5D3235EF55; Sat, 11 Feb 2023 10:11:25 +0300 (MSK) Original-Received: by iva5-344f444591f3.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id OBaxVMIYQiE1-UjGXIYwH; Sat, 11 Feb 2023 10:11:25 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1676099485; bh=rgLLC+gkyh+Q7oiIuQK9Apa70HFbsTyHhxrV5hNQ0uw=; h=References:Date:In-Reply-To:Cc:To:From:Subject:Message-ID; b=a7u8QIr+O0eTk1ETjnUoI8WgSSqvoNF7NRkoGmWUsSoloyII3Z4Q/nf+3NZjWEL5x +p7Btsd0KmdaayGF0E7unAWngyE7Hd17hhT5E9FecqAmVRSFy/AOz2ds9798sJCA/s ppwDcZ5syw4S1IhVxQRygMXjJzUZsCluWTtSLMMY= Authentication-Results: iva5-344f444591f3.qloud-c.yandex.net; dkim=pass header.i=@yandex.ru In-Reply-To: <0768E0D7-6D58-40AC-A1D4-784C27CE0D7F@thornhill.no> Received-SPF: pass client-ip=178.154.239.144; envelope-from=hi-angel@yandex.ru; helo=forward500b.mail.yandex.net 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, 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:303125 Archived-At: 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 support > > > > > developing C/C++ programs.=C2=A0 I believe some do. > > > >=20 > > > > I think most of those have similar problems supporting macros. > > > > Who knows their names? I may be able to ask some of their users. > > >=20 > > > From my experience on and off work, there are just two IDEs (as in, n= ot > > > editors) > > > used most widely for C++ code: QtCreator and Visual Studio. The first= you > > > discussed, the second is proprietary. > > >=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. These t= wo > > > have > > > don't use tree-sitter either. > >=20 > > I installed Sublime Text on my Archlinux and tested with the C++ code O= P > > posted. > >=20 > > What I see is that ST does seem confused about indentation, while tryin= g to > > make > > a newline right after `slots:` line. > >=20 > > However, if you try to make a newline after the `void someSlot() {};` l= ine, > > it > > will use the indentation used on the previous line. > >=20 > > The default cc-mode in Emacs works similarly. The cc-ts-mode on the oth= er > > hand > > doesn't make use of the previous indentation, and I think it should. It > > would > > resolve that problem and others, because in my experience it happens ve= ry > > often > > in C and C++ code that you want some custom indentation level, so you j= ust > > make > > one and you expect the editor to keep it while creating more new lines. > >=20 >=20 > That last statement sounds easily solvable. Can you send me a short examp= le > describing exactly what you want in a code snippet and I'll add it. >=20 > Thanks, > Theo Thank you! The example is below, but please wait a bit just to make sure th= ere's no opposition from other people, because I don't know if it works lik= e this on purpose, or not. Given this C++ code with weird class members indentation: class Foo { int a; bool b; }; Now, suppose you put a caret after `bool b;` text and press Enter to make a= new line (all tests are done with `emacs -Q`). The behaviour: * cc-mode and Sublime Text: creates a newline with the indentation exactly = as on the previous one. * cc-ts-mode: re-indents the `bool b;` line, then creates a new one with a custom indentation that is different from one on the `int a;` line. The cc-mode and Sublime Text behaviour seems like less annoying to me, beca= use if I wanted to reindent the prev. line, most likely I'd did it by pressing = an indentation hotkey (e.g. `=3D` in Evil mode I use).