From: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: rms@gnu.org, emacs-devel@gnu.org
Subject: Re: jit-lock refontifies too much
Date: Thu, 22 Sep 2005 13:37:38 -0400 [thread overview]
Message-ID: <87ll1pvwyl.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <433254BF.8040205@gmx.at> (martin rudalics's message of "Thu, 22 Sep 2005 08:52:47 +0200")
> I'm only comparing Emacs-22.1 jit-lock with my patch. On a 1GHz machine
> setting jit-lock-context-time to zero seconds makes Emacs stutter when I
> use auto-repeat to insert a sequence of characters. Patched, I can set
> this to zero seconds and won't suffer any delays as long as I don't
> insert, for example, a sequence of string delimiters. With faster
> hardware the slowdown might go away. GC overhead stays.
Oh, yes, if you set it to 0s the slowdown will be noticeable, especially in
buffers where the font-lock patterns are complex, such as in C mode or
Perl mode. That's partly why the default is only 0.5s.
>> Wait, I don't even need nested comments, just take C mode:
>>
>> /* sfsgf
>> tryjjy */
>> to
>> //* sfsgf
>> tryjjy */
>>
>> Although in your case jit-lock will round up the "change" to a whole line,
>> so the problem shouldn't bite you in the case of C.
> It does, however. I would have to syntax-ppss the start of the
> following line in order to handle this. Your examples reveal the major
> weakness of my approach. I'm not able to handle changes in the type of
> the first delimiter of a delimited expression as long as the face of an
> enclosed character may stay the same.
Exactly. There may be some other cases, tho. E.g. in elisp-mode, if you
change
(defvar foo 1
"hello")
to
(defvar foo '(1
"hello")
the "hello" needs refontification (from font-lock-doc to font-lock-string).
In the above case, the syntax-ppss state changes, so using that would solve
this problem. But changing
(defvar foo 1
"hello")
to
(defvar foo 0 1
"hello")
also requires a similar refontification, but the syntax-ppss state doesn't
really change, so even using syntax-ppss wouldn't solve this problem.
>> The above problems can be "easily" addressed by changing your algorithm to
>> not look at the face property, but instead to look at the return value of
>> syntax-ppss. If it hasn't changed, then we know the subsequent text doesn't
>> need refontification.
> I don't remember any previous return value when refontifying. Calling
> syntax-ppss twice for the same position in one and the same invocation
> of jit-lock-fontify-now always yields the same value.
Oh, right, when jit-lock-fontify-now gets called, the buffer is already
changed, so you'd have to use a before-change-functions hook to remember the
syntax-ppss state before the change. Hmmm...
Stefan
next prev parent reply other threads:[~2005-09-22 17:37 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 [this message]
2005-09-25 13:17 ` martin rudalics
2005-09-26 23:56 ` Richard M. Stallman
2005-09-27 13:09 ` martin rudalics
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ll1pvwyl.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@gnu.org \
--cc=rms@gnu.org \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).