Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Defer jit-lock on a per-buffer basis

56 views
Skip to first unread message

Tassilo Horn

unread,
Nov 15, 2012, 4:29:56 AM11/15/12
to help-gn...@gnu.org
Hi all,

recently this blog post

http://tsengf.blogspot.de/2012/11/slow-scrolling-speed-in-emacs.html

suggested to set `jit-lock-defer-time' to some small fraction to defer
jit-lock fontification a bit. This has an enormous effect for example
when scrolling in large c-mode buffers.

However, most of the time I work with buffers that are rather small and
instant fontification is fast enough. There, deferring font-lock is
somewhat distracting.

So is there a way to enable deferred jit-lock on a per-buffer basis?

I tried this:

(defun th-jit-lock-defer-fontification ()
(interactive)
(set (make-local-variable 'jit-lock-defer-time) 0.1)
(font-lock-mode -1)
(font-lock-mode 1))

In fact, when I execute that command, the variable is buffer-local, and
jit-lock is deferred as it should. But it is actually deferred in *all*
buffers! Even disabling and re-enabling font-lock-mode in a buffer that
doesn't have a buffer-local value of `jit-lock-defer-time' doesn't make
fontification instant again...

Any ideas?

Bye,
Tassilo


Eli Zaretskii

unread,
Nov 15, 2012, 11:55:32 AM11/15/12
to help-gn...@gnu.org
> From: Tassilo Horn <ts...@gnu.org>
> Date: Thu, 15 Nov 2012 10:29:56 +0100
>
> recently this blog post
>
> http://tsengf.blogspot.de/2012/11/slow-scrolling-speed-in-emacs.html
>
> suggested to set `jit-lock-defer-time' to some small fraction to defer
> jit-lock fontification a bit. This has an enormous effect for example
> when scrolling in large c-mode buffers.
>
> However, most of the time I work with buffers that are rather small and
> instant fontification is fast enough. There, deferring font-lock is
> somewhat distracting.
>
> So is there a way to enable deferred jit-lock on a per-buffer basis?

Not without rewriting the JIT Lock code, I think. JIT Lock goes over
all of the buffers with the same timers, so any option you customize
will affect all of the buffers.

Tassilo Horn

unread,
Nov 15, 2012, 1:28:05 PM11/15/12
to help-gn...@gnu.org
Eli Zaretskii <el...@gnu.org> writes:

>> So is there a way to enable deferred jit-lock on a per-buffer basis?
>
> Not without rewriting the JIT Lock code, I think. JIT Lock goes over
> all of the buffers with the same timers, so any option you customize
> will affect all of the buffers.

Right, so why not simply making the timers buffer-local, too? I've
tried that

--8<---------------cut here---------------start------------->8---
(defun th-jit-lock-defer-fontification ()
(interactive)
(make-local-variable 'jit-lock-stealth-timer)
(make-local-variable 'jit-lock-stealth-repeat-timer)
(make-local-variable 'jit-lock-context-timer)
(make-local-variable 'jit-lock-defer-timer)
(set (make-local-variable 'jit-lock-defer-time) 0.1)
(font-lock-mode -1)
(font-lock-mode 1))
--8<---------------cut here---------------end--------------->8---

and it seems to work exactly as expected. :-)

Thanks,
Tassilo


Stefan Monnier

unread,
Nov 15, 2012, 3:38:27 PM11/15/12
to
> suggested to set `jit-lock-defer-time' to some small fraction to defer
> jit-lock fontification a bit. This has an enormous effect for example
> when scrolling in large c-mode buffers.

FWIW, you can argue that it's a bug in the c-mode.


Stefan
0 new messages