all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "João Távora" <joaotavora@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
	emacs-devel <emacs-devel@gnu.org>
Subject: Re: jit-lock-antiblink-grace
Date: Sat, 12 Oct 2019 11:57:39 +0100	[thread overview]
Message-ID: <CALDnm50EMw-BCKcjRz5eikRuEJW+8zb7h+oELVLvjfpFOZ2hvg@mail.gmail.com> (raw)
In-Reply-To: <834l0enw8c.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 5362 bytes --]

On Sat, Oct 12, 2019 at 10:34 AM Eli Zaretskii <eliz@gnu.org> 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
benchmark.

> 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
enabled/disabled.

> Some more comments about the code:
>
> > +** New customizable variable 'jit-lock-antiblink-grace'
>
> This line should end in a period

OK.

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

OK.

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

João

[-- Attachment #2: Type: text/html, Size: 6209 bytes --]

  reply	other threads:[~2019-10-12 10:57 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-10 22:34 jit-lock-antiblink-grace João Távora
2019-10-11 14:26 ` jit-lock-antiblink-grace Stefan Monnier
2019-10-12  9:34 ` jit-lock-antiblink-grace Eli Zaretskii
2019-10-12 10:57   ` João Távora [this message]
2019-10-12 13:02     ` jit-lock-antiblink-grace Juanma Barranquero
2019-10-12 13:14       ` jit-lock-antiblink-grace João Távora
2019-10-12 14:50         ` jit-lock-antiblink-grace Juanma Barranquero
2019-10-12 15:11           ` jit-lock-antiblink-grace João Távora
2019-10-12 15:30             ` jit-lock-antiblink-grace Juanma Barranquero
2019-10-12 13:32     ` jit-lock-antiblink-grace Eli Zaretskii
2019-10-12 14:13       ` jit-lock-antiblink-grace Stefan Monnier
2019-10-12 14:23         ` jit-lock-antiblink-grace Eli Zaretskii
2019-10-12 14:34           ` jit-lock-antiblink-grace Stefan Monnier
2019-10-12 15:57             ` jit-lock-antiblink-grace Eli Zaretskii
2019-10-12 17:16               ` jit-lock-antiblink-grace Stefan Monnier
2019-10-12 17:50                 ` jit-lock-antiblink-grace Eli Zaretskii
2019-10-12 15:47         ` jit-lock-antiblink-grace Alan Mackenzie
2019-10-12 14:23       ` jit-lock-antiblink-grace João Távora
2019-10-12 16:04         ` jit-lock-antiblink-grace Eli Zaretskii
2019-10-12 21:55           ` jit-lock-antiblink-grace João Távora
2019-10-13  6:39             ` jit-lock-antiblink-grace Eli Zaretskii
2019-10-13  8:47               ` jit-lock-antiblink-grace João Távora
2019-10-13  9:22                 ` jit-lock-antiblink-grace Eli Zaretskii
2019-10-13 10:28                   ` jit-lock-antiblink-grace João Távora
2019-10-13 10:45                     ` jit-lock-antiblink-grace Eli Zaretskii
2019-10-14 23:29                       ` jit-lock-antiblink-grace João Távora
2019-10-15  6:48                         ` jit-lock-antiblink-grace Eli Zaretskii
2019-10-15 18:28                           ` jit-lock-antiblink-grace João Távora
2019-11-24  1:04                             ` jit-lock-antiblink-grace João Távora
2019-11-24 16:16                               ` jit-lock-antiblink-grace Eli Zaretskii
2019-11-25 18:46                                 ` jit-lock-antiblink-grace Alan Mackenzie
2019-11-25 19:02                                   ` jit-lock-antiblink-grace João Távora
2019-11-25 19:26                                     ` jit-lock-antiblink-grace Alan Mackenzie
2019-11-25 19:45                                       ` jit-lock-antiblink-grace João Távora
2019-11-25 20:11                                         ` jit-lock-antiblink-grace Alan Mackenzie
2019-11-25 20:23                                           ` jit-lock-antiblink-grace João Távora
2019-11-25 21:07                                             ` jit-lock-antiblink-grace João Távora
2019-11-26  2:30                                               ` jit-lock-antiblink-grace João Távora
2019-11-26 17:58                                                 ` jit-lock-antiblink-grace Eli Zaretskii
2019-11-30 19:11                                                   ` jit-lock-antiblink-grace João Távora
2019-11-30 19:22                                                     ` jit-lock-antiblink-grace Eli Zaretskii
2019-11-30 20:12                                                       ` jit-lock-antiblink-grace João Távora
2019-11-30 20:16                                                         ` jit-lock-antiblink-grace Eli Zaretskii
2019-11-30 20:19                                                           ` jit-lock-antiblink-grace João Távora
2019-11-30 20:41                                                             ` jit-lock-antiblink-grace Eli Zaretskii
2019-11-30 22:00                                                               ` jit-lock-antiblink-grace João Távora
2019-12-01 18:13                                                                 ` jit-lock-antiblink-grace Eli Zaretskii
2019-12-04 22:45                                                                   ` jit-lock-antiblink-grace João Távora
2019-12-05 15:40                                                                     ` jit-lock-antiblink-grace Eli Zaretskii
2019-11-26 13:43                                           ` jit-lock-antiblink-grace Stefan Monnier
2019-11-25 19:47                                       ` jit-lock-antiblink-grace Dmitry Gutov
2019-11-25 20:03                                         ` jit-lock-antiblink-grace João Távora
2019-10-12 16:14         ` jit-lock-antiblink-grace Alan Mackenzie
2019-10-12 22:26           ` jit-lock-antiblink-grace João Távora
2019-10-13 10:18             ` jit-lock-antiblink-grace Alan Mackenzie
2019-10-13 10:48               ` jit-lock-antiblink-grace João Távora
2019-10-13 12:02 ` jit-lock-antiblink-grace Alan Mackenzie
2019-10-13 19:57   ` jit-lock-antiblink-grace João Távora

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CALDnm50EMw-BCKcjRz5eikRuEJW+8zb7h+oELVLvjfpFOZ2hvg@mail.gmail.com \
    --to=joaotavora@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.