[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
font-lock and text mode
From: |
Oliver Scholz |
Subject: |
font-lock and text mode |
Date: |
Mon, 24 Feb 2003 13:40:01 +0100 |
User-agent: |
Gnus/5.090016 (Oort Gnus v0.16) Emacs/21.3.50 |
I noticed that `hi-lock-mode' doesn't work properly in text mode (CVS
Emacs): after I have added a regexp with `C-x w h', matches already
in the buffer are highlighted, but matching text that I insert after
that is not.
Also it seems to be impossible to add highlighting via
font-lock-keywords to text mode.
(font-lock-add-keywords nil
'(("\\<lirum larum\\>" . font-lock-warning-face)))
I tried a lot to find the reason for this. Finally I tested whether
font-locking works with a derived mode of text-mode.
(defvar test-mode-font-lock-keywords
'(("lirum-larum" . font-lock-warning-face)))
(define-derived-mode test-mode text-mode
"FIXME"
(set (make-local-variable 'font-lock-defaults)
'(test-mode-font-lock-keywords t)))
This is fine. My guess was that this has something to do with the
implementation of `global-font-lock-mode', so I tried to call
`global-font-lock-mode-cmmh' manually, but to no avail. Looking at the
expansion of `define-derived-mode' above and experimenting with it, I
found that `kill-all-local-variables' is critical here. This is enough
to enable font-locking:
(progn (kill-all-local-variables)
(set (make-local-variable 'font-lock-defaults)
'((("\\<lirum-larum\\>" . font-lock-warning-face))
t)))
So I looked at the code of `kill-all-local-variables'. But I can't
find anything there relating to `font-lock' (except the hook
`change-major-modes', but calling `global-font-lock-mode-cmmh' should
amount to the same).
I am puzzled. What am I missing?
Oliver
--
6 Ventôse an 211 de la Révolution
Liberté, Egalité, Fraternité!
- font-lock and text mode,
Oliver Scholz <=