[Top][All Lists]

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

Re: org-mode and mode hooks.

From: Stefan Monnier
Subject: Re: org-mode and mode hooks.
Date: Fri, 27 May 2005 13:15:14 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

> I've run into the same problem in sql-mode; the need to alter the
> font-lock  rules after font-lock-mode has been enabled.  My current
> solution is as follows:

>     ;; Force font lock to reinitialize if it is already on
>     ;; Otherwise, we can wait until it can be started.
>     (when (and (fboundp 'font-lock-mode)
>              (boundp 'font-lock-mode)
>              font-lock-mode)
>       (font-lock-defontify)
>       (font-lock-mode -1)
>       (font-lock-mode 1))

Does this work?  I'm surprised since I don't think any one of those
3 functions resets font-lock-set-defaults.

> The `defontify' seems to be the ticket to get font-lock to recalc its
> settings  and actually reperform the fontification.

Huh?  Actually you probably shouldn't call font-lock-defontify, especially
since you don't seem to understand what it does.

> Stefan, can you confirm that this approach should work?  The docs for `font-
> lock-defontify' certainly imply that this function should do what we are 
> looking for.  Thanks.

I don't think any approach will work except for something like:

  (font-lock-mode -1)
  (kill-local-variable 'font-lock-set-default)
  (font-lock-mode 1)

Although this of course depends a lot on how you change the settings.
The best way (which doesn't mean it's good) to change settings currently is
probably with font-lock-add-keywords.
A simpler alternative is to use a function-matcher so you don't even have to
tell font-lock to update anything, you can instead just change some of the
variables used by your function (this is what I used in sh-script).


reply via email to

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