[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: jit-lock-antiblink-grace

From: João Távora
Subject: Re: jit-lock-antiblink-grace
Date: Sat, 12 Oct 2019 11:57:39 +0100

On Sat, Oct 12, 2019 at 10:34 AM Eli Zaretskii <address@hidden> wrote:
> > 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.  

Everything slows down everything, the question is where and by how much.
A noop will probably not slow paging very much.  Can you tell me more
about the kinds of files you're anxious about and exact meaning of
"paging"?  Is it C-n'ing from the first line to the last?  I could

> If there's no better solution than using that over-used hook,

My very first version relied on an extension of the existing
jit-lock-context-time, but I seem to remember it broke down here and
there sometimes.  I agreed with Stefan (possibly off-list) to use a
post-command-hook, which is safer.  But I can have a look at the
original version and re-study those problems more closely.

> then at the very least we should give users a way of NOT adding a
> post-command-hook when this feature is disabled.

Given that I intend for this to be controlled via a customization
variable, I only see it done via a `:set` hook or something like that.
Or use some hack where the current timers detect the variable has been

> 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.

OK.  Supposing you've already already gotten the idea, I invite you to
submit a suggestion.

> > +(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.)

What's bothering you? (assuming all other objections you stated already
are somehow dealt with satisfactorily.)

> I don't understand the "at EOL" part: isn't any unterminated string
> appear as if it is "at EOL"?

An unterminated string at EOL might be terminated somewhere _after_ EOL,
i.e. a perfectly legitimate (as "in your intentions") multiline string.
Moreover this is a hint as to how the system is implemented, which some
users may appreciate.

> > +(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).

The docstring explains the abbreviation.  I'm afraid that given current
naming practice (prefix, double dash, sub-feature) I couldn't do much
better.  I think jit-lock--antiblink-l-b-p is a better name than
jit-lock--antiblink-pos, or jit-lock--pos, because it makes the reader
"chase" the doc and learn of the exact meaning of the abbreviation.

Do you really prever jit-lock--antiblink-in-string-or-comment and
jit-lock--antiblink-line-beginning-position? I think it's much harder to
follow.  But I will abide, especially if you suggest alternatives.

> > +      (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.

See above.

> > +           (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?

This is an internal consistency check, i.e. a run-time assertion.  It
should never happen, except when the program is buggy.  I had this set
to 'warn', but Stefan suggested I change it.  What do you suggest?
Perhaps I could warn and turn off the feature.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]