all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org
Subject: Re: jit-lock refontifies too much
Date: Tue, 27 Sep 2005 15:09:39 +0200	[thread overview]
Message-ID: <43394493.6070805@gmx.at> (raw)
In-Reply-To: <E1EK2po-0005ia-F5@fencepost.gnu.org>

 > It would be better just to keep comparing until you reach a line that
 > previously was fontified.  After all, the line that was not fontified
 > before certainly should get fontified, if it is on the screen.  But a
 > subsequent line that was previously fontified may not need to be
 > changed.
 >

This might work for a single window on one and the same buffer.  With
two windows there might remain some unfontified stretch between the
portions shown in the windows.  When I modify text in the first window
and that would affect the context of the second window, the information
might not get through the unfontified area.  On the other hand comparing
until I reach fontified text (or point-max) regardless of whether text
is on screen would be expensive.

 > Since the question is whether there is a realistic case where it would
 > have visible impact.  If nobody really wants to set
 > jit-lock-context-time to zero, that's not a realistic example.
 > So we still don't know whether there is a realistic case where it
 > would have visible impact.

Disciplined users insert/delete both delimiters of comments or strings
simultaneously.  They could profitably set `jit-lock-context-time' to
zero.  I'm too undisciplined.

 >
 > That is why I suggested recording these ppss values in text
 > properties of the first character on a line--so that they would stay
 > around for comparison later.

That would be fine.  But recording these properties for each and every
line fontified would introduce too much overhead.  It would be enough
recording only those things really needed (fields 0, 3, 4, and 7 of
ppss).  In any case this would have to be done for every buffer even if
it isn't modified ever.  A lazy strategy would require some clairvoyance
about which lines would get modified or a before-change-hook anyway.

Saving ppss in text properties at bol would be certainly useful for
font-locking purposes.  But these ppss would usually be invalid and
therefore not useful for other purposes.  And they would have to be
recycled and recalculated after a context change has been detected.

 >
 >     That would be overly expensive.  I rewrote all this with ppss, two
 >     markers, a before-change-functions hook and without any text properties.
 >     It seems to work but needs some further testing.
 >
 > That is interesting.  I would not have expected it to work.

It will "work" until you or Stefan have a closer look at it.

 > However, this would require doing that computation for each change,
 > and that could be rather expensive, right?

For the first in a sequence of changes.  That is, when you enter/delete
a stretch of text I would initially record the ppss for the line begin
following the first character you entered/deleted.  Usually, you then
modify text (a) within 0.5 secs and (b) adjacent to the position of the
last text change.  In such cases I would not record anything for
subsequent modifications.  If you now sit for 0.5 secs, refontification
will be needed iff the syntactic context really changed.

If, within 0.5 secs, you change text on another line I give up.  More
precisely, "change text on another line" means "change text outside the
region enclosed by the markers".  Initially this region ranges from the
begin of the line where a modification starts to the begin of the line
following the end of the modification.  In particular, I give up for
backward-deletions of newlines preceding the start of the region,
indent-region, filling, or replacing all occurrences of some text in a
buffer.  Although, setting `jit-lock-context-time' to zero could avoid
refontification in some of these cases.

 >
 > One advantage for the idea of saving it in a text property for the
 > first character on each line is that it only has to be checked
 > when it is time to refontify.
 >

If "time to refontifiy" means "during `jit-lock-context-fontify'" that's
what I try to do presently.

 > Another possible advantage is: if things are not in sync for the first
 > line after the end of the changed text, it might be in sync on a
 > subsequent line, and that could avoid refontifying most of the lines
 > on the screen.
 >

I can think of two interpretations for "things are not in sync":

1. Buffer text contains something like an unclosed string/comment.  For
    an unclosed comment a subsequent line may "compensate" the error if
    it contains a comment terminator and comments don't nest.  In this
    case one could avoid refontification.  A paren in column zero will
    compensate such errors too.  But in that case correcting an error
    would require that subsequent lines are refontified in order to clear
    the warnings installed by font-lock.  Hence it might be difficult to
    derive a general method.

2. Text on screen has not been yet fontified correctly.  In this case
    "things are not in sync" for `jit-lock-context-time' seconds.  With
    the default settings I would have to get things out of sync and back
    into sync within 0.5 secs.  Doing this within the region enclosed by
    the markers should be handled by my approach.  Changes outside the
    region would indicacte the presence of a skilled user - someone who'd
    probably profit from setting `jit-lock-context-time' to a value less
    than the default.

  reply	other threads:[~2005-09-27 13:09 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-12  6:25 jit-lock refontifies too much martin rudalics
2005-09-12 13:37 ` Stefan Monnier
2005-09-14  5:48   ` martin rudalics
2005-09-14 11:53     ` Stefan Monnier
2005-09-15  5:31       ` martin rudalics
2005-09-20  0:03       ` Richard M. Stallman
2005-09-20 13:53         ` Stefan Monnier
2005-09-21  9:24           ` martin rudalics
2005-09-21 13:34             ` Stefan Monnier
2005-09-22  6:52               ` martin rudalics
2005-09-22 17:37                 ` Stefan Monnier
2005-09-25 13:17                   ` martin rudalics
2005-09-26 23:56                     ` Richard M. Stallman
2005-09-27 13:09                       ` martin rudalics [this message]
2005-09-28 17:10                         ` Richard M. Stallman
2005-10-01  7:34                           ` martin rudalics
2005-10-01 23:25                             ` Richard M. Stallman
2005-10-02 14:53                               ` Stefan Monnier
2005-09-27 15:54                       ` Stefan Monnier
2005-09-28 12:26                         ` martin rudalics
2005-09-28 14:16                           ` Stefan Monnier
2005-09-29  6:29                             ` martin rudalics
2005-09-29 20:25                               ` Stefan Monnier
2005-09-25  2:40             ` Richard M. Stallman

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=43394493.6070805@gmx.at \
    --to=rudalics@gmx.at \
    --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.