unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* First fontification of a buffer happens before font lock is fully initialised.
@ 2012-01-25 12:48 Alan Mackenzie
  2012-01-25 17:46 ` Stefan Monnier
  0 siblings, 1 reply; 15+ messages in thread
From: Alan Mackenzie @ 2012-01-25 12:48 UTC (permalink / raw)
  To: emacs-devel; +Cc: Hannu Koivisto

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.



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

end of thread, other threads:[~2012-02-23 14:34 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-25 12:48 First fontification of a buffer happens before font lock is fully initialised Alan Mackenzie
2012-01-25 17:46 ` Stefan Monnier
2012-01-25 18:26   ` Alan Mackenzie
2012-01-25 19:22     ` Hannu Koivisto
2012-01-25 20:22       ` Alan Mackenzie
2012-01-26  1:43     ` Stefan Monnier
2012-01-26 10:58       ` Alan Mackenzie
2012-02-04 12:03       ` Alan Mackenzie
2012-02-06  1:39         ` Stefan Monnier
2012-02-07 10:10           ` Alan Mackenzie
2012-02-07 18:02             ` Stefan Monnier
2012-02-08 21:43               ` Alan Mackenzie
2012-02-10 14:27                 ` Stefan Monnier
2012-02-23 11:39                   ` Alan Mackenzie
2012-02-23 14:34                     ` Stefan Monnier

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