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: Sun, 13 Nov 2022 16:22:36 -0800 Message-ID: <9E9244D3-2EFB-4621-91E0-FC8B8C1C2D52@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> 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="5100"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Theodor Thornhill , emacs-devel , monnier@iro.umontreal.ca To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Nov 14 01:23:36 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 1ouNGA-00019M-Ry for ged-emacs-devel@m.gmane-mx.org; Mon, 14 Nov 2022 01:23:34 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ouNFN-0005Me-9c; Sun, 13 Nov 2022 19:22:45 -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 1ouNFM-0005Ku-14 for emacs-devel@gnu.org; Sun, 13 Nov 2022 19:22:44 -0500 Original-Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ouNFK-0002Nn-5Y; Sun, 13 Nov 2022 19:22:43 -0500 Original-Received: by mail-pj1-x102c.google.com with SMTP id f5-20020a17090a4a8500b002131bb59d61so11277580pjh.1; Sun, 13 Nov 2022 16:22:41 -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=8tSpKdnGdkkgR/ufp/M2CKihFCXbGqQpIbEy+WBBk4w=; b=UkUAmxNoYDGPfwazUE5GwzRcKHu/TlJsRhM2r+DJxSGvrlehBhVvnOKxaYhrIP1EIp GJ+PhO4HqhfF521OrMlOgNz1aKd0PqhaMnDi43VZ5xn0Wt20o/Y+MYkHjhCuOpPH8iBc P01CpDM16s/vS/UULfvzlY51Ee5GpS81AsdE9v6JpZIct94t8HNWFCemfkS2uYSUUya2 h09lQEYKszGcekBNyqCmWRMY4aMzKy7r6BxcaLFSRB64MntTG6OXjfK5pG0zq9+m9skw iElUKoQJ5cLvFw+sBkF3Qbv+eVP+IfYfcHEXNTn9I6/ywaquTgiwDdjmbfNTGkriOcn/ D31w== 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=8tSpKdnGdkkgR/ufp/M2CKihFCXbGqQpIbEy+WBBk4w=; b=xsDNw8xXFST0IDPTd+M+VTRiSUDfcyRzuj+lYJD0O0N/E2f8f2pz5nZR2OeGu1ft7f ZiUw53ZlLYgftMeLJeSKhj23uWeiTl8oKwSxXqD74PuMpWc7v39GS55RrNNjqTp6RlGM 1X8A/ZbTjJBzt3LNLs/m2c/JLbzQtb9LlxdigSuIJ4CvwTEDa7A7sxV8Ul3vdHVD5s+G N5VY2innQ10HcZRkW8aFJgnI45T1e4yY9DeJLoqIP79Nvec+cLx6WEyN6PFEAyY04xNE jZMohwe+Ve7x1LTvm383k8hoFtcnayT+jhEfVTkNuqilXo4BGYMoDj6c16zkMRaU3AQf Vsuw== X-Gm-Message-State: ANoB5plfloe4vxFKDznflcrLob8P2HQHXxHyMnuYIuT4zIdYJq8watZw 97UjYwXIVenGxq19Mk6k49t63bnvA1I= X-Google-Smtp-Source: AA0mqf6bzP8TMiytMCYUfHUB7IwvvVgEJ/qH3UpaoT2fyyBz6vzWjxv557mGEOCB0NPF59gINEhz6Q== X-Received: by 2002:a17:902:6bc6:b0:187:1c65:e208 with SMTP id m6-20020a1709026bc600b001871c65e208mr11180788plt.173.1668385360066; Sun, 13 Nov 2022 16:22:40 -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 p10-20020a17090a2c4a00b0020a825fc912sm8340215pjm.45.2022.11.13.16.22.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 13 Nov 2022 16:22:39 -0800 (PST) In-Reply-To: <83leofkwjm.fsf@gnu.org> X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=casouri@gmail.com; helo=mail-pj1-x102c.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:299764 Archived-At: > On Nov 13, 2022, at 1:56 AM, Eli Zaretskii wrote: >=20 >> From: Theodor Thornhill >> Cc: casouri@gmail.com, emacs-devel@gnu.org, monnier@iro.umontreal.ca >> Date: Sun, 13 Nov 2022 10:40:26 +0100 >>=20 >>> But if I add an empty line at BOB, the fontification becomes as >>> expected, and doesn't go back to font-lock-warning-face even if I = then >>> remove that empty line. >>>=20 >>=20 >> This is likely due to either treesit or tree-sitter or tree-sitter-c = not >> dealing properly with the root node. Maybe Yuan has some insight = here? >=20 > This sounds like we don't update tree-sitter under some conditions, > IOW a bug of sorts. That=E2=80=99s just due to jit-lock. When jit-lock first fontifies int foo (void) { The parse tree has errors and it fontifies int in warning face. Then when you insert the closing bracket, the parse tree is complete int foo (void) { int bar =3D 0; } Int is still in warning face because jit-lock doesn=E2=80=99t know it = needs to be refontified. When you insert a newline in BOB, jit-lock = refortifies everything after the changed region, so int is refontified.=20= 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 Yuan=