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: Re: First fontification of a buffer happens before font lock is fully initialised. Date: Wed, 25 Jan 2012 20:22:49 +0000 Message-ID: <20120125202249.GC3624@acm.acm> References: <20120125124804.GB3638@acm.acm> <20120125182651.GA3624@acm.acm> <83vcnzy4c3.fsf@kalahari.s2.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1327523323 31001 80.91.229.12 (25 Jan 2012 20:28:43 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 25 Jan 2012 20:28:43 +0000 (UTC) Cc: Stefan Monnier , emacs-devel@gnu.org To: Hannu Koivisto Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jan 25 21:28:32 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 1Rq9SI-00019i-Js for ged-emacs-devel@m.gmane.org; Wed, 25 Jan 2012 21:28:30 +0100 Original-Received: from localhost ([::1]:47614 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rq9SI-0000aX-5b for ged-emacs-devel@m.gmane.org; Wed, 25 Jan 2012 15:28:30 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:46884) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rq9SF-0000L9-SU for emacs-devel@gnu.org; Wed, 25 Jan 2012 15:28:29 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rq9Mn-0003mJ-6l for emacs-devel@gnu.org; Wed, 25 Jan 2012 15:22:50 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:47816 helo=mail.muc.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rq9Mm-0003m1-Pc for emacs-devel@gnu.org; Wed, 25 Jan 2012 15:22:49 -0500 Original-Received: (qmail 14866 invoked by uid 3782); 25 Jan 2012 20:22:46 -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 21:22:45 +0100 Original-Received: (qmail 4036 invoked by uid 1000); 25 Jan 2012 20:22:49 -0000 Content-Disposition: inline In-Reply-To: <83vcnzy4c3.fsf@kalahari.s2.org> 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:147924 Archived-At: Hi, Hannu. On Wed, Jan 25, 2012 at 09:22:52PM +0200, Hannu Koivisto wrote: > Alan Mackenzie writes: > > On Wed, Jan 25, 2012 at 12:46:04PM -0500, Stefan Monnier wrote: > >> > 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. > Indeed yesterday, after my initial report, I debugged the problem a bit > more and also noticed that it happens with some files but not with > others. It seemed that there was asynchronous behaviour at play that > might explain that but I didn't have time to track why the asynchronity > happened with some files but with others font-lock-mode ended up > calling font-lock-fontify-buffer before running the hooks. It will only happen on the first file (or a initial sequence of files), since it is a global variable not being set which triggered the crash. Looking at lazy-lock.el, there appears to be a minimum size below which lazy-lock won't be active. That size is 25,600 by default. Could it be that files smaller than this cause the crash, files bigger don't? > >> 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. > So do you agree that the code should be changed so that fontification > always happens after running the mode-hook? Yes, absolutely. > > Surely this cannot be - the hooks are run at the end of the > > define-minor-mode expansion no matter what. Surely the hooks are not > > being run twice. Though I admit I haven't tracked down the stages in > > initialising jit-lock-mode. > > Hannu's bug report said nothing about disabling jit-lock, so I presume it > > was enabled. > I didn't talk about my configuration at all because I was hoping to > eventually reproduce the problem starting with emacs -q if my > observation about what I felt was clearly problematic call chain didn't > lead to a fix. My configuration uses lazy-lock. Gladly I can see from > your mail to bug-cc-mode that you have been able to reproduce the > problem with emacs -q and font-lock-support-mode set to nil with small > files. > I'd guess that with lazy-lock it decides to postpone fontification > with some files but not with others. I can't help but wonder why > the problem doesn't occur with all files when > font-lock-support-mode is set to nil. Then again, I don't know > what font-lock-support-mode being nil really means, I'm just > assuming that in that case fontification should never be postponed. Pretty much. > -- > Hannu -- Alan Mackenzie (Nuremberg, Germany).