* fontification-functions called for wrong buffer
@ 2003-11-01 1:02 James Clark
2003-11-02 19:57 ` Stefan Monnier
0 siblings, 1 reply; 2+ messages in thread
From: James Clark @ 2003-11-01 1:02 UTC (permalink / raw)
I have a mode that adds a function to fontification functions. It works
in 21.3 but not with the current CVS version. The problem is that in
the CVS version of emacs, when a buffer X has a function Y in its
fontification-functions variable (which is supposed to be automatically
buffer-local), Y gets called not just when the current buffer is X but
also when the current buffer is a minibuffer or an echo window. I can
easily work around this, but it seems like a bug to me.
If you eval the following, then do M-x my-fontify-start, and then M-x
my-fontify-end, you will see the problem. With 21.3, my-fontifier will
have been called for just one buffer; with the CVS version of emacs, it
will have been called for more than one.
(defvar my-fontified-buffers nil)
(defun my-fontifier (start)
(or (memq (current-buffer) my-fontified-buffers)
(setq my-fontified-buffers
(cons (current-buffer) my-fontified-buffers))))
(defun my-fontify-start ()
(interactive)
(setq my-fontified-buffers nil)
(add-hook 'fontification-functions 'my-fontifier))
(defun my-fontify-end ()
(interactive)
(remove-hook 'fontification-functions 'my-fontifier)
(message "Fontified buffers: %s" my-fontified-buffers))
James
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: fontification-functions called for wrong buffer
2003-11-01 1:02 fontification-functions called for wrong buffer James Clark
@ 2003-11-02 19:57 ` Stefan Monnier
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2003-11-02 19:57 UTC (permalink / raw)
Cc: emacs-devel@gnu.org
> I have a mode that adds a function to fontification functions. It works
> in 21.3 but not with the current CVS version. The problem is that in
> the CVS version of emacs, when a buffer X has a function Y in its
> fontification-functions variable (which is supposed to be automatically
> buffer-local), Y gets called not just when the current buffer is X but
> also when the current buffer is a minibuffer or an echo window. I can
> easily work around this, but it seems like a bug to me.
It's a recently introduced bug in add-hook compounded with sloppy coding on
your part: please pass the `local' argument to add-hook (and remove-hook
as well, of course).
Stefan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-11-02 19:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-01 1:02 fontification-functions called for wrong buffer James Clark
2003-11-02 19:57 ` Stefan Monnier
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).