From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: First fontification of a buffer happens before font lock is fully initialised. Date: Wed, 25 Jan 2012 20:43:48 -0500 Message-ID: References: <20120125124804.GB3638@acm.acm> <20120125182651.GA3624@acm.acm> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1327542241 6964 80.91.229.12 (26 Jan 2012 01:44:01 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 26 Jan 2012 01:44:01 +0000 (UTC) Cc: Hannu Koivisto , emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jan 26 02:43:57 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 1RqENX-0000Zw-2h for ged-emacs-devel@m.gmane.org; Thu, 26 Jan 2012 02:43:55 +0100 Original-Received: from localhost ([::1]:38429 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RqENW-00069J-GJ for ged-emacs-devel@m.gmane.org; Wed, 25 Jan 2012 20:43:54 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:37335) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RqENU-00069E-1C for emacs-devel@gnu.org; Wed, 25 Jan 2012 20:43:52 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RqENS-00033Y-V6 for emacs-devel@gnu.org; Wed, 25 Jan 2012 20:43:51 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:65427) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RqENS-00033U-RM for emacs-devel@gnu.org; Wed, 25 Jan 2012 20:43:50 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EAGKvIE9FpZaC/2dsb2JhbABDrkSBBoFyAQEEAVYeBQULCw4mEhQYDSSID7gbiSsCAQUCBQYWBAIFg1kBCQUQBoM1BIg/mneEVw X-IronPort-AV: E=Sophos;i="4.71,572,1320642000"; d="scan'208";a="159065289" Original-Received: from 69-165-150-130.dsl.teksavvy.com (HELO ceviche.home) ([69.165.150.130]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 25 Jan 2012 20:43:49 -0500 Original-Received: by ceviche.home (Postfix, from userid 20848) id 145D366107; Wed, 25 Jan 2012 20:43:48 -0500 (EST) In-Reply-To: <20120125182651.GA3624@acm.acm> (Alan Mackenzie's message of "Wed, 25 Jan 2012 18:26:51 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 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:147932 Archived-At: >> > 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