From: Eli Zaretskii <eliz@gnu.org>
To: JD Smith <jdtsmith@gmail.com>
Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org
Subject: Re: region-based face-remapping
Date: Wed, 10 Jan 2024 14:44:10 +0200 [thread overview]
Message-ID: <83edepnysl.fsf@gnu.org> (raw)
In-Reply-To: <23BA0312-2129-49A5-A43F-900F789E8C54@gmail.com> (message from JD Smith on Tue, 9 Jan 2024 16:31:30 -0500)
> From: JD Smith <jdtsmith@gmail.com>
> Date: Tue, 9 Jan 2024 16:31:30 -0500
> Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
> emacs-devel@gnu.org
>
> Did you try to use jit-lock-register machinery?
>
> Maybe Stefan (CC'ed) will have better ideas.
>
> I haven’t. In my (limited) understanding and experience, all the font-lock apparatus is highly tuned to
> after-change modifications. Here we need to (in addition) mark regions (old and new) as outdated,
> even when the buffer hasn’t changed at all, just based on the movement of the (selected window’s)
> point. I can know how to expand modified regions with `font-lock-extend-region-functions’, but I don’t
> know how to inform font-lock that “even though you didn’t see changes, trust me, these regions are in
> need of updating”. I would do this in a PCH, rate-limited by a timer.
It is not true that jit-lock is based on editing changes. It uses a
special text property to mark regions already fontified, so resetting
that property will cause the corresponding region to be re-fontified
on the next redisplay cycle.
> Maybe it’s as simple as calling `font-lock-flush’ on those regions? If so, can you call font-lock-flush
> multiple times in a row on overlapping regions without creating issues? Does font-lock-flush do the
> right (JIT) thing, even when you mark a very large region?
Yes, AFAIU. But it might be overkill for your case.
> And (this is the big one) how do you handle two chef’s both with their spoons in the font-locking pot
> at the same time?
>
> 1 Normal font-lock responding to changes in the buffer to refontify regions.
> 2 PCH+timer marks regions for refontification when the buffer-modified-tick or treesitter
> region-of-interest changes (the former because you can no longer trust that equal regions are in
> fact equivalent).
Don't worry about that, redisplay and jit-lock know how to deal with
that.
> Seem like there’d be a bunch of unnecessarily repetitive refontification in such a scheme. And
> marking large regions with `font-lock-flush’ every 75ms as you type also seems problematic.
That could be, but I'm quite sure this can be optimized if it works
for your use case.
> For disclosure, I’ve never used jit-lock-register, and personally find the font-lock documentation light
> on details for implementing non-standard fontification scenarios such as this.
That's why I asked Stefan to join this discussion.
> That's exactly what JIT font-lock solves, right? Editing a buffer
> changes the text, and thus the faces that need to be put on the text
> change also. For example, something that was a comment can become
> non-comment, or vice versa. Isn't what you describe similar (read:
> identical), except that the faces themselves are different, i.e. not
> font-lock faces?
>
> I guess so. The difficulty seems perhaps the other way around: updating font-lock JIT for both buffer
> modifications and (potentially) point movement (simultaneously, without stepping on each other!).
Again, don't worry about that. Once redisplay cycle starts, changes
are basically frozen, so whatever was done in the buffer gets
fontified. If there's a followup change, it will be fontified again.
next prev parent reply other threads:[~2024-01-10 12:44 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-08 21:49 region-based face-remapping JD Smith
2024-01-09 13:03 ` Eli Zaretskii
2024-01-09 14:15 ` Stefan Monnier
2024-01-09 20:20 ` JD Smith
2024-01-10 12:36 ` Eli Zaretskii
2024-01-09 20:20 ` JD Smith
2024-01-15 20:17 ` Stefan Monnier via Emacs development discussions.
2024-01-09 21:31 ` JD Smith
2024-01-10 12:44 ` Eli Zaretskii [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-01-02 0:22 JD Smith
2024-01-02 13:00 ` Eli Zaretskii
2024-01-02 15:49 ` JD Smith
2024-01-03 12:31 ` Eli Zaretskii
2024-01-03 12:40 ` Dmitry Gutov
2024-01-03 13:42 ` Eli Zaretskii
2024-01-04 0:07 ` Dmitry Gutov
2024-01-04 7:05 ` Eli Zaretskii
2024-01-05 3:49 ` Dmitry Gutov
2024-01-05 8:50 ` Eli Zaretskii
2024-01-05 14:18 ` Dmitry Gutov
2024-01-05 14:34 ` Eli Zaretskii
2024-01-05 16:25 ` Dmitry Gutov
2024-01-03 23:15 ` JD Smith
2024-01-04 6:58 ` Eli Zaretskii
2024-01-05 0:51 ` JD Smith
2024-01-05 8:19 ` Eli Zaretskii
2024-01-05 16:35 ` Dmitry Gutov
2024-01-06 14:04 ` JD Smith
2024-01-06 13:53 ` JD Smith
2024-01-06 14:27 ` Eli Zaretskii
2024-01-06 14:56 ` JD Smith
2024-01-08 17:28 ` Eli Zaretskii
2024-01-07 3:41 ` Dmitry Gutov
2024-01-15 19:55 ` Stefan Monnier via Emacs development discussions.
2024-01-15 20:19 ` Eli Zaretskii
2024-01-15 20:25 ` Eli Zaretskii
2024-01-15 20:36 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83edepnysl.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=jdtsmith@gmail.com \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).