From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: treesit indentation "blinking" Date: Thu, 23 Mar 2023 13:04:02 -0700 Message-ID: <35A837A9-59B4-4F1F-A5FA-8483C8024D76@gmail.com> References: <87h6ucik61.fsf@dancol.org> <0F406D08-56D4-4B21-B94D-A47681606911@gmail.com> <1870bcadd28.2829.cc5b3318d7e9908e2c46732289705cb0@dancol.org> <1870cce6690.2829.cc5b3318d7e9908e2c46732289705cb0@dancol.org> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.400.51.1.1\)) 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="24587"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Daniel Colascione Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Mar 23 21:05: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 1pfRBc-00069v-5I for ged-emacs-devel@m.gmane-mx.org; Thu, 23 Mar 2023 21:05:24 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pfRAs-0001VX-2S; Thu, 23 Mar 2023 16:04:38 -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 1pfRAn-0001Um-QN for emacs-devel@gnu.org; Thu, 23 Mar 2023 16:04:35 -0400 Original-Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pfRAb-0001vp-8N for emacs-devel@gnu.org; Thu, 23 Mar 2023 16:04:31 -0400 Original-Received: by mail-pj1-x1030.google.com with SMTP id p13-20020a17090a284d00b0023d2e945aebso4273642pjf.0 for ; Thu, 23 Mar 2023 13:04:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679601854; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=5dFaaaClw+laEAmC+xE4y607eJc5toIM02PVM+t7Ors=; b=NGSPLjrFAc1O+3tWvvfqh0WEDGXrXgPkYCzJdLwh9kc2bdMjy82fXG9B72GhDiEOpg DB6HsGrT/njrhPvakqpdRwTseq7ZRtB+rZ5os+chIPVtCGYu+y2OsViUtyKUWaEyfsqT 3yqcg4l+5K3TvNVajh9Yj+lkodGThc7aCtXHiLugzNsHNfZXdLaQJ4ug7S3FdbfGnw7T UcCBBcDTSW8WhMHth6fzusuHQuJS82toIJj6ZewS9Bt1mCbubjP56z99xbbVIuj+1FnG 3pbV5ieaNqFK6Sa8tOUl6kRXYb+zjiNHIkSn3K41o2WiW0Z/UtU7g20YaHKW0dQyYq8g 2pmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679601854; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5dFaaaClw+laEAmC+xE4y607eJc5toIM02PVM+t7Ors=; b=jtnolCSXbbZHkTb/hvUo/QXLDN7JWlXSbaEO8WY1PP0afUsL6vsVplKrng1Wo8TT+z XWuka2qFC8M9hvQmZE8d3RaJ40Iwp6oEwzd6QTpT5VFTVH+Lkrnw5kwwUucwSIJOKZZS pP+dTi+/E+4/mbeiTBECTdWAq+i7Qjp7o+0xhzhHbQ4l+ehN5rNp9Oe/kbudg1Z+DJAu Xr3TCCpSNG4cDf6L3cBMx8Rbh72H47rVEcQiI9QcsmHIZJy9K8diEzlwgzZYAA8lxgQM KHTVJSNFL2pIzvtq2c4/tCfPMOyaBZBLjYXe9cSiMVYY+gKPJMyPoQr29j8/dSVSAtHZ ZfhQ== X-Gm-Message-State: AAQBX9fSzDHYwDtoDWqbZ5fRbUf/u7kJBpuxzsxXVtJx8voQTJH9d7oy oG96Z4bmpBztB/Z5dXFyzkk= X-Google-Smtp-Source: AKy350bgW3yhUEufsBDERX/fVBN0Ljf4lET0EK3Vp1SKjPgbT4hm5Ne82stBumgAy48OQewKWjxxtA== X-Received: by 2002:a17:903:28c3:b0:19c:be03:d1a3 with SMTP id kv3-20020a17090328c300b0019cbe03d1a3mr46458plb.40.1679601854105; Thu, 23 Mar 2023 13:04:14 -0700 (PDT) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id jd1-20020a170903260100b0019b0afc24e8sm12689257plb.250.2023.03.23.13.04.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Mar 2023 13:04:13 -0700 (PDT) In-Reply-To: <1870cce6690.2829.cc5b3318d7e9908e2c46732289705cb0@dancol.org> X-Mailer: Apple Mail (2.3731.400.51.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=casouri@gmail.com; helo=mail-pj1-x1030.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:304738 Archived-At: > On Mar 22, 2023, at 9:51 PM, Daniel Colascione = wrote: >=20 > On March 22, 2023 21:03:29 Yuan Fu wrote: >=20 >>> On Mar 22, 2023, at 5:07 PM, Daniel Colascione = wrote: >>>=20 >>>=20 >>>=20 >>> On March 22, 2023 20:00:23 Yuan Fu wrote: >>>=20 >>>>> On Mar 22, 2023, at 1:49 PM, Daniel Colascione = wrote: >>>>>=20 >>>>> Is there a general-purpose through which we can avoid line = indentation >>>>> oscillating as the user types when the AST is temporarily invalid, >>>>> e.g. after '(' or '{'? I'm checking out the C++ tree-sitter mode, = and >>>>> one of the more disconcerting things is the current line's = indentation >>>>> changing rapidly as I type. Is it feasible to create ERROR = recovery >>>>> indentation rules for every conceivable situation? >>>>>=20 >>>>=20 >>>> Yes, but in reality, I think all we need is a couple special case = for the unmatched ( and {=E2=80=99s. Can you think of other cases of = blinking indentations? >>>>=20 >>>> Yuan >>>=20 >>> But TS reacts to missing closing brackets by clarifying the whole = nearby expression as ERROR. It's not, as would be more useful, saying = "here's a stray (, and everything else is normal and parsed as if that ( = were absent=E2=80=9D >>=20 >> We can just look at the buffer text directly: if there=E2=80=99s an = ERROR and the previous char (after skipping whitespace chars) is ( or {, = we know what to do >=20 >=20 > Do we know what to do? That ERROR might be arbitrarily far up the = parse tree. I don't think it's as easy as you think it might be. One = strategy that might work is to see whether adding a "(" introduced an = error, and, if so, temporarily replacing that "(" with whitespace, = reparsing, and then using the resulting parse tree instead of the one = with the "(" to do indentation and fontification. This way, I think = you'd end up without the random jumping around we see today in TS modes. We can place this special rule at the end of our rule list, and previous = rules not matching should indicated =E2=80=9Cerror=E2=80=9D by itself. = Of course, I can=E2=80=99t prove it by using this method to fix the = blinking indent, but I don=E2=80=99t quite have the time for it right = now. Yuan