emacs-devel
[Top][All Lists]
Advanced

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

Re: org-mode and mode hooks.


From: Michael Mauger
Subject: Re: org-mode and mode hooks.
Date: Fri, 27 May 2005 14:49:37 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Luc Teirlinck <teirllm <at> dms.auburn.edu> writes:

> 
> Stefan Monnier wrote:
> 
>    Can you explain the change?
>    I really don't like the
> 
>      (defun turn-on-font-lock-as-appropriate ()
>        (let (font-lock-set-defaults)
>        (turn-on-font-lock-if-enabled)))
> 
>    since it may cause font-lock-keywords to be reset from font-lock-defaults,
>    thus throwing away keywords added via font-lock-add-keywords since.
> 
> The problem that binding font-lock-defaults to nil tries to solve is
> that (with org-mode's yesterday's version), after font-lock was turned
> on in outline-mode, I could not get it correct for org-mode by
> disabling and enabling font-lock-mode, font-lock just kept using
> outline-mode's font-lock settings.  

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))

The `defontify' seems to be the ticket to get font-lock to recalc its settings 
and actually reperform the fontification.  My original solution used internals 
from font-lock that were not version stable.

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.

-- Michael





reply via email to

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