emacs-devel
[Top][All Lists]
Advanced

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

Re: (add-hook 'font-lock-mode-hook ...) keeps adding to font-lock-keywor


From: Klaus Zeitler
Subject: Re: (add-hook 'font-lock-mode-hook ...) keeps adding to font-lock-keywords
Date: Mon, 05 Sep 2005 10:58:49 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (usg-unix-v)

>>>>> "Stefan" == Stefan Monnier <address@hidden> writes:
    Stefan> 
    Stefan> font-lock-mode-hook is called both when turning the mode ON and
    Stefan> when turning the mode OFF.

But I didn't turn it off.

    Stefan> font-lock-keywords should not be modified as you do.  Instead you

Is that documented somewhere. I've seen similar constructs used quite a few
times (e.g. emacs wiki page).

    Stefan> should use font-lock-add-keywords, which knows about
    Stefan> font-lock-compile-keywords.

ok, changed it to:

(defun show-tabs () "Show tabs with a slightly changed background"
   (font-lock-add-keywords nil '(("[\t]+"  (0 'tab-face t)))))
(add-hook 'font-lock-mode-hook 'show-tabs)

and now it looks better, but it still looks a bit odd to me:

(t
 (("[   ]+"
   (0 'tab-face t)))
 ("[    ]+"
  (0 'tab-face t)))

But at least it doesn't get added over and over again.

-- 
 ------------------------------------------
|  Klaus Zeitler      Lucent Technologies  |
|  Email:             address@hidden  |
 ------------------------------------------
---
If a listener nods his head when you're
explaining your program, wake him up.




reply via email to

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