emacs-devel
[Top][All Lists]
Advanced

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

First fontification of a buffer happens before font lock is fully initia


From: Alan Mackenzie
Subject: First fontification of a buffer happens before font lock is fully initialised.
Date: Wed, 25 Jan 2012 12:48:04 +0000
User-agent: Mutt/1.5.21 (2010-09-15)

Hi, Emacs.

(define-minor-mode font-lock-mode ....), calls
  font-lock-default-function   which calls
  font-lock-mode-internal      which calls
  font-lock-fontify-buffer.

This call of f-l-fontify-buffer happens before font-lock-mode-hook is
run, since the defined-minor-mode runs the hook as the _very_ last
thing.  Thus the buffer's f-l-stuff is potentially not fully initialised
at this first call of f-l-fontify-buffer.

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.

Suggested fix:
(i) Amend define-minor-mode to have an extra parameter :run-hooks with
  default t.
(ii) Set it to nil for f-l-mode, and explicitly write the hook run in
  the appropriate place.

Incidentally, XEmacs does run this hook in the correct place.

-- 
Alan Mackenzie (Nuremberg, Germany.



reply via email to

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