From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#71345: Feature: unleash font-lock's secret weapon; handle Qfontified = non-nil Date: Mon, 03 Jun 2024 12:56:13 -0400 Message-ID: References: <8A929E16-AF10-4D2B-AD71-AEAD4435F016@gmail.com> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24051"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: dmitry@gutov.dev, 71345@debbugs.gnu.org To: JD Smith Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jun 03 18:57:13 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1sEAze-0005yf-FB for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 03 Jun 2024 18:57:10 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEAzM-0006kh-0C; Mon, 03 Jun 2024 12:56:52 -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 1sEAzK-0006kQ-7Y for bug-gnu-emacs@gnu.org; Mon, 03 Jun 2024 12:56:50 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sEAzJ-0006Ix-P2 for bug-gnu-emacs@gnu.org; Mon, 03 Jun 2024 12:56:49 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sEAzW-0003jW-2e for bug-gnu-emacs@gnu.org; Mon, 03 Jun 2024 12:57:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 03 Jun 2024 16:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71345 X-GNU-PR-Package: emacs X-Debbugs-Original-Cc: Dmitry Gutov , bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.171743380214294 (code B ref -1); Mon, 03 Jun 2024 16:57:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 3 Jun 2024 16:56:42 +0000 Original-Received: from localhost ([127.0.0.1]:49876 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sEAzC-0003iS-9t for submit@debbugs.gnu.org; Mon, 03 Jun 2024 12:56:42 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:34910) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sEAzA-0003iK-BY for submit@debbugs.gnu.org; Mon, 03 Jun 2024 12:56:41 -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 1sEAyq-0006a4-PQ for bug-gnu-emacs@gnu.org; Mon, 03 Jun 2024 12:56:22 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEAyo-0006Fv-BF for bug-gnu-emacs@gnu.org; Mon, 03 Jun 2024 12:56:20 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 6EBC0806D1; Mon, 3 Jun 2024 12:56:16 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1717433771; bh=EF24VqVw7GFBDT1r3S6ZnpVdWD+0mj9GFE1UdOU31Tw=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Vh+yv/3wlaplrOi+okLSJEPZoR/mKCiftCR3QMOdk5dqSDo2c9/KKrOTejN1Bu5r8 YyxI6JugULBGLCDfYYedQWAuTnOQAizfQUreBQBHexLzxQ9iEZsYSy+Vq0SGMFR6rK I9YhCIE9eMLKl+qRoX6rGtsIQesk5hfgXcVdNlhVEwWvGtt+hmqdjyh2n7qu7Ofx4k O/omD2PTQzf6jNg5nHIWEpElbNgNXhsF1bDY0LfQUagVSdsi07Bpb8KqOzoCPnYVKy 44Dl+lZ0IszZ8F+DbPOlVvvT71UQji6G9740dGUn99Afdi70vQ8LQ46aBQ4E65jhiJ kF+y2fS94ldVg== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 2CF6280788; Mon, 3 Jun 2024 12:56:11 -0400 (EDT) Original-Received: from alfajor (unknown [23.233.149.155]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 04EB712041B; Mon, 3 Jun 2024 12:56:10 -0400 (EDT) In-Reply-To: <8A929E16-AF10-4D2B-AD71-AEAD4435F016@gmail.com> (JD Smith's message of "Mon, 3 Jun 2024 12:35:02 -0400") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:286472 Archived-At: > In my particular case, I've been trying for several months to achieve > a scheme for position-dependent additional fontification based on treesitter > scope: think font-lock, but respondent not just to the contents of the > buffer, but also the location of point within it. My particular application > is drawing treesitter scope-aware indentation bars. There are many other > applications you could envision, including many discussed here > (e.g. bug#22404). I've been meaning to add support for that to jit-lock. Here's the design I have in mind: >From the outside, only one change, i.e. a new function (jit-lock-flush BEG END FONTIFICATION-FUNCTION) where FONTIFICATION-FUNCTION is the exact same function that was passed to `jit-lock-register` (and is thus used as a kind of identifier of the corresponding backend). So in your case, when the position-dependent highlighting needs to be updated, you'd request it by calling `jit-lock-flush`. The way it would be implemented inside `jit-lock.el` is that `jit-lock-flush` would set `fontified` to nil over that whole region, but before that it would scan the region for those places where `fontified` is non-nil, and set the `jit-lock-already-fontified` property to the list of currently active backends (minus FONTIFICATION-FUNCTION), so as to remember that while this region does require jit-lock action those backends don't need to be called. Then when `jit-lock-fontify-now` is called it will skip those backends mentioned in `jit-lock-already-fontified`. Stefan