From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: First fontification of a buffer happens before font lock is fully initialised. Date: Wed, 25 Jan 2012 12:48:04 +0000 Message-ID: <20120125124804.GB3638@acm.acm> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1327495695 12481 80.91.229.12 (25 Jan 2012 12:48:15 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 25 Jan 2012 12:48:15 +0000 (UTC) Cc: Hannu Koivisto To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jan 25 13:48:11 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Rq2Go-0004cG-An for ged-emacs-devel@m.gmane.org; Wed, 25 Jan 2012 13:48:10 +0100 Original-Received: from localhost ([::1]:35899 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rq2Gn-0004uy-RX for ged-emacs-devel@m.gmane.org; Wed, 25 Jan 2012 07:48:09 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:59877) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rq2Gk-0004ui-KL for emacs-devel@gnu.org; Wed, 25 Jan 2012 07:48:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rq2Gj-0005sP-HL for emacs-devel@gnu.org; Wed, 25 Jan 2012 07:48:06 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:49566 helo=mail.muc.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rq2Gj-0005rv-4h for emacs-devel@gnu.org; Wed, 25 Jan 2012 07:48:05 -0500 Original-Received: (qmail 78201 invoked by uid 3782); 25 Jan 2012 12:48:01 -0000 Original-Received: from acm.muc.de (pD9556726.dip.t-dialin.net [217.85.103.38]) by colin.muc.de (tmda-ofmipd) with ESMTP; Wed, 25 Jan 2012 13:47:59 +0100 Original-Received: (qmail 3806 invoked by uid 1000); 25 Jan 2012 12:48:04 -0000 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 193.149.48.1 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:147914 Archived-At: 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.