From: "João Távora" <joaotavora@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
dalal.chinmay.0101@gmail.com, emacs-devel@gnu.org,
dimitri@belopopsky.com, luangruo@yahoo.com
Subject: Re: Eglot "inlay hints" landed
Date: Fri, 24 Feb 2023 10:42:26 +0000 [thread overview]
Message-ID: <CALDnm50JOrpvcms6KmtGoyYaJsUsTVN7ULysNzLPJKkhOCr2Vw@mail.gmail.com> (raw)
In-Reply-To: <83y1ono6rg.fsf@gnu.org>
On Fri, Feb 24, 2023 at 7:35 AM Eli Zaretskii <eliz@gnu.org> wrote:
>
> > From: Stefan Monnier <monnier@iro.umontreal.ca>
> > Cc: Eli Zaretskii <eliz@gnu.org>, dalal.chinmay.0101@gmail.com,
> > emacs-devel@gnu.org, dimitri@belopopsky.com, luangruo@yahoo.com
> > Date: Thu, 23 Feb 2023 20:08:41 -0500
> >
> > Yes and no: yes, there are already cases where the jit-lock-context
> > heuristic of refreshing everything *after* a modification is not
> > sufficient
>
> If a jit-lock client is smart enough, it should itself install an
> after-change function to remove the 'fontified property from the
> portions of buffer text affected by a change that are before the first
> changed position (or maybe even in other buffers).
Thanks, I was going to ask about that. I suppose this is how one
marks sections of a buffer "dirty" or invalidatest them so that
jit-lock knows it must run over them again when it sees fit.
If it works with other buffers as well, it might provide an
elegant solution to the "A affects B" scenario we discussed
earlier.
> > but as a general rule programming languages are designed for
> > "forward-only parsing" so it's unusual for a change at POS to affect the
> > parsing before POS
>
> Strictly speaking, this is inaccurate: a change in the middle of a
> line could very well affect parsing of that entire line, so it in
> effect affects everything from the beginning of that line (perhaps
> even more, if that line is a continued line, in the language syntax).
> But jit-lock is supposed to already account for that, and call the
> fontification-functions with START set to the beginning of the line,
> unless I'm misremembering. (You already know all that, but maybe João
> doesn't.)
Thanks, I think I can confirm this. I've observed this behaviour.
Jit lock starts in the beginning of the line to end of the line
in a small chunk containing the small changed region, only then
proceeds to larger chunks (after some jit-lock-contextual-time,
apparently).
> > > To do this, we use a jit-lock implementation detail,
> > > jit-lock-context-unfontify-pos, which tells us that the contextual
> > > fontification has just finished. Not sure how brittle it is, but it
> > > seems to work reasonably.
> >
> > I think it won't work reliably in the case where the "immediate"
> > jit-lock refresh happens to cover everything until window-end (e.g. we
> > just inserted chunk of text that ends after window-end). In that case
> > the jit-lock-context thingy will just mark the rest of the buffer as
> > "not fresh" but won't call your fontification function at all.
> > [ And of course, there are also those few rare modes that don't use
> > jit-lock-context at all. ]
>
> jit-lock doesn't use window-end. It can't, really: the results of
> fontification could affect where the window ends, which is why
> window-end is only updated when redisplay of a window successfully
> finishes, which is way after jit-lock did its job.
>
> That is why jit-lock calls fontification-functions with END that is
> arbitrarily computed from START; this is controlled by
> jit-lock-chunk-size. And a function called via
> fontification-functions could legitimately decide it fontifies more
> than just the chunk for which it was called.
And Eglot's eglot--update-hints is indeed one such function. The
coalescing of small jit-lock chunks is very "generous" and it will
request inlay hints for things in the middle that jit-lock didn't
strictly think are necessary. This works out well in my testing
with the latest version of the feature installed in emacs-29.
> (Again, you already know all that. I'm writing this to avoid
> potential misunderstandings and confusion.)
Thanks for the clarifications.
João
next prev parent reply other threads:[~2023-02-24 10:42 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <ypi9cz6ahi5n.fsf@gmail.com>
[not found] ` <83edqqaf8c.fsf@gnu.org>
[not found] ` <2B284D77-97DF-4B3E-89FB-13F0CA93D240@gmail.com>
[not found] ` <CALDnm53otfeDQGr0dWWUhxGLTSuiWTstLXJz1HXQgWLiAgsk=A@mail.gmail.com>
[not found] ` <CA+46MXbbW60t=JccgKGX39jTkOu+i=GZhzSQsfnqBUPb-mnJWg@mail.gmail.com>
2023-02-22 19:42 ` Eglot "inlay hints" landed João Távora
2023-02-23 1:45 ` [SPAM UNSURE] " Stephen Leake
2023-02-23 5:29 ` Chinmay Dalal
2023-02-23 6:31 ` Eli Zaretskii
2023-02-23 9:55 ` Chinmay Dalal
2023-02-23 10:03 ` João Távora
2023-02-23 10:55 ` Dimitri Belopopsky
2023-02-23 11:07 ` João Távora
2023-02-23 12:03 ` João Távora
2023-02-23 13:25 ` Dimitri Belopopsky
2023-02-23 11:05 ` Eli Zaretskii
2023-02-23 11:23 ` João Távora
2023-02-23 12:36 ` Eli Zaretskii
2023-02-23 12:57 ` João Távora
2023-02-23 14:48 ` Eli Zaretskii
2023-02-23 16:09 ` João Távora
2023-02-23 17:17 ` Eli Zaretskii
2023-02-23 17:46 ` João Távora
2023-02-23 18:01 ` Eli Zaretskii
2023-02-23 19:26 ` João Távora
2023-02-23 19:54 ` Eli Zaretskii
2023-02-23 20:03 ` João Távora
2023-02-23 19:27 ` Stefan Monnier
2023-02-23 19:39 ` João Távora
2023-02-23 19:53 ` Stefan Monnier
2023-02-23 20:09 ` João Távora
2023-02-23 22:19 ` Stefan Monnier
2023-02-23 23:59 ` João Távora
2023-02-24 1:08 ` Stefan Monnier
2023-02-24 2:28 ` João Távora
2023-02-24 7:35 ` Eli Zaretskii
2023-02-24 10:42 ` João Távora [this message]
2023-02-24 11:33 ` Eli Zaretskii
2023-02-24 12:26 ` João Távora
2023-02-23 10:17 ` Tassilo Horn
2023-02-23 12:55 ` Chinmay Dalal
2023-02-23 19:50 ` Nikola Pajkovsky
2023-02-23 21:35 ` João Távora
2023-02-23 21:45 ` Nikola Pajkovsky
2023-02-24 4:20 ` Chinmay Dalal
2023-02-24 5:04 ` Chinmay Dalal
2023-02-24 9:59 ` João Távora
2023-02-24 11:03 ` Nikola Pajkovsky
2023-02-27 22:50 ` Johann Klähn
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=CALDnm50JOrpvcms6KmtGoyYaJsUsTVN7ULysNzLPJKkhOCr2Vw@mail.gmail.com \
--to=joaotavora@gmail.com \
--cc=dalal.chinmay.0101@gmail.com \
--cc=dimitri@belopopsky.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=luangruo@yahoo.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).