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: command to fontify whole buffer? Date: Thu, 22 Sep 2011 14:33:41 +0000 Message-ID: <20110922143341.GB3134@acm.acm> References: <8BFD7E6B15F149EA96503B2768DFD6C5@us.oracle.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1316702287 5275 80.91.229.12 (22 Sep 2011 14:38:07 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 22 Sep 2011 14:38:07 +0000 (UTC) Cc: emacs-devel@gnu.org To: Drew Adams Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Sep 22 16:38:04 2011 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 1R6kPY-0003Vg-Pb for ged-emacs-devel@m.gmane.org; Thu, 22 Sep 2011 16:38:00 +0200 Original-Received: from localhost ([::1]:56982 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R6kPY-00078w-Aq for ged-emacs-devel@m.gmane.org; Thu, 22 Sep 2011 10:38:00 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:55279) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R6kPQ-00078S-1z for emacs-devel@gnu.org; Thu, 22 Sep 2011 10:37:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R6kPK-0003Tu-AS for emacs-devel@gnu.org; Thu, 22 Sep 2011 10:37:52 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:40587 helo=mail.muc.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R6kPJ-0003TW-V2 for emacs-devel@gnu.org; Thu, 22 Sep 2011 10:37:46 -0400 Original-Received: (qmail 4139 invoked by uid 3782); 22 Sep 2011 14:37:42 -0000 Original-Received: from acm.muc.de (pD9556380.dip.t-dialin.net [217.85.99.128]) by colin.muc.de (tmda-ofmipd) with ESMTP; Thu, 22 Sep 2011 16:37:41 +0200 Original-Received: (qmail 4223 invoked by uid 1000); 22 Sep 2011 14:33:41 -0000 Content-Disposition: inline In-Reply-To: <8BFD7E6B15F149EA96503B2768DFD6C5@us.oracle.com> 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:144190 Archived-At: Hi, Drew. On Thu, Sep 22, 2011 at 06:32:49AM -0700, Drew Adams wrote: > Sometimes I want to fontify a whole buffer (really). One use case is to be able > to then use the fontification for other (e.g. code) purposes than visual > highlighting. But it really doesn't matter why - I just want to. ;-) > With the current lazy/jit fontification, I see no command to do that. > `font-lock-fontify-buffer' doesn't do it. Are you sure? I thought it did, and looking again at the fine source, it does appear to. > Marking the whole buffer and using `(font-lock-fontify-region BEG END)' > doesn't do it. Ditto. > Digging more than a bit, I finally found non-interactive function > `jit-lock-fontify-now', which seems to do the trick. Why not provide a > command that does it? jit-lock-fontify-now just calls the function font-lock-fontify-region (via a hook) which calls font-lock-default-fontify-region (via another hook). > (defun fontify-buffer-completely-no-but-really () > "Yes, really, completely, right now." > (interactive) > (jit-lock-fontify-now)) > Oddly enough, the `jit-lock-fontify-now' doc is no different from the doc of all > the other `fontify' functions that do _not_ really, necessarily fontify > everything they apply to. They all say only that they fontify. The others do > not say that they don't really, necessarily fontify all they apply to. And this > function doesn't say that it is any different from the others. But it seems to > be. A lot of these functions set the 'fontified text property to nil (or 'deferred) with the intention that they get properly fontified later. Most of the time this actually happens. > Another question is whether there is some condition that can be tested to know > whether a buffer has really been completely fontified (whether or not that > fontification is completely up-to-date because of subsequent edits). Text > property `fontified' does not indicate this - is there something that does? Surely 'fontified DOES do it. If it has the value t throughout the buffer, that buffer is fully fontified, otherwise not. Or have I misunderstood something? By the way, I drew a diagram of how jit-lock works about 5 years ago, tracing the functions which call each other, and the hooks out of which things get hoiked. Would you be interested in a copy of it? -- Alan Mackenzie (Nuremberg, Germany).