From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Newsgroups: gmane.emacs.devel Subject: Re: Eglot "inlay hints" landed Date: Fri, 24 Feb 2023 10:42:26 +0000 Message-ID: References: <87356xv65z.fsf_-_@gmail.com> <83fsawriye.fsf@gnu.org> <835ybsr6aa.fsf@gnu.org> <83356wr224.fsf@gnu.org> <87bklktu89.fsf@gmail.com> <83y1oophd0.fsf@gnu.org> <83k008pah3.fsf@gnu.org> <83y1ono6rg.fsf@gnu.org> Mime-Version: 1.0 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="15990"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Monnier , dalal.chinmay.0101@gmail.com, emacs-devel@gnu.org, dimitri@belopopsky.com, luangruo@yahoo.com To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Feb 24 11:43:21 2023 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 1pVVXt-0003xM-7M for ged-emacs-devel@m.gmane-mx.org; Fri, 24 Feb 2023 11:43:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVVXI-0001vH-RZ; Fri, 24 Feb 2023 05:42:44 -0500 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 1pVVXG-0001ut-FQ for emacs-devel@gnu.org; Fri, 24 Feb 2023 05:42:42 -0500 Original-Received: from mail-oi1-x232.google.com ([2607:f8b0:4864:20::232]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVVXE-0006eq-Lk; Fri, 24 Feb 2023 05:42:42 -0500 Original-Received: by mail-oi1-x232.google.com with SMTP id bg11so15495934oib.5; Fri, 24 Feb 2023 02:42:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1677235358; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=vjPZepaNk6K8KfYaMuwevxZngba4AIDw4W7Gzy0L+9Q=; b=l5XcTzszYrC3V9oOTbCRaNIfLtVKss+M5BAEGjwNMBbKURYDuAVVwZZPfc4r8Ch5iR pCwVLfSMMLy8WfdW9J5N/kF6BNP6Vu6SCF8ZryBMznraI2nYQtDMdm20xpzrUsjtskgj MwemqmX1G+qDKd0GNXe+fW63oFd1pQXNJjrdOYgmF2BMDKx0MmbXVVHCaJb6DBN2gtY0 QMLVUyMsBZeY/hyHOR0/11t0XzYEZXbRBzyECBu97h8XVQxnrj5kQiWSfrVFO3lFE+oR JBIf4oo2rl9lyX4cBmyWsnlwHiB8AV1Nq9aaenllx4fl3yRI9c4DOMMglx/HNtxvEDnw XlnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677235358; h=content-transfer-encoding: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=vjPZepaNk6K8KfYaMuwevxZngba4AIDw4W7Gzy0L+9Q=; b=T34mYoCbMSRm8/EhhiHhKnC/iWrNoiCkHZdk9Z3jZOKmkCJ/GEMd83sZNoCY9f/5nu NSoysXzKh0O4BF8bKzoeUq+g4hnnFvq76yminibnSnYdbJP+LAT8n4icoAC09ytgpFI8 Gh9dl2sSgxeYglX9ez16wjoGVm250rMwmS3+8AHl4DaWKriSg+HLugWjyTflsZ2tutnP LnoB71kw7OlFJVP5r5mgCg75etZOLBRKPpmEw2Zy/05ELfCKNoex7TVAz/DQrQ8M26RB qdrlSnRzLgiF7e9YxRb2XbJAHbNsnO8BWk0pqAjedZJVVn2Krg+7MKdj/CxwyrOk8e66 ulnA== X-Gm-Message-State: AO0yUKXGkQPTDxs20vSbANl5/iYs1c7gx7OnE+Y/+omqw4JaA+XCaNrZ Ro4n4wM9VQsP0CW9xyshqc6h4LaxBniWUWIkB88+DplG X-Google-Smtp-Source: AK7set+p5p31ZwzY8nQKnAuo2umjgvrdv2TadK7jKrUEF6HWEU2W8F6wtKxWT/ddMXzqPiq2R2j6xU8b7WJd4HQzgKg= X-Received: by 2002:aca:1a06:0:b0:383:e304:34cd with SMTP id a6-20020aca1a06000000b00383e30434cdmr967839oia.8.1677235357188; Fri, 24 Feb 2023 02:42:37 -0800 (PST) In-Reply-To: <83y1ono6rg.fsf@gnu.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::232; envelope-from=joaotavora@gmail.com; helo=mail-oi1-x232.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.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, FREEMAIL_REPLY=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:303745 Archived-At: On Fri, Feb 24, 2023 at 7:35 AM Eli Zaretskii wrote: > > > From: Stefan Monnier > > Cc: Eli Zaretskii , 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 th= e > > 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=C3= =A3o > 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=C3=A3o