From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Eglot "inlay hints" landed Date: Thu, 23 Feb 2023 20:08:41 -0500 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> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29368"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eli Zaretskii , dalal.chinmay.0101@gmail.com, emacs-devel@gnu.org, dimitri@belopopsky.com, luangruo@yahoo.com To: =?windows-1252?B?Sm/jbyBU4XZvcmE=?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Feb 24 02:09:33 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 1pVMaa-0007PK-Ad for ged-emacs-devel@m.gmane-mx.org; Fri, 24 Feb 2023 02:09:32 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVMa1-0008EK-PX; Thu, 23 Feb 2023 20:08:57 -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 1pVMZz-0008Dq-D0 for emacs-devel@gnu.org; Thu, 23 Feb 2023 20:08:55 -0500 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 1pVMZx-0000VI-8G; Thu, 23 Feb 2023 20:08:55 -0500 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 8F00A1000C4; Thu, 23 Feb 2023 20:08:50 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id EFA9F100048; Thu, 23 Feb 2023 20:08:48 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1677200929; bh=DdAWlg0C/uogLx3WPSPwpRTxI9aLoljQs3o8UCrbzKU=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=RsQcuhiTy83AWPEkx7tTWGYBhlD4Tbu9cwocbcIdlnQ3hhMq4LQqmxbevERakQyt1 HawgBXA2PB3Dxp83wVlW1V5A22O2mwfdGIeXFsHJQRTMAWBdFhm67aY3kyhv8HCpLv NtEaxMzWBuwH/sOzCi/00QpnHyYZrvxXle4RQkOQil7CoG3KsUO+z6CiTORW2W2Q9g waDgU53/dv7qTinzkhsgulsEO3hrTAPLysp5yNeKCorEb8Q6ZkJQEi0KHiABQc6xzS +hA5HONnKxmVi0js/HYgpTiw4XZfutOWVQpXWBL6DNU+lx1LpbLSpcL7dLUnzzsGVc Xqx+J23+z/4TA== Original-Received: from pastel (unknown [216.154.34.24]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 8AECF1231E3; Thu, 23 Feb 2023 20:08:48 -0500 (EST) In-Reply-To: (=?windows-1252?Q?=22Jo=E3o_T=E1vora=22's?= message of "Thu, 23 Feb 2023 23:59:42 +0000") 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 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: , 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:303730 Archived-At: >> Also, I'm not sure it gives exactly the info you need/want: >> I suspect that in some languages you can have: >> >> foo (x) >> ... >> function foo (bar : Int) > > Yeah, in that case we're frobbed. But isn't that a problem already > those "some languages" for regular "contextual" fontification? Yes and no: yes, there are already cases where the jit-lock-context heuristic of refreshing everything *after* a modification is not sufficient, 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 (and most uses of jit-lock limit themselves to syntactic information, so there are rather few cases where this is a problem). In those few cases we use things like the `jit-lock-defer-multiline` property which the major mode's font-lock rules can place manually in an ad-hoc manner. In your case, I suspect for the affected language servers there's not much more we can do but to say that the whole buffer's inlays need to be recomputed after a change. > 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. ] I think using your own timer is probably the better option. I'd make it wait for `eglot-lazy-inlay-hints` rather than (+ eglot-lazy-inlay-hints jit-lock-context-time), but I'd give it as default value a value computed from `jit-lock-context-time`. Stefan