unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Defer jit-lock on a per-buffer basis
@ 2012-11-15  9:29 Tassilo Horn
  2012-11-15 16:55 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Tassilo Horn @ 2012-11-15  9:29 UTC (permalink / raw)
  To: help-gnu-emacs

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




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Defer jit-lock on a per-buffer basis
  2012-11-15  9:29 Defer jit-lock on a per-buffer basis Tassilo Horn
@ 2012-11-15 16:55 ` Eli Zaretskii
  2012-11-15 18:28   ` Tassilo Horn
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2012-11-15 16:55 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Tassilo Horn <tsdh@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.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Defer jit-lock on a per-buffer basis
  2012-11-15 16:55 ` Eli Zaretskii
@ 2012-11-15 18:28   ` Tassilo Horn
  0 siblings, 0 replies; 4+ messages in thread
From: Tassilo Horn @ 2012-11-15 18:28 UTC (permalink / raw)
  To: help-gnu-emacs

Eli Zaretskii <eliz@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




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Defer jit-lock on a per-buffer basis
       [not found] <mailman.13022.1352971819.855.help-gnu-emacs@gnu.org>
@ 2012-11-15 20:38 ` Stefan Monnier
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2012-11-15 20:38 UTC (permalink / raw)
  To: help-gnu-emacs

> 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-11-15 20:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-15  9:29 Defer jit-lock on a per-buffer basis Tassilo Horn
2012-11-15 16:55 ` Eli Zaretskii
2012-11-15 18:28   ` Tassilo Horn
     [not found] <mailman.13022.1352971819.855.help-gnu-emacs@gnu.org>
2012-11-15 20:38 ` Stefan Monnier

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