From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: jit-lock-antiblink-grace Date: Sat, 12 Oct 2019 12:34:11 +0300 Message-ID: <834l0enw8c.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="74212"; mail-complaints-to="usenet@blaine.gmane.org" Cc: larsi@gnus.org, cpitclaudel@gmail.com, monnier@iro.umontreal.ca, emacs-devel@gnu.org To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Oct 12 11:35:17 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iJDnw-000JAO-6f for ged-emacs-devel@m.gmane.org; Sat, 12 Oct 2019 11:35:16 +0200 Original-Received: from localhost ([::1]:59796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJDnu-0002pr-VY for ged-emacs-devel@m.gmane.org; Sat, 12 Oct 2019 05:35:15 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60237) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJDn8-00029y-AO for emacs-devel@gnu.org; Sat, 12 Oct 2019 05:34:27 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:35328) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1iJDn7-0007eJ-Se; Sat, 12 Oct 2019 05:34:25 -0400 Original-Received: from [176.228.60.248] (port=1995 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1iJDn4-00017W-Qm; Sat, 12 Oct 2019 05:34:25 -0400 In-reply-to: (message from =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= on Thu, 10 Oct 2019 23:34:25 +0100) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:240906 Archived-At: > From: João Távora > Date: Thu, 10 Oct 2019 23:34:25 +0100 > > A while back I coded up a feature in a scratch branch that > I dubbed the "antiblink". It helps avoid the fontification "blinking" > behaviour observed when creating temporarily unterminated > strings to source code. > > I recall that Lars and Clément tested it with generally positive results. > > At Stefan's request, I have reworked the implementation and > cleaned up the feature, which is embodied in the jit-lock-antiblink-grace > variable and want to land it on master if no-one objects. > > If you want to try it before that happens see the > scratch/jit-lock-antiblink-cleaned-up branch. Bother: this unconditionally adds a post-command-hook, which will necessarily slow down paging through a file. If there's no better solution than using that over-used hook, then at the very least we should give users a way of NOT adding a post-command-hook when this feature is disabled. Some more comments about the code: > +** New customizable variable 'jit-lock-antiblink-grace' This line should end in a period > +Setting this to a positive number of seconds helps avoid the > +fontification "blinking" behaviour observed when adding temporarily > +unterminated strings to source code. If the user has recently created > +an unterminated string at EOL, jit fontification allows this idle > +"grace" period to elapse before deciding it is a multi-line string and > +fontifying the remainder of the buffer accordingly. This should be simplified and shortened. (In general, copy/paste of doc strings into NEWS is not a good idea.) In particular, if the default is to have this behavior (see below), the NEWS entry should tell how to disable that. > +(defcustom jit-lock-antiblink-grace 2 > + "Like `jit-lock-context-time' but for unterminated multiline strings. > +Setting this to a positive number of seconds helps avoid the > +fontification \"blinking\" behaviour observed when adding > +temporarily unterminated strings to source code. If the user has > +recently created an unterminated string at EOL, allow for an idle > +\"grace\" period to elapse before deciding it is a multi-line > +string and fontifying the remainder of the buffer accordingly." > + :type '(number :tag "seconds") > + :group 'jit-lock) This new defcustom should have a :version tag. The doc string should say how to disable the feature. Also, the doc string makes it sound like the default is not a positive number of seconds by default, but it is. (I question the wisdom of making this the default behavior, btw.) I don't understand the "at EOL" part: isn't any unterminated string appear as if it is "at EOL"? > +(defvar jit-lock--antiblink-l-b-p (make-marker) > + "Last line beginning position (l-b-p) after last command (a marker).") > +(defvar jit-lock--antiblink-i-s-o-c nil > + "In string or comment (i-s-o-c) after last command (a boolean).") Please don't use such cryptic variable names, at least not on the file level (preferably also not locally inside functions). > + (add-hook 'post-command-hook 'jit-lock--antiblink-post-command nil t) As mentioned above, this hook should not be added if the feature is disabled. > + (when jit-lock--antiblink-grace-timer > + (message "internal warning: `jit-lock--antiblink-grace-timer' not null")) We should in general avoid calling 'message' here, because such a message will appear after every command, which is a nuisance. Is this really needed? Thanks.