emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: First fontification of a buffer happens before font lock is fully in


From: Stefan Monnier
Subject: Re: First fontification of a buffer happens before font lock is fully initialised.
Date: Wed, 25 Jan 2012 20:43:48 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

>> > This situation was found and analysed by Hannu Koivisto after CC Mode
>> > crashed for this reason on a C++ buffer.  Why it doesn't happen for
>> > every CC Mode buffer is not yet clear.
>> I think the behavior depends on the use of font-lock-support-mode.
>> With jit-lock, fontification takes place after running the mode-hook,
>> whereas without it, fontification takes place before.
> Surely this cannot be

I'm pretty sure this is the source of the difference.

> the hooks are run at the end of the define-minor-mode expansion no
> matter what.

Yes, but fontification can take place even later, depending on
font-lock-support-mode.

> Surely the hooks are not being run twice.

No, indeed, they should only be run once.

> Though I admit I haven't tracked down the stages in initialising
> jit-lock-mode.

jit-lock postpones fontification to whenever the text is actually
displayed, i.e. much later than initialization; it may very well never
fontify any part of the text at all, if the buffer is never displayed.

> So do you agree that the code should be changed so that
> fontification always happens after running the mode-hook?

Yes, I agree.  This was the behavior in Emacs-20, and is also the
behavior with jit-lock (i.e. the default behavior).  I'm not sure what's
the best way to get that result, tho: adding yet-another keyword to
define-minor-mode is something I'd rather avoid.


        Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]