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: Thu, 3 Nov 2022 12:12:19 -0700 Message-ID: <8A2361BB-1081-4550-AC29-B9E99BFC2FB8@gmail.com> References: <6C8B0F8E-DF61-4BC3-B0D0-56DBB66BE637@gmail.com> <7AE71CCA-6F18-4DE6-8608-7D9B3E9E52FB@gmail.com> <9BA853EA-8B7F-41A0-A174-D86DF5CE7788@gmail.com> <83sfj3cfl0.fsf@gnu.org> <03309451-1AEB-458C-88FD-9715CECC27A2@gmail.com> <83mt9bc9ke.fsf@gnu.org> <8335b19ndr.fsf@gnu.org> <39ECD413-BD10-4BF3-90AC-36F02276607E@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="28142"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , emacs-devel@gnu.org To: =?utf-8?Q?Jo=C3=A3o_Paulo_Labegalini_de_Carvalho?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Nov 03 20:13:22 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 1oqfeU-0007EP-4r for ged-emacs-devel@m.gmane-mx.org; Thu, 03 Nov 2022 20:13:22 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oqfde-0001Dw-Eb; Thu, 03 Nov 2022 15:12:30 -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 1oqfdb-0001DN-CQ for emacs-devel@gnu.org; Thu, 03 Nov 2022 15:12:29 -0400 Original-Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oqfdZ-0003Oz-3z; Thu, 03 Nov 2022 15:12:26 -0400 Original-Received: by mail-pl1-x632.google.com with SMTP id p21so2838020plr.7; Thu, 03 Nov 2022 12:12:24 -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=nbakrorWu6WVaz2YFIonEwRtHUNadSqnM10RWId9BFc=; b=QclNItMSOdPX0UEcJSBKbqYpl/ugGdeJgFIDHEzT3+AvgaU8+wZObv2/4QMk/6J77j Kv7flED2Nj+oi7g1ddGlFj584g0KFxS/5mkAIpBlQO20iUrfnJMa3z1+rouaXXSp4KEN 8EiOKKPWluj1bS5aqlIBUAnbhkuxXEIsGPcoALfFDepANoCohC2D0NnF+sFutrZTU9nY IkrZfnVpa17Se73bvUNJsQCAsomR14aTsyigP5CE0A1T9Iaq0SRfQyNER6g/7ba/dCtp CnJBRVS4Jnv2rQml4p3BUBgNypxModn/6UdSu1ah5g8Bzdb7qLiqKOaR7Bs2qsjs6PaI pX0Q== 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=nbakrorWu6WVaz2YFIonEwRtHUNadSqnM10RWId9BFc=; b=vDFt91nrVc2kDn8EE8bROu0LrfeT/AFX6oK4YBO16WhPd2sEk5+2SR2yYKfimg1JP+ zv9ngkfv+8XDG3D0Xw58mbEF/FXMTsjovPzosiQ+rnxuu7I2L5y7dqINrYG5i3bxirDk IKtGHUpT3GQ9TpDKqoznF3xV21jz2WgkE0cnpnwpdYiqxMj1lsQOmbhqAPoopdzfSgBZ Yfqk/Z57ersBW56KwOMDugx2cdYn80YE28o0JwPXxfuWjyfa6au5tC03vH4q1UHuySlC I+dgarZOm6XzYHewhiKHZn46J+TDhBbSEBJhg6LbW74hSLMldya5UvRczrDO/hnuI3GL KsVA== X-Gm-Message-State: ACrzQf3l0kTdfqnkNonv3Irb/WLYV7D9NlpjILimeo5frgZLRhjGnUwi gOrcZ9mTK/kRdJ57lEt9BfA= X-Google-Smtp-Source: AMsMyM4yEAr6EGMcNU9AlEoD5RIdUEL1riOy/gUeO1FzsWZtCEaX1GzZasEi3XudFRDJj45/nr9rvA== X-Received: by 2002:a17:903:1110:b0:178:9f67:b524 with SMTP id n16-20020a170903111000b001789f67b524mr31988076plh.50.1667502742057; Thu, 03 Nov 2022 12:12:22 -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 k30-20020aa7999e000000b0056bcfe015c9sm1054915pfh.204.2022.11.03.12.12.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Nov 2022 12:12:21 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=casouri@gmail.com; helo=mail-pl1-x632.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@gnu.org Xref: news.gmane.io gmane.emacs.devel:299096 Archived-At: > On Nov 3, 2022, at 9:08 AM, Jo=C3=A3o Paulo Labegalini de Carvalho = wrote: >=20 > Thanks for working on this. >=20 >> The deeper problem is, if there is some regex-based-font-lock face in = region A (applied when Emacs fontified region A), eg, highlighted TODO = keywords in a docstring, they will be overwritten by the string face, if = we just apply string face to the whole string and trigger redisplay. >=20 > I still need to get familiar with the parts of the code involved. But = can we avoid this (potentially) expensive re-fontification by keeping a = list of text properties/fonts applied to a region? Because if the region = was not changed, aside from adding/removing comments, then it would not = need to be re-parsed. This shouldn=E2=80=99t be expensive, and most work is delayed until the = region is actually displayed. I wouldn=E2=80=99t worry about it.=20 > =20 >> What I ended up doing is to set jit-lock-context-unfontify-pos to the = beginning of the string node (aka beginning of region A). Then in a = timer jit-lock-context will refontify everything after that position. = And I have some measure to break possible infinite recursion (fontify = region -> set jit-lock-context-unfontify-pos -> cause refontification -> = fontify region -> =E2=80=A6). >=20 > I still need to look at your fix more carefully as a similar issue = exists for sh-mode and heredoc strings. All you need to do is capture these contextual nodes in a special name = =E2=80=9Ccontextual=E2=80=9D. (heredoc_body) @contextual (string) @contextual This should take care of updating faces. But I don=E2=80=99t know about = the bleeding you described in the very beginning. Do you still see it? = Is there a recipe to reproduce it? Yuan