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: Tree sitter support for C-like languages Date: Tue, 15 Nov 2022 02:56:34 -0800 Message-ID: <93F973AB-C5B5-4A0B-BF99-1253ADA21092@gmail.com> References: <87tu36em9t.fsf@thornhill.no> <45FD2F78-F15B-488B-9348-A8E298D8AD35@gmail.com> <87v8nmyqqp.fsf@thornhill.no> <834jv4nz2g.fsf@gnu.org> <871qq8hsj1.fsf@thornhill.no> <83iljklzmo.fsf@gnu.org> <87v8nkgcqj.fsf@thornhill.no> <87sfiogcbm.fsf@thornhill.no> <83pmdrkyj7.fsf@gnu.org> <87v8njw5th.fsf@thornhill.no> <83leofkwjm.fsf@gnu.org> <9E9244D3-2EFB-4621-91E0-FC8B8C1C2D52@gmail.com> <09869DDB-2C3D-4064-81B0-0E6902C46396@gmail.com> <8d36534e-7fad-fde2-5cf0-ce7c42d4ee35@yandex.ru> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.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="15522"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , Theodor Thornhill , emacs-devel , monnier@iro.umontreal.ca To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Nov 15 11:57:34 2022 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 1outdF-0003se-VC for ged-emacs-devel@m.gmane-mx.org; Tue, 15 Nov 2022 11:57:33 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1outcg-0000jb-7D; Tue, 15 Nov 2022 05:56:58 -0500 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 1outcb-0000iu-6d for emacs-devel@gnu.org; Tue, 15 Nov 2022 05:56:53 -0500 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 1outcM-0007K2-4C; Tue, 15 Nov 2022 05:56:51 -0500 Original-Received: by mail-pj1-x1030.google.com with SMTP id d59-20020a17090a6f4100b00213202d77e1so16559674pjk.2; Tue, 15 Nov 2022 02:56:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=HLQpE7+DCacd/KrNEv7KzUi+shuE+ilQADEekOa6ZE8=; b=DoT9yHlbHgx0lcUeF6YwPBt/Ehw7IwATmMUii3x0j0brRVEV5XdUalHKULT2PctubA ga20NPhlOMZopvngw/QrU4WuWxDW3O5vYDljhgntLUvihWlpe1V9n+vv9eftTECUD+vu Xh0bR7obasKaVjzcIXRbgCzurJHMiCzDZmW+muclmFS+gizL7IhinuXsN07FtSOTEgZj o1fR2wy9SJcvS9J2160sESuQk0WkLirJkyodiysFHIcKttTJcqASMDCRlRj9EXacZ47F e++cQks6lxCy3FMGCqh17aKbQNRhYtRst8BcRnHo1aBnY/UM6FzO410G21Vc+0sifT7v jwkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=HLQpE7+DCacd/KrNEv7KzUi+shuE+ilQADEekOa6ZE8=; b=pSXefHo0YOWn4T6l2hF1LID0lyX0wOzHf28pdDvcCYhvikLlH7EFoDrND2PJj1Bfq2 E+a5ivGjSWxT57LaKjTu1VHTvS1KG1aH65FwmrA4UMAKabnMKa6SU+Daqei7magVpPPE CG5smBpTo1ZgoXesIZHfSk39RAWOJzaaaSgs5LRXy//ConsQmw9urMuwIqIaP4UAFO45 QKv65dSOR7GX5Vgu9qnLFVVXS7OPyBWZT62AqWnOBsd6V2Rr1JCB2H0LhOKgRynecHoH ohilddRbpefY5qNQpdAmc8fx3ZteAQ4joeSM5w4aReKgZBOrIo58LrMbXN/6l2LVRmcS +hXA== X-Gm-Message-State: ANoB5pnj7SHcAT/Bpl6ek/aRIMmJXQZcKbApShk5cYffy0aZ5+xD74tT 2IEn+a+RV5WuAAUffLyQcSU= X-Google-Smtp-Source: AA0mqf5d0lpbLYE+5+YoJEOUMcvyuCm+4diyigPjWMa+CR4I7XQWGLZQd6GA0o5ppZXedOEDbVXllw== X-Received: by 2002:a17:902:b901:b0:172:b0f3:527f with SMTP id bf1-20020a170902b90100b00172b0f3527fmr3653096plb.40.1668509796426; Tue, 15 Nov 2022 02:56:36 -0800 (PST) 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 u8-20020a1709026e0800b00188767268ddsm9503540plk.151.2022.11.15.02.56.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Nov 2022 02:56:35 -0800 (PST) In-Reply-To: <8d36534e-7fad-fde2-5cf0-ce7c42d4ee35@yandex.ru> X-Mailer: Apple Mail (2.3696.120.41.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, 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:299840 Archived-At: > On Nov 14, 2022, at 11:54 AM, Dmitry Gutov wrote: >=20 > On 14.11.2022 10:35, Yuan Fu wrote: >>> On Nov 13, 2022, at 5:26 PM, Dmitry Gutov wrote: >>>=20 >>> On 14.11.2022 02:22, Yuan Fu wrote: >>>> So if we want the warning face to automatically disappear, we need = to record these warning faces and remember to come back to refontify = them later. We need to know when to refontify them, and know when to = stop trying to refontify them (maybe the error isn=E2=80=99t transient). = For now I think it=E2=80=99s best to just not fontify the error nodes. >>>=20 >>> I'm guessing the situation could be the reverse as well: after the = user typing some chars, the warning would need to be *added* rather than = removed, in some cases. >> That=E2=80=99s a good perspective. But from what I see I think it=E2=80= =99s best not to fontify these =E2=80=9Cerrors=E2=80=9D, at least for C = and C++. Because a lot of things could be marked =E2=80=9Cerror=E2=80=9D = in a C file, like stuff around macros. And in extreme cases the whole = file is marked =E2=80=9Cerror=E2=80=9D, even though if we ignore the = error everything is parsed fine. I guess tree-sitter isn=E2=80=99t happy = about some tiny thing in that file but never the less can parse = everything correctly. I attached that file below. >=20 > Perhaps not in C/C++, but other langs could use them. >=20 > Also (and here I'm really guessing, not sure what the = limitations/benefits of TS grammars are) there might be other nodes = which could change due to the user writing or deleting code on = subsequent lines. Yes, this is common for comments and multi-line strings. And we can = correctly handle them now, yay (see my other message.) >=20 >>> Any chance tree-sitter gives you some info/callbacks to convey the = earliest node (closes to bob) which has changed after the most recent = buffer modification? So we'd refontify starting with its beginning = position. >> Yes and no, I explained in more detail in another message. >=20 > If you're referring to this grandparent message: >=20 > > jit-lock doesn=E2=80=99t know it needs to be refontified >=20 > ...then I suppose it's a matter of letting it know somehow. I haven't = read the TS integration code yet, so I'm not sure at which level it = integrates with jit-lock. It plugs into font-lock, but it also secretly knows about jit-lock=E2=80=A6= We now can tell what parts of the buffer are affected/changed, and we = set fontified to nil in those areas so redisplay will refontify them. >=20 > But jit-lock-functions are allowed to fontify more than the passed in = boundaries, for example. Yuan