unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
Subject: RE: How to prevent font-lock (& jit-lock etc.) from refontifying?
Date: Wed, 13 Oct 2004 15:07:35 -0700	[thread overview]
Message-ID: <FDELKNEBLPKKDCEBEJCBOEGKCIAA.drew.adams@oracle.com> (raw)
In-Reply-To: <jwv655egvzt.fsf-monnier+gnu.emacs.help@gnu.org>

I guess that's as close as I'll get to what I was looking for.  In this
case, I can use inhibit-modification-hooks, but in general that does more
than just tell font-lock not to refontify; it inhibits all
*-change-functions.

I just wanted to be able to write some code that highlights things
regardless of the buffer mode and regardless of whether font-lock-mode is
on. Yes, the highlighting could be temporary until a buffer change.

Besides using inhibit-modification-hooks, it looks like there is now no way
to tell font-lock not to refontify.  IOW, "you can't get there from here".

Either:

 - the user happens to be using font-lock, in which case you could either
add the highlighting regexps to font-lock-keywords or use font-lock-face

 - or the user doesn't happen to be using font-lock, in which case your code
cannot depend on font-lock to do the highlighting

So, without resorting to inhibit-modification-hooks, it looks like you would
need to test whether font-lock is currently turned on, and use a _different
implementation_ accordingly. That seems absurd.

I guess I may try doing something with overlays.

BTW, what was wrong with the situation before -- where font-lock did its
thing but didn't try to rule the roost, and gave you a way to _prevent it
from refontifying_ -- when you knew it didn't need to refontify (or when you
didn't want it to refontify)?

Previously, function font-lock-after-fontify-buffer did the trick: it would
tell font-lock that the buffer has already been fontified and doesn't need
fontifying (until a buffer change is made).

That function still exists, and it still does the same thing - but only for
fast-lock and lazy-lock fontifying. Here's the code, including a
commented-out part that suggests that someone once had it working for
jit-lock too:

(defun font-lock-after-fontify-buffer ()
  (cond ((and (boundp 'fast-lock-mode) fast-lock-mode)
	 (fast-lock-after-fontify-buffer))
	;; Useless now that jit-lock intercepts font-lock-fontify-buffer.  -sm
	;; (jit-lock-mode
	;;  (jit-lock-after-fontify-buffer))
	((and (boundp 'lazy-lock-mode) lazy-lock-mode)
	 (lazy-lock-after-fontify-buffer))))

Shouldn't this function have the same effect in all font-lock modes,
including jit-lock? Shouldn't it always tell the fontification code not to
do anything until the buffer changes? The comment (yours, I guess) seems to
indicate that this can't be done now (even if it should be done) because
jit-lock intercepts font-lock-fontify-buffer. Does that mean that this
function was neutered because of the way jit-lock happened to be
implemented?

Maybe this function can't do the trick anymore, but don't you think there
should at least be a variable to calm font-lock down (like
inhibit-modification-hooks, but affecting only fontification)?

  - Drew

-----Original Message-----From: Stefan Monnier
just do:   (let ((inhibit-modification-hooks t))
              (put-text-property start end 'face 'toto))

  reply	other threads:[~2004-10-13 22:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.2867.1097623015.2017.help-gnu-emacs@gnu.org>
2004-10-13 21:20 ` How to prevent font-lock (& jit-lock etc.) from refontifying? Stefan Monnier
2004-10-13 22:07   ` Drew Adams [this message]
2004-10-13 22:55     ` Stefan Monnier
     [not found] <mailman.3061.1097688611.2017.help-gnu-emacs@gnu.org>
2004-10-13 18:32 ` Oliver Scholz
2004-10-12 19:51 Drew Adams
2004-10-12 20:27 ` Drew Adams
2004-10-13 10:06 ` Sacha Chua
     [not found] ` <mailman.2950.1097663332.2017.help-gnu-emacs@gnu.org>
2004-10-13 15:23   ` Kevin Rodgers
2004-10-13 17:22     ` Drew Adams

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=FDELKNEBLPKKDCEBEJCBOEGKCIAA.drew.adams@oracle.com \
    --to=drew.adams@oracle.com \
    /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.
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).