From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: treesit indentation "blinking" Date: Mon, 3 Apr 2023 15:07:11 +0300 Message-ID: <6efb9f84-211d-560e-3196-95d7f0b8be19@yandex.ru> 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> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19871"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Cc: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= , Yuan Fu , Eli Zaretskii , theodor thornhill , geza.herman@gmail.com, Daniel Colascione , emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Apr 03 14:08:17 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 1pjIyv-000532-2U for ged-emacs-devel@m.gmane-mx.org; Mon, 03 Apr 2023 14:08:17 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pjIy8-000061-Tn; Mon, 03 Apr 2023 08:07:28 -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 1pjIxy-00005i-IG for emacs-devel@gnu.org; Mon, 03 Apr 2023 08:07:19 -0400 Original-Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pjIxw-0006p4-6z; Mon, 03 Apr 2023 08:07:18 -0400 Original-Received: by mail-wr1-x42e.google.com with SMTP id i9so29102413wrp.3; Mon, 03 Apr 2023 05:07:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680523634; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=exrY44I6lU+O/qtU4dyvAwtizG/Bm1kBBVS6s5XfoFo=; b=o8ZI2OZRw05qtlBbLLFKnKtDUu2FfA6k6t1CJq2v5huQ7+eWd3QDBevZfVpbi62uvc 6xF+J5jD1pGkLKdBHmEOYitl3FQL2MtggpDqFSy/Ao0a3nDT0uwn2Wd5K/C9St1wggvZ spbsdju/fTH2b0cAciXUR2KVbxKqvejhVKgnnEXPP5Dw2Df9qqM/GHE8DPdC7KBT9u+/ cEVBYrhEk5u88Znn/XL829P6R/1EVuyu1g2NhwARsY+rbBvbY1e3L0QiyB8vCosPwtsM 8hidxUeqcDHcTZOb3Y5jVES/fUFcm/MWkbA0pf5TCPf1KE/GrIbKmRReSDBi5I2Y3BwY z+Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680523634; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=exrY44I6lU+O/qtU4dyvAwtizG/Bm1kBBVS6s5XfoFo=; b=BhqAMQ5ObbSyzzDDaBR0SgPAKgqRMcGueYIjN2jTVMbluPBw6YDirVfY3abs3NwpRH oLzaRMw6oz9zT+X7jy5XSGl/88UvQxHiXNT87dyrGHyRNAGZLkn0gnI7v+VVZkS70EOl QT+xWLCmafjYiM/P7Gf6cSPzVy2UMBT35OjKhRPqlH/N4lmDvKQra2V8zfZ498xCQev2 EasX+pFJ0sMYTpqCB0aRQltSKxAEVBJ16b5zmNkohomK/CqMlemIniLQ9crBIjIf3BDT Ijk15bQVWY1ECvw+3AJiPx3aLh4q2FLLpuvCPaELva3a/xR3ot0K68JjMxJvdciHOqI1 YSgg== X-Gm-Message-State: AAQBX9faAlwNP4YdXl0s9Zw+Bq5ND+5YXgvdpsEp1mt8gpI+TW1XnBHG rXUJPBH21TS2IPhMjmJVahU= X-Google-Smtp-Source: AKy350ZnLCOcc2l4qv9FOME17fAM/qAt15p9FgbYx9ExMkReCvv/hpwuxcynuIl6TMnFawxslwlZHQ== X-Received: by 2002:a5d:4744:0:b0:2cf:e2e8:c5e8 with SMTP id o4-20020a5d4744000000b002cfe2e8c5e8mr11312895wrs.35.1680523633699; Mon, 03 Apr 2023 05:07:13 -0700 (PDT) Original-Received: from [192.168.1.2] ([31.216.80.60]) by smtp.googlemail.com with ESMTPSA id u18-20020a5d5152000000b002be5bdbe40csm9536279wrt.27.2023.04.03.05.07.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 03 Apr 2023 05:07:13 -0700 (PDT) Content-Language: en-US In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=raaahh@gmail.com; helo=mail-wr1-x42e.google.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, NICE_REPLY_A=-1.349, 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:305066 Archived-At: On 03/04/2023 12:59, Alan Mackenzie wrote: > Hello, Dmitry. > > On Mon, Apr 03, 2023 at 00:21:18 +0300, Dmitry Gutov wrote: >> On 02/04/2023 20:23, João Távora wrote: >>> So my initial idea was to tone down electric-indent-chars, at least >>> for the moment. And Dmitry's idea was to make electric-indent-chars >>> be ambitious_only_ if electric-pair-mode is enabled (by the user). >>> Maybe we should bring back that idea, and it seems the least bad of the >>> bunch right now. > >> Alternatively, we only perform "electric indent" (aside from after RET) >> when the parse tree does not contain errors. > > That is NOT electric indentation. The whole point about electric > indentation is for it to take effect whilst point is still on the line > being edited. Thus, for example, you can see whether or not the line > needs breaking, or whether there's room for a short comment at the end > of the line. Wouldn't you know whether the line needs breaking, as long as the line was indented correctly when you opened it with RET? > What you're proposing is something which would almost never trigger, > since a line being edited will not have a parse tree without errors (if > I've understood that properly). If it did trigger at some point, that > would likely cause annoyance and puzzlement. That's a fair assessment, but it's going to trigger in a lot of cases still: after ;, or after a paren or brace being closed. This is not a substitute for enabling electric-pair-mode, alas. Just a less hackish way to check the same thing rather than check for this particular mode being enabled. I would also prefer c++-ts-mode supported indentation with closing braces missing, but we're really limited by what the parser provides. E.g. for this code int foo() { for (;;) { we get this parse tree: (ERROR (primitive_type) (function_declarator declarator: (identifier) parameters: (parameter_list ( ))) { for ( ; ; ) {) where the "for" statement isn't even present (the separate tokens are parsed as leaf nodes, and that's it). It's difficult to write meaningful indentation rules that would match this.