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: Initial fontification in sh-mode with tree-sittter Date: Mon, 31 Oct 2022 14:56:02 -0700 Message-ID: <7AE71CCA-6F18-4DE6-8608-7D9B3E9E52FB@gmail.com> References: <6C8B0F8E-DF61-4BC3-B0D0-56DBB66BE637@gmail.com> 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="24149"; mail-complaints-to="usenet@ciao.gmane.io" Cc: =?utf-8?Q?Jo=C3=A3o_Paulo_Labegalini_de_Carvalho?= , emacs-devel@gnu.org To: =?utf-8?Q?Daniel_Mart=C3=ADn?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Oct 31 22:57:00 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 1opcmB-00066o-Lv for ged-emacs-devel@m.gmane-mx.org; Mon, 31 Oct 2022 22:56:59 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1opclQ-0008NU-Ew; Mon, 31 Oct 2022 17:56:12 -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 1opclP-0008NJ-2j for emacs-devel@gnu.org; Mon, 31 Oct 2022 17:56:11 -0400 Original-Received: from mail-pg1-x533.google.com ([2607:f8b0: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 1opclN-0007TV-Bp for emacs-devel@gnu.org; Mon, 31 Oct 2022 17:56:10 -0400 Original-Received: by mail-pg1-x533.google.com with SMTP id q71so11823946pgq.8 for ; Mon, 31 Oct 2022 14:56:07 -0700 (PDT) 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=eQYECjcidB9IFA/E3Ah3Zwzn6YMpR0HfCmUoVIei0rA=; b=K9RmVcIpriSxS5Mkvh6vQVfWS0mHx7UPUmZfxS1b8Ynu4lY2xp37NW0bZGslUNNtna nm3lG1ODHl3xZTcGH+9gsTTX7o5c4dJ2iNlUBBm/+DWA55BoEcwRHpy2t1PkIXEsyvyY nyBxDUpz9riT5I0zvsn2aSc9MtarhDM9Asb18jDa/nHCOrGsfqaz9vJ24KNFtb9KNMmY 6DfhbglXOkLR0G4z4xiPvz5NEr0GogL9DHsTR+Q0wBPxqobrC2y/k/st0I0xTFSqMArM 9i6l9/j3enVABWiSJ9azZka3BcbU48lW9zTn/Intpcpb5SbT5hmlXjJkPQ2O0HIYIKf4 1tMg== 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=eQYECjcidB9IFA/E3Ah3Zwzn6YMpR0HfCmUoVIei0rA=; b=PI02MM2I9sRj6eCSaSHZpcwngtkbT+lTuxZd0xPmQlm6KrjrS/Tn0HE7yfSwiu5FJJ cuGGk1MENz50mL+vo1SRU7jewrH09kXiJpsJodEoAVokLXTWbwj6Cpg4FxtE1djAzKH3 duKclk/zYR3UFxHBNzyYuWk4vTAMEV/3fw1ZCvIIbVuLorusC/z1cJ3DfjEBLpB3NT0b o6DkbsfCzOCBAoBidDdZc2/G9Tl9COyxb3UUH3DM+pyZJCieW8joLvWH35d1FceVBcmb zg+ogF5AoCd9qAVvzb4CSrbb7AmAqrLzEq9TciHR+/P6n5EntdWqYxzrIRsVK/PI5f2T cAMA== X-Gm-Message-State: ACrzQf29/lk1UqT5H/lAIdK1W+XfGkO3suhuzWJt8oQkx3YtsC4s2BDk KJ23C84rwHBQrjKwx3qBMwE= X-Google-Smtp-Source: AMsMyM4tSan7nQ1qc9xjq4FhCPLSB6CYSp+tavL8Xw/ybCb0qKbgJu9WeUk/o8luzA1uQL/kn8ereQ== X-Received: by 2002:a05:6a00:16c4:b0:535:890:d52 with SMTP id l4-20020a056a0016c400b0053508900d52mr16352428pfc.9.1667253366344; Mon, 31 Oct 2022 14:56:06 -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 4-20020a621404000000b0056c704abca7sm5064602pfu.220.2022.10.31.14.56.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Oct 2022 14:56:05 -0700 (PDT) In-Reply-To: <6C8B0F8E-DF61-4BC3-B0D0-56DBB66BE637@gmail.com> X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=casouri@gmail.com; helo=mail-pg1-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: , Original-Sender: "Emacs-devel" Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:298895 Archived-At: > On Oct 30, 2022, at 7:13 PM, Yuan Fu wrote: >=20 >=20 >=20 >> On Oct 28, 2022, at 8:09 AM, Daniel Mart=C3=ADn = wrote: >>=20 >> Yuan Fu writes: >>=20 >>>=20 >>> Hmmm, I couldn=E2=80=99t reproduce this in python-mode, also defun = is not recognized in python so I used this snippet: >>>=20 >>> def foo(): >>> Return 42 >>>=20 >>> When I insert =E2=80=9C=E2=80=9D=E2=80=9D before the defun, = everything after becomes string face, when I insert the following = =E2=80=9C=E2=80=9D=E2=80=9D, everything is updated again. >>>=20 >>> I didn=E2=80=99t make any significant change to the font-lock code = recently, either. >>>=20 >>=20 >> I can reproduce the problem by following these steps: >>=20 >> emacs -Q from top of the feature/tree-sitter branch >> M-: (require 'treesit) >> M-x customize-variable treesit-settings RET >> Set "Activate" to "Yes" and apply the change. >> C-x b sample.py RET >> M-x python-mode >> Write the following program: >>=20 >> def main(): >> return 0 >>=20 >> M-< C-o """ (the code is not fontified as string) >> M-> """ (the code is not fontified as string) >> M-x python-mode RET (the code _is_ fontified as string) >=20 > Thanks, I can reproduce this on emacs -Q, too (but strangely not on my = =E2=80=9Cconfigured=E2=80=9D Emacs). >=20 >>=20 >> A git bisect tells that the first bad commit is >> 5159789e55d64c7482dff3dc1a621d01f530f83c >=20 > Strange, this commit has nothing to do with font-lock, hmm... >=20 >>=20 >> Hope this helps. >=20 > Yes! Many thanks. >=20 > Yuan I think I=E2=80=99ve fixed this problem. It is mainly due to how the = fortifications rule is written. When the starting quotes are inserted, = normal syntactic font-lock will mark everything behind it in = string-face, but for tree-sitter, since the source is incomplete, the = quotes are in an error node in the parse tree and there is no string = node, so tree-sitter rules can=E2=80=99t capture any string node, so no = string face is applied. And when the ending quotes are inserted, the = only region jit-lock wants tree-sitter to fontify is that three quote, = so again the whole string is not captured. I changed the font-lock rule = to match the ending quote rather than the whole string, and now it=E2=80=99= s working fine. Now it is actually better than before: If you insert an open quote, the = rest of the buffer will not be marked in string face, instead, and when = you insert the ending quote, the string is fontified correctly. Yuan