* font-lock-refresh-defaults
@ 2010-07-15 21:20 Drew Adams
2010-07-22 14:46 ` font-lock-refresh-defaults Stefan Monnier
0 siblings, 1 reply; 3+ messages in thread
From: Drew Adams @ 2010-07-15 21:20 UTC (permalink / raw)
To: Emacs-devel; +Cc: 'Bastian Beischer'
I just got a bug report for my library buff-menu+.el, which adds a few things to
buff-menu.el. The problem was that none of the faces were showing up (except
one), using the latest Emacs source code.
There is no such problem with Emacs 23.2 or with a build as late as 2009-09-11.
I see the problem starting with a build of 2010-05-23 (I have no builds between
those dates).
The buff-menu.el source library is identical (no changes), so the problem does
not come from that code.
The problem goes away if a call to `font-lock-refresh-defaults' is inserted:
(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?)
Why? And exactly when? What changes must users make to their code?
Well, the doc string for the function gives a little guidance, but I looked in
the Emacs and Elisp manuals for more. Nothing. I looked in NEWS. Nothing.
Why the silence about this change? Why not help users by telling them (a) THAT
they may have to do something different to get the same behavior as before and
(b) WHY they now have to do something different.
Why no discussion in emacs-devel before the change - or even after it?
Searching the emacs-devel archives finds thread "Need help with search based
font-locking". This function was added in the middle of that thread. No
attention was brought to this change. Nothing about how this means that you
might need to change your code, that this represents a general font-lock
behavior change.
Isn't some explanation of this feature the least one could expect from those who
make such changes? We might like to understand WHY such a change in existing
code that uses font-locking is now necessary, and under what circumstances.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: font-lock-refresh-defaults
2010-07-15 21:20 font-lock-refresh-defaults Drew Adams
@ 2010-07-22 14:46 ` Stefan Monnier
2010-07-22 15:48 ` font-lock-refresh-defaults Drew Adams
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2010-07-22 14:46 UTC (permalink / raw)
To: Drew Adams; +Cc: 'Bastian Beischer', Emacs-devel
> (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.
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: font-lock-refresh-defaults
2010-07-22 14:46 ` font-lock-refresh-defaults Stefan Monnier
@ 2010-07-22 15:48 ` Drew Adams
0 siblings, 0 replies; 3+ messages in thread
From: Drew Adams @ 2010-07-22 15:48 UTC (permalink / raw)
To: 'Stefan Monnier'; +Cc: 'Bastian Beischer', Emacs-devel
> > (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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-07-22 15:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-15 21:20 font-lock-refresh-defaults Drew Adams
2010-07-22 14:46 ` font-lock-refresh-defaults Stefan Monnier
2010-07-22 15:48 ` font-lock-refresh-defaults Drew Adams
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).