From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_Paulo_Labegalini_de_Carvalho?= Newsgroups: gmane.emacs.devel Subject: Re: Initial fontification in sh-mode with tree-sittter Date: Thu, 3 Nov 2022 10:08:49 -0600 Message-ID: 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 Content-Type: multipart/alternative; boundary="000000000000faf4bb05ec932c43" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12392"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , emacs-devel@gnu.org To: Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Nov 03 17:09:45 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 1oqcmm-00032e-NE for ged-emacs-devel@m.gmane-mx.org; Thu, 03 Nov 2022 17:09:44 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oqcmD-0004TD-Kw; Thu, 03 Nov 2022 12:09:09 -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 1oqcmB-0004Ri-Kq for emacs-devel@gnu.org; Thu, 03 Nov 2022 12:09:07 -0400 Original-Received: from mail-ed1-x533.google.com ([2a00:1450: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 1oqcm9-0006mw-Uk; Thu, 03 Nov 2022 12:09:07 -0400 Original-Received: by mail-ed1-x533.google.com with SMTP id i21so3742445edj.10; Thu, 03 Nov 2022 09:09:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=m+Th1Oy0kkMfArCVu+B0pe33yDyhqs//up7FB67c1Vc=; b=YIk3e9rkYF8yJSiEd9OJNI+y6m8i6Zle7uBNLow5hGhQUJfulmzVx34WARWfdQiO6I CLu97r+H1qjvvmq3kBg8Bo9X66pA6WU7HR1ybVLAKt9PLtaP1LanLBzB6ugYiYSuheG3 +4FqjwkQXW1TJR5fMlsJvG/OsesKtZwa9YZrFVEcBv3whSMFliqz9LDSt0bU/A09oBpS aq6wxCWophrqrY25l+7BZGmQAn049JXE0u2E5SNgo8pkKMpLanVIxqXSLn0S6JtpWgJc +2TCY7grrYQUvD0aP28yQqDweQeq8iYLufi3BdILuqv+5pDlePHOuSw9G7JzwzM2xvHi 75iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=m+Th1Oy0kkMfArCVu+B0pe33yDyhqs//up7FB67c1Vc=; b=I5lsoC4QRFF34gsnDHfIRg09mtznVP0GK4/dSl2NFJYTzQvTQDiC9HUg+A+HX+cWSf wV2JC/zwx6/zFKhGt1PzcVITsFp0ti8/2UOSU5o1kudKW6JB9uXXp12Fdy2BW3ER7wy6 iVwMG4w3iYBjqBTrdNe5mKLtWsn8TlFYXlDYTAQ+BpHskcvU6cshm50YJ3oy8tUAYWyQ ePsmjM4PhMkvg5If1rVokYPxzO83Qwxx/fWOCwF32wtagyxLNnTKcG8qzXR1xiMc8AKt nTDXptfBpD7rXB/vav89JhM6Bn8EMSI2QzGaG1LTJfN55H/p/muDVRCi0A6vZeJCCfF1 BiWw== X-Gm-Message-State: ACrzQf1tTK/xRZR8kH3cEMwOBxl3kglDqoLUYsOYL2X9qgVMUC05aLe0 fnWbAUQaO7LA1K9xrM3kL4UifnVq/3kldipnkoY= X-Google-Smtp-Source: AMsMyM6CZvfXQcIJ6zyozf+ar3odsN0fNlvmC49yQTaAcPbzYwkZ0/0V3XQHIefWhNVbx6nRtgS8+WPiKX3YGRESL9Q= X-Received: by 2002:a05:6402:440d:b0:450:de54:3fcf with SMTP id y13-20020a056402440d00b00450de543fcfmr30197857eda.312.1667491742543; Thu, 03 Nov 2022 09:09:02 -0700 (PDT) In-Reply-To: <39ECD413-BD10-4BF3-90AC-36F02276607E@gmail.com> Received-SPF: pass client-ip=2a00:1450:4864:20::533; envelope-from=jaopaulolc@gmail.com; helo=mail-ed1-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, HTML_MESSAGE=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:299079 Archived-At: --000000000000faf4bb05ec932c43 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks for working on this. 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. > 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. > 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 hav= e > some measure to break possible infinite recursion (fontify region -> set > jit-lock-context-unfontify-pos -> cause refontification -> fontify region > -> =E2=80=A6). > I still need to look at your fix more carefully as a similar issue exists for sh-mode and heredoc strings. --=20 Jo=C3=A3o Paulo L. de Carvalho Ph.D Computer Science | IC-UNICAMP | Campinas , SP - Brazil Postdoctoral Research Fellow | University of Alberta | Edmonton, AB - Canad= a joao.carvalho@ic.unicamp.br joao.carvalho@ualberta.ca --000000000000faf4bb05ec932c43 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks for working on this.

Th= e 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.

I still need to get familiar with the parts of the code in= volved. But can we avoid this (potentially) expensive=C2=A0re-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 w= ould not need to be re-parsed.
=C2=A0
What I ended up doing is to set jit-lock-contex= t-unfontify-pos to the beginning of the string node (aka beginning of regio= n A). Then in a timer jit-lock-context will refontify everything after that= position. And I have some measure to break possible infinite recursion (fo= ntify region -> set jit-lock-context-unfontify-pos -> cause refontifi= cation -> fontify region -> =E2=80=A6).

I still need to look at your fix more carefully as a similar issue e= xists for sh-mode and heredoc strings.

--
Jo=C3=A3o Paulo L. de Carvalho
Ph.D Computer Science | =C2= =A0IC-UNICAMP | Campinas , SP - Brazil
Postdoctoral Research Fellow | Un= iversity of Alberta | Edmonton, AB - Canada
--000000000000faf4bb05ec932c43--