From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Newsgroups: gmane.emacs.devel Subject: Re: treesit indentation "blinking" Date: Sat, 25 Mar 2023 16:14:15 +0000 Message-ID: <87wn34x0yw.fsf@gmail.com> References: <87h6ucik61.fsf@dancol.org> <0F406D08-56D4-4B21-B94D-A47681606911@gmail.com> <1870bcadd28.2829.cc5b3318d7e9908e2c46732289705cb0@dancol.org> <1870cce6690.2829.cc5b3318d7e9908e2c46732289705cb0@dancol.org> <35A837A9-59B4-4F1F-A5FA-8483C8024D76@gmail.com> <187104f6b48.2829.cc5b3318d7e9908e2c46732289705cb0@dancol.org> <21d018e5-a730-12e3-f97c-fffa4f646ccf@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="16761"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Daniel Colascione , Yuan Fu , emacs-devel@gnu.org To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Mar 25 17:13:24 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 1pg6WC-00049f-Se for ged-emacs-devel@m.gmane-mx.org; Sat, 25 Mar 2023 17:13:24 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pg6VD-0007WC-7E; Sat, 25 Mar 2023 12:12:23 -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 1pg6VA-0007Sb-PV for emacs-devel@gnu.org; Sat, 25 Mar 2023 12:12:20 -0400 Original-Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pg6V8-00080k-4r for emacs-devel@gnu.org; Sat, 25 Mar 2023 12:12:19 -0400 Original-Received: by mail-ed1-x533.google.com with SMTP id ew6so19377666edb.7 for ; Sat, 25 Mar 2023 09:12:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679760734; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=E78U9OSzY1Em4H61TIWOTfdTFcQudTaW4lNR6JfLI1c=; b=gSxKwyLkocftFH305KYqo596iJRVPeu9WS7gA2O4eBPW9M5OcrjXrforEwjlrDRBgP ALnWr8VjM1dhZWuwj0AzY0w/+LqsAvCA73dUJxZPHDSTPjL3cYevf2yNlafAzBJDZ8FR WV1oS3WQj4FgUrqh9z1nACwy7WXA9QIhcZSjwtiVLva+JM+DliYmB2u3xdAF9Q/61SFB jc+Gt4vutZdiEIj4tDa/5kdFk6UlPYBg+fJ5tT2hHKRPsZrrvTn27u4dISW1ELZ8H9Qg DPKI2dgBrBu3UVo5O+mhpsXWLjhWWdy+nqAKkK2Q47ZGqRvqwyixc08JHNnkActZhDKo pPfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679760734; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=E78U9OSzY1Em4H61TIWOTfdTFcQudTaW4lNR6JfLI1c=; b=22mNpL1LhU716rkR9o2cK7n+2dgpfuks3cuzXuU/fbtZ8uuoJk+Rov66vahuT6F82a LpXo2W9VklHDcrByu9lZZp2lgPHVAzdh7apH4z2N/N/gE2xID3wjrr9mLSCjewXUDsJa CXcEFXuoBS/UueMGe7OowWmD3cCUmZ9wHpHjJ8eseGEefBVfwPg86/u1tH6WfVIRcUR8 IdBHDBbr0K2wj87SgbWiYJPr7CPp0LAI92MO2ZI813I7PZmGuCyTm4QPIFUXXnpPiS1R LMn7ymaYopirqMuqBN2qEc8CO+y1/OpeaOgNarlPcLM+snLDYzMqMDnrrfY8VWOLCXUg AUtg== X-Gm-Message-State: AAQBX9eMGMI7mB4Dw40lp1bqqrR5qxHxSNpObpGlZUvztCcB20XQ8huI VA4jmdTz4fw5ftBFK3ANmtzLr1jlW+0= X-Google-Smtp-Source: AKy350ZcOop+z+wO6dMPRR5gqSLIMTWhULb+m7v7r6FHcLrS282EW4LbpBv0zTWif0dX037LHPFkXw== X-Received: by 2002:a17:907:8b88:b0:925:f788:d76d with SMTP id tb8-20020a1709078b8800b00925f788d76dmr6936547ejc.27.1679760734111; Sat, 25 Mar 2023 09:12:14 -0700 (PDT) Original-Received: from krug (87-196-74-168.net.novis.pt. [87.196.74.168]) by smtp.gmail.com with ESMTPSA id l11-20020a1709066b8b00b00939faf4be97sm6934745ejr.215.2023.03.25.09.12.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Mar 2023 09:12:13 -0700 (PDT) In-Reply-To: <21d018e5-a730-12e3-f97c-fffa4f646ccf@yandex.ru> (Dmitry Gutov's message of "Sat, 25 Mar 2023 14:42:50 +0200") Received-SPF: pass client-ip=2a00:1450:4864:20::533; envelope-from=joaotavora@gmail.com; helo=mail-ed1-x533.google.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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:304764 Archived-At: Dmitry Gutov writes: > On 25/03/2023 11:05, Jo=C3=A3o T=C3=A1vora wrote: >> On Thu, Mar 23, 2023 at 9:24=E2=80=AFPM Dmitry Gutov = wrote: >>> >>> On 23/03/2023 23:10, Daniel Colascione wrote: >>>> Editing can cause all sorts of transient nonsense in the AST, and it's >>>> impossible to predict in a general manner what this nonsense might be. >>>> The wrong kind of bracket can cause the entire rest of the file to be >>>> parsed as nonsense. This or that error recovery rule isn't going to >>>> solve the problem: such a strategy is a fragile whack a mole. There >>>> needs to be some general solution to prevent indentation blinking. This >>>> blinking makes TS modules unusable for me. >>> >>> It seems to me it will only be feasible to support a number of >>> "incomplete" syntax constructs. Maybe it will constitute a majority of = them. >> I don't think this problem has anything to do with tree-sitter. It >> would happen just as well in regular c++-mode if electric-indent-mode >> were on by default there (but it isn't). > > The mode is globally on by default, but indeed the contents of > electric-indent-chars are much shorter there. > >> So it's just the fact that electric-indent-mode is on by default >> _and_ c-ts-mode.el does this: >> (setq-local electric-indent-chars (append "{}():;,#" >> electric-indent-chars)) >> so people are getting what the mode author (and Emacs defaults) ask >> for: >> electric indentation doing its thing. > > Good point: perhaps either this list should be revisited, or > predicated (at runtime) somehow on electric-pair-mode being enabled. At first, I thought this was a good idea. electric-pair-chars could be a function returning the characters to use, and c++-ts-mode could set it to a function that returns the extended set if electric-pair-mode is on. But OTOH, extra chars in electric-indent-chars is of limited use if electric-pair-mode is on, because when the buffer is balanced, newline-inserting commands already do the correct indent. So, it would probably solve this problem, but not much beyond not messing with electric-indent-chars at all in the first place. Jo=C3=A3o