unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Drew Adams <drew.adams@oracle.com>
Cc: emacs-devel@gnu.org
Subject: Re: command to fontify whole buffer?
Date: Thu, 22 Sep 2011 14:33:41 +0000	[thread overview]
Message-ID: <20110922143341.GB3134@acm.acm> (raw)
In-Reply-To: <8BFD7E6B15F149EA96503B2768DFD6C5@us.oracle.com>

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



  reply	other threads:[~2011-09-22 14:33 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-22 13:32 command to fontify whole buffer? Drew Adams
2011-09-22 14:33 ` Alan Mackenzie [this message]
2011-09-22 14:46   ` Lennart Borgman
2011-09-22 15:33     ` Alan Mackenzie
2011-09-22 17:30       ` Dave Abrahams
2011-09-22 22:31         ` Lennart Borgman
2011-09-22 14:56   ` Drew Adams
2011-09-22 15:27     ` Alan Mackenzie
2011-09-22 15:43       ` Drew Adams
2011-09-22 22:34       ` Lennart Borgman
2011-09-25 20:54       ` Nix
2011-09-23  4:23 ` Stefan Monnier
2011-09-23  4:55   ` Jambunathan K

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110922143341.GB3134@acm.acm \
    --to=acm@muc.de \
    --cc=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).