From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Daniel_Mart=C3=ADn?= Newsgroups: gmane.emacs.devel Subject: Re: treesit indentation "blinking" Date: Sat, 08 Apr 2023 20:59:03 +0200 Message-ID: References: <83bkka5z7w.fsf@gnu.org> <871ql6a4d4.fsf@gmail.com> <83jzyy4776.fsf@gnu.org> <9F152CAA-6326-459F-84FF-87988B3A92B6@gmail.com> <6bf0322b-1151-129a-e26f-61cf4f232d17@yandex.ru> <6efb9f84-211d-560e-3196-95d7f0b8be19@yandex.ru> <1874921e1d0.2829.cc5b3318d7e9908e2c46732289705cb0@dancol.org> 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="11437"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (darwin) Cc: Daniel Colascione , Dmitry Gutov , Alan Mackenzie , =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= , Yuan Fu , Eli Zaretskii , theodor thornhill , geza.herman@gmail.com, emacs-devel@gnu.org To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Apr 08 20:59:53 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 1plDmz-0002lI-Iq for ged-emacs-devel@m.gmane-mx.org; Sat, 08 Apr 2023 20:59:53 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1plDmM-00066F-Lc; Sat, 08 Apr 2023 14:59:14 -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 1plDmK-00065j-N7 for emacs-devel@gnu.org; Sat, 08 Apr 2023 14:59:12 -0400 Original-Received: from sonic313-21.consmr.mail.ir2.yahoo.com ([77.238.179.188]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1plDmI-0008K8-4a for emacs-devel@gnu.org; Sat, 08 Apr 2023 14:59:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.es; s=s2048; t=1680980347; bh=FT+QxdntvDoL5EP4o6iJOgnmaarWQKuFS1wDIe7Jd1s=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject:Reply-To; b=QeeB+hTH1f1OjK1RRXDpzBv/Up+hggosxntUQGRgHPGEPQ/r3oTgiKTHUwW73rUXCWPC4eyBXP0ZqGLJiCECGQEtsjDlSIZb82yx7wneVXUdPYttUdI4uHIQgsOaMyqGGAaxsXsDGiGTIMmRMUgLiT10lsMhJdXHje8fYY4nXM6Pgth/i+1LRciWMUN77lHWZtcAzCpV+hcI8LiZw9JWu4kz4FKCnP+wtNcvlZtT5752ri1X5I0HDlinZ0eEkZFV7OWSTEZjReIl2D2s8LMV6jGL6yM3sHLBJH/KgVlUs+npG+19IDQqxPXavxEotXQHZ9WfFKibTAAAsNcvDbtIOg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1680980347; bh=MkHedXcQY1lHC7SVY2CAhVzhBtB6m/DFwKXvsjA4vAT=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=S21SPD8WTmUiziMQkomvsbDWQNEGzyMPbbrZn55MYWw1zkRGlAhoUk8TdE+ZbBddYSwYPX4NkJZkmVpTmj2fofviyzhtUDJLA5q8MuBNR0uKAIA29ThNKQrmKrcslfGfeoz+V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Rz X-Sonic-MF: X-Sonic-ID: 8181888e-9b59-46cf-8331-6e47f740e78a Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic313.consmr.mail.ir2.yahoo.com with HTTP; Sat, 8 Apr 2023 18:59:07 +0000 Original-Received: by hermes--production-ir2-74cd8fc864-ggn56 (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 633e7fc940ba3b600af32d4485ad925b; Sat, 08 Apr 2023 18:59:04 +0000 (UTC) In-Reply-To: (Dmitry Gutov's message of "Sat, 8 Apr 2023 04:32:13 +0300") X-Mailer: WebService/1.1.21365 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Received-SPF: pass client-ip=77.238.179.188; envelope-from=mardani29@yahoo.es; helo=sonic313-21.consmr.mail.ir2.yahoo.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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:305191 Archived-At: Dmitry Gutov writes: > On 07/04/2023 17:20, Daniel Mart=C3=ADn wrote: >> In general, I'd suggest taking a look at Neovim's Tree-sitter >> implementation and perhaps reuse (part of) their .scm Tree-sitter syntax >> highlight or indentation queries: >> https://github.com/nvim-treesitter/nvim-treesitter/tree/master/queries/c >> Neovim's implementation doesn't "blink" in the scenarios presented here, >> but I'm not sure about how it performs in other tricky cases. > > Looking at that file, it does contain queries that look for ERROR > nodes, e.g. > > ( > ERROR > "for" "(" @indent.begin ";" ";" ")" @indent.end) > > So perhaps we should revisit that approach too. > >> Now that text editors have access to the same programming language >> grammars, I'm surprised the Tree-sitter community hasn't started any >> cross-team effort to work on canonical queries (or slighter richer >> abstractions) per programming language. Text editor developers are >> working and rediscovering complex language problems independently. > > We could do an indent implementation that just uses these indents.scm > files. Not exactly sure why we didn't start out this way, but note > that our Lisp based solution is a lot more flexible. > > E.g. there doesn't seem to be an obvious way to support "indentation > styles" with these. I think it may be possible to have different query files, say, "GNU.scm", "K&R.scm", "C.scm" and add to the beginning of "GNU.scm" a Lisp comment like "; import C.scm". We would need to do manual parsing of the .scm files, though. Another question is how flexible this mechanism is. If I change something in an .scm file, would I need to restart Emacs to see the results? We could turn the .scm files into proper data Emacs Lisp files that could be evaluated on the fly, I don't know how over-engineered that'd be. Also, I don't know if we could even satisfy advanced CC mode users who are used to modify their style by just invoking C-c C-o on the line whose indentation they want to change. Even if we don't use external .scm files, perhaps we could add the queries in them to our Tree-sitter rules? I think we'd need a new Tree-sitter matcher to match them properly, right?