From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Re: cc-mode fontification feels random Date: Mon, 30 Aug 2021 20:03:01 +0000 Message-ID: References: <835yvmka50.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11652"; mail-complaints-to="usenet@ciao.gmane.io" Cc: dancol@dancol.org, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Aug 30 22:04:21 2021 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 1mKnW1-0002n8-3Q for ged-emacs-devel@m.gmane-mx.org; Mon, 30 Aug 2021 22:04:21 +0200 Original-Received: from localhost ([::1]:42400 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mKnVz-0005iH-Hx for ged-emacs-devel@m.gmane-mx.org; Mon, 30 Aug 2021 16:04:19 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60914) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mKnUo-0004xr-RM for emacs-devel@gnu.org; Mon, 30 Aug 2021 16:03:06 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:61507 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.90_1) (envelope-from ) id 1mKnUm-0003RR-I3 for emacs-devel@gnu.org; Mon, 30 Aug 2021 16:03:06 -0400 Original-Received: (qmail 6885 invoked by uid 3782); 30 Aug 2021 20:03:02 -0000 Original-Received: from acm.muc.de (p4fe15b65.dip0.t-ipconnect.de [79.225.91.101]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Mon, 30 Aug 2021 22:03:01 +0200 Original-Received: (qmail 8438 invoked by uid 1000); 30 Aug 2021 20:03:01 -0000 Content-Disposition: inline In-Reply-To: <835yvmka50.fsf@gnu.org> X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de Received-SPF: pass client-ip=193.149.48.1; envelope-from=acm@muc.de; helo=mail.muc.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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" Xref: news.gmane.io gmane.emacs.devel:273548 Archived-At: Hello, Eli. On Mon, Aug 30, 2021 at 22:25:31 +0300, Eli Zaretskii wrote: > > Date: Mon, 30 Aug 2021 18:50:34 +0000 > > From: Alan Mackenzie > > Cc: emacs-devel@gnu.org > > The following patch is an attempt to improve this situation. It is best > > used with jit-stealth-lock enabled. I have tried it out with the > > following settings: > > jit-lock-stealth-load: 200 ; i.e. inactive. > > jit-lock-stealth-nice: 0.1 ; 100 ms between fontifying stealth > > chunks. > > jit-lock-stealth-time: 1 ; 1 second idle time before stealth kicks > > in. > > Whenever a new found type is entered into the CC Mode table, it marks > > all occurrences of the type in the buffer for fontification (by setting > > the 'fontified text property to nil on it), and causes an immediate > > redisplay when there are occurrences of the new type in a window. > So you are saying that this will cause the display of the visible > portion of the window to flicker whenever jit-lock-stealth finds such > a "new type"? There will be a one-time change from no fontification of foo to font-lock-type-face. The actual area of the screen getting refontified is one declaration. > That could annoy, can't it? It might. It didn't annoy me whilst trying it out. The real question is, will it annoy less than having types permanently unfontified. > jit-lock-stealth is for fontifying portions of the buffer(s) that are > not on display, it would be wrong for it to apply this enhancement, I > think, certainly by default. jit-lock has a presumption that the fontification of one part of a buffer doesn't influence the fontification of another part. This isn't the case in CC Mode. My impression is that jit-lock isn't much used. It's disabled by default. What I'm envisaging is repurposing it to solve a real problem. > And jit-lock-stealth-time of 1 sec is too short. I use 16, because > once jit-lock-stealth starts fontifying a chunk, Emacs can be > relatively slow to react to keyboard input, so I prefer to let > jit-lock-stealth start its thing only when there's a very good chance > I indeed stopped typing, not just thinking about something for a > second or two. On my first try this evening with jit-lock, I set jit-lock-stealth-nice to zero. I completely lost control of my session, and hat to abort it and restart. But with the parameters set appropriately, can stealth really make Emacs slow to react? > > I think stealth lock could be enhanced by having it fontify several > > 500-byte chunks together, say until 0.05s time has been taken up. This > > could speed up stealth fontification while still leaving the keyboard > > responsive to the user. > Users can already arrange for that by manipulating the > jit-stealth-lock parameters. I didn't see that this evening. Stealth fontifies one chunk at a time, then waits the "nice" time before fontifying the next chunk. The time for stealth to get through xdisp.c was several minutes, possibly even many minutes. This is unimportant for general background fontification, but more important if using stealth to detect types. > Why should we change code to force upon everyone what seems like a good > idea to you (but isn't a good idea IME, see above)? Well, I was thinking of these enhancements to stealth being more of an option than forced upon people. For example, a new variable jit-lock-stealth-time-block could be nil by default, or set to 0.05 to fontify for 0.05 seconds before attending to user input. 0.05 seconds is enough for about 5 500-byte chunks in CC Mode on my machine. That has the potential to speed up stealth fontification by a factor a little less than 5. > If you want that, you can easily arrange for Emacs to behave like that > without changing any code. I didn't see any way of doing it while looking at the code earlier on. What exactly are you thinking of, here? -- Alan Mackenzie (Nuremberg, Germany).