From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Harald Kirsch Newsgroups: gmane.emacs.devel Subject: Re: Any expert on font-lock machinery able to provide some insight Date: Fri, 3 Jan 2025 14:57:00 +0100 Message-ID: References: <67d9db0a-ba0f-4164-83fd-796089a6e40b@gmx.de> <86ikqwgldg.fsf@gnu.org> <91114d5a-4af9-4ae1-b7c9-b673e5edf25e@gmx.de> <86cyh4gh0t.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13771"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jan 03 14:57:44 2025 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 1tTiBM-0003Qe-Os for ged-emacs-devel@m.gmane-mx.org; Fri, 03 Jan 2025 14:57:44 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tTiAk-0004Fk-4x; Fri, 03 Jan 2025 08:57:06 -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 1tTiAj-0004Fb-1W for emacs-devel@gnu.org; Fri, 03 Jan 2025 08:57:05 -0500 Original-Received: from mout.gmx.net ([212.227.17.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tTiAg-0000mZ-Vo; Fri, 03 Jan 2025 08:57:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1735912620; x=1736517420; i=pifpafpuf@gmx.de; bh=Xh1lJjMjS1c8cW0xIuG6hv353cVEjZZICpdKW/KnF7k=; h=X-UI-Sender-Class:Message-ID:Date:MIME-Version:Subject:To:Cc: References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=QF9YuFvZqXDVkRnbYJAnPO/wpezrhttBwJrDzuFngfUmp+jCy/w4+uXygXO2xY2N NF2HMFYKgy4qHW3d6q05YyrorTvHsmWALuuCP4sn1RRoO0r1XpCtdlSxLXHfOag4D HfTCkxZft6WAXcJQ2ORUQfnAUuppIo7+rb4bKhnkTdV99IKnSpABKpXRm5ASbA6BK Zfl2ZkraBCwpTtoRL80zxwUOSp0CdL7Q079ZV2rNB7skMNbHDPcaZEOcJgLOZ4a4h ieFZ4CcA7bQu8od2PFi3TJ/yn2RuVZ+kXC4KgR/tZNfSi9cVyb1zlBzh0Y4eKsj8C X7j/IaAcL6kBjFChDA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from [192.168.55.104] ([79.247.82.79]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MFsUp-1tGlCV2nR1-00FxF6; Fri, 03 Jan 2025 14:57:00 +0100 Content-Language: en-US In-Reply-To: <86cyh4gh0t.fsf@gnu.org> X-Provags-ID: V03:K1:oCEEH6KpWnOEQMCgYpxImVsLUMPpm5Mb574r5eClIRN7zP+tCDM X52vSanZTsouvwifFkRHkBVu9trSh24b57plzkIkxy48uak4lN8DUXHGyU3PVDlAxb/1QN5 5NNzycet/qfuJXvEUjfwfGwY9PUJWHfYrlLXPVJkbbtDtYDpxT/NwW2Kg+c+GScwY24mWVn uoRYX0b83mlAYHg7gWfSQ== UI-OutboundReport: notjunk:1;M01:P0:Dudbs43Tdw4=;E0aKdEMNOKYzakWXl2bPsosDAIw G104tiz4opthslXL9fvlz+Blk1rtpdishTeDch1XPaVdI+1bPDrQqpJaqasNDWVRTAkyTZbJk Wep7guaMavQXLH2ohR0X1hUbxQAgAzp7hcCwNcA+wD8fzrEXtf7VK4WrXY7PCqmv7Ine8sqWT ARExnn7BTRqXSt+NcLru6dTRARSYkHWArcSeWjUyBFOmMRSi8+KDgnQbS7t2PA5y6NQQ9za9q ZmZtID7w8PqrsBl2FcrTFUUrikAWquQjNDfayG5SIMsYjCIzVc/qBE1wFDCZwyihkYirvZ05E duX2EUPmhMZVnEmTb5McVYjWjxjE+c3jvWLOmazczVM0JOmgatGxjBjfPHUaml0Ly6jQJVeZl Wjbw1Jx4qtOCANts3I3pjAYq37azwl/GD8Sc+W/rNlTvvsbNyrVhznmn9BFvuY4H5uHZH/6D3 xCg9fk53cXxau9CajLIpRPJWsjM6KOOvb7cUORNvajUKzfmTJn+/uOq7JcckGqTFfFm9VOvzs Q9NUVhUPHvLmJ22GMo3mj1/a+QAEI2E/0acYSwK6F5sE7X/4pRqc266hxa6AGSLQEFDzo1veV D+R5CoIxU3/mPZNS7xov4Pf/q99EeaQRTf65EUc9bERgJ23FQwNLKJ2gmApOuTzNcBtZEsZwM OfutHi9E62h0krwd9AKR678TbeCMidtrhIyd63KTxEsh2K08hIu/AT2KQHXHVXm1XULP+Phbn PW5QWj6ArP3r6NTUS+QwH565RpCNgHOA7qSWsDPayBEaO2Q9mVaUUqzKa7r5wa2fBLxHSbXR Received-SPF: pass client-ip=212.227.17.20; envelope-from=pifpafpuf@gmx.de; helo=mout.gmx.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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:327627 Archived-At: For better research I made a trivial example font lock function and call it, to simulate the async server round-trip, on a timer like so: ;;; -*- lexical-binding: t; -*- (defun eglot-semtok-request-fontification (&optional beg end loudly) (message "front %s-%s" beg end) (run-with-timer 0.1 nil (lambda () (t-eglot-semtok-request-fontification beg end loudly)) ) ) (defun t-eglot-semtok-request-fontification (&optional beg end loudly) (message "timer %s-%s" beg end) (save-excursion (font-lock-unfontify-region beg end) (goto-char beg) (while-let ((mend (re-search-forward "[a-z]+\\(-[a-z]+\\)+" end t)) (mstart (car (match-data))) ) (add-face-text-property mstart mend 'bold) ) )) (setq font-lock-defaults '(nil nil nil nil (font-lock-fontify-region-function . eglot-semtok-request-fontification ) (font-lock-fontify-buffer-function . eglot-semtok-request-fontification ) ) ) - put into text file (easier to override font-lock) - M-x eval-buffer - M-x font-lock-mode - M-x font-lock-mode - insert a space near the top - move cursor See how for each cursor move the same front and timer messages are shown. When configuring the t-... function directly in setq and starting over, the extra font-lock calls are not seen. How would eglot-semtok-request-fontification need to change, short of actually fontifying everything, to lure font-locking into thinking all is fine, no need to run again shortly after? Harald. On 03.01.25 14:32, Eli Zaretskii wrote: > [Please use Reply All, to keep the list CC'ed.] > >> Date: Fri, 3 Jan 2025 13:44:04 +0100 >> From: Harald Kirsch >> >> Hi Eli, >> >> thanks for the explanation. >> >> On 03.01.25 12:58, Eli Zaretskii wrote: >> ... >>>> But it seems I am missing another channel of information which trigge= rs >>>> font-locking too often. >>> >>> Why does it bother you that it happens too often? >> >> 1. I compare with elisp font-locking which is much less frequent. >> >> 2. It is eglot-semtok, which does an LSP server call to get font-lock >> information. It is quick enough and I wouldn't have noticed without the >> logging, but it seems a waste nevertheless. >> >>>> With describe-char I do see >>>> >>>> There are text properties here: >>>> fontified defer >>>> >>>> not going away. Can this point to the problem? >>> >>> This should only happen with buffer positions that were not yet >>> fontified. If the buffer position was already fontified, the value >>> should be t. >> >> The buffer position was already fontified, so I should not see this. I >> might be doing something wrong so that the font-lock machinery thinks, >> font-locking did not happen. The actual fontification happens >> asynchronously (due to the server roundtrip), but I thought I had given >> the engine enough info pretending all is done. I don't fully understand= , >> how the decision is made to fontify again. >> >> Cheers >> Harald >>