emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: font-lock-refresh-defaults


From: Drew Adams
Subject: RE: font-lock-refresh-defaults
Date: Thu, 22 Jul 2010 08:48:52 -0700

> > (defun Buffer-menu-fontify-and-adjust-frame ()
> >   "Use for `buffer-menu-mode-hook'.  Fontify, fit and raise frame."
> >   (save-window-excursion
> >     (save-excursion
> >       (pop-to-buffer "*Buffer List*")
> >       (when (< emacs-major-version 21)
> >         (make-local-variable 'font-lock-defaults))
> >       (setq font-lock-defaults 
> >             '(buffer-menu-font-lock-keywords t))
> >       (when (fboundp 'font-lock-refresh-defaults)
> >         (font-lock-refresh-defaults)) ; WHY NEEDED NOW?
> >       (turn-on-font-lock)
> >       (when (and (fboundp 'fit-frame) (one-window-p t))
> >         (fit-frame))
> >       (raise-frame))))
> 
> > OK, so Emacs has apparently changed something about font-locking, so
> > now you must refresh whenever you change the font-lock defaults.
> > (Whenever?  Or maybe only sometimes when you change the defaults?)
> 
> I think that's pretty much always been necessary (as a general rule),
> tho if the change is made before font-lock gets initialized, then of
> course, there's nothing to refresh and the refresh is not needed, but
> "when font-lock is initialized" is something that can depend on
> *many* things.

I won't argue that one has not sometimes had to refresh the defaults.  I will
say that the above code (without the call to `font-lock-refresh-defaults'),
which is pretty simple, works fine in all previous Emacs releases.  (And I also
initialize font-lock prior to that code.)

(And I repeat that the relevant context - the buff-menu.el code - did not change
at all.  It is there that someone will naturally look first for a change, to try
to understand why things suddenly no longer work.)

Refreshing might have been _theoretically_ necessary in the past as well, as you
suggest, but it was not very often needed in practice, AFAICT.

Anyway, `font-lock-refresh-defaults' did not even exist prior to Emacs 23.2.
(And as I said before, the above code code, without f-l-r-d, works even in Emacs
23.2.)

If this requirement to refresh has always been present (even if I didn't notice
the need in practice), how did people refresh the defaults previously, without
f-l-r-d?  Can you point me to some pre-f-l-r-d source code that actually does
it?

I repeat that _something_ has apparently changed wrt font-locking, so that you
must now refresh whenever (?) you change the defaults, or at least in more (or
different) contexts than previously.


And I repeat the main questions:

Why the change?
Just when do you now need to refresh, in practice (guidelines)?

Why is there nothing about this change in NEWS?
And nothing about when to use f-l-r-d in the Elisp manual?

IOW, it seems that this need to refresh is felt more now than before, yet there
is nothing guiding programmers about this.  There is not even any mention of the
(new) function you must call to satisfy the need (f-l-r-d).

How about a little insight into this change?  What's it all about?  Thx.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]