From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#62238: 30.0.50; Unusual interpretation of "S-expressions" in c-ts-mode Date: Sun, 19 Mar 2023 19:28:58 +0200 Organization: LINKOV.NET Message-ID: <86edplupr9.fsf@mail.linkov.net> References: <87ilezg0wo.fsf@posteo.net> <7FDC4392-AC34-4EA2-A166-AB10755361CD@gmail.com> <83jzzeb2v6.fsf@gnu.org> <83fsa2as1a.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12454"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) Cc: 62238@debbugs.gnu.org, casouri@gmail.com, theo@thornhill.no, philipk@posteo.net, Daniel =?UTF-8?Q?Mart=C3=ADn?= To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Mar 19 18:54:35 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1pdxEo-00031P-J7 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 19 Mar 2023 18:54:34 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pdxEM-00063M-GS; Sun, 19 Mar 2023 13:54:06 -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 1pdxEJ-00060S-8R for bug-gnu-emacs@gnu.org; Sun, 19 Mar 2023 13:54:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pdxEJ-0007q8-0f for bug-gnu-emacs@gnu.org; Sun, 19 Mar 2023 13:54:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pdxEI-0002gA-Sz for bug-gnu-emacs@gnu.org; Sun, 19 Mar 2023 13:54:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 19 Mar 2023 17:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62238 X-GNU-PR-Package: emacs Original-Received: via spool by 62238-submit@debbugs.gnu.org id=B62238.167924838210169 (code B ref 62238); Sun, 19 Mar 2023 17:54:02 +0000 Original-Received: (at 62238) by debbugs.gnu.org; 19 Mar 2023 17:53:02 +0000 Original-Received: from localhost ([127.0.0.1]:52682 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pdxDJ-0002dl-OA for submit@debbugs.gnu.org; Sun, 19 Mar 2023 13:53:02 -0400 Original-Received: from relay2-d.mail.gandi.net ([217.70.183.194]:54623) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pdxDH-0002dN-Lk for 62238@debbugs.gnu.org; Sun, 19 Mar 2023 13:53:00 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 570A540005; Sun, 19 Mar 2023 17:52:51 +0000 (UTC) In-Reply-To: <83fsa2as1a.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 18 Mar 2023 19:27:45 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:258245 Archived-At: >> > I don't understand how you came to that conclusion. Why would we want >> > to use syntax tables when we have a parser at our fingertips? And if >> > "the Tree-sitter function is general and should work for every >> > language", as you say (and I agree), why should we refrain from using >> > it for C? >> >> Note that basing C-M-x on syntax tables (that is, traditional >> forward-sexp) does not completely exclude the use of Tree-sitter, AFAIU. >> Here's my thought process: To do its job, C-M-x needs to know about some >> code structures such as symbol constituents, strings, comments, and >> parenthetical groups. If in some language or future version of C the >> syntax is complex enough that getting the syntax class of a character >> requires proper parsing, the Tree-sitter major modes can augment the >> syntax table to make C-M-x work correctly. See >> c-ts-mode--syntax-propertize for an example of how Tree-sitter can >> augment a buffer's syntax table, if needed. > > We have already C mode that uses syntax tables. I think it's useful > to try syntactic movement using results of parsing as well, and > compare the relative merits and demerits. After trying to tweak treesit-sexp-type-regexp a few times I become convinced it is not up to the task of properly handling all sexp operations. It seems the existing functions that implement C-M-f (forward-sexp), C-M-u (backward-up-list), etc. should remain in place, and the role of the tree-sitter would be only to provide syntax information for them, i.e. just to replace syntax tables with tree-sitter wrappers.