[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
font-lock-keywords uses only facename
From: |
Alex Schroeder |
Subject: |
font-lock-keywords uses only facename |
Date: |
Fri, 04 Jun 2004 01:48:10 +0200 |
User-agent: |
Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux) |
Today I wrote a very small generic mode for lists of emails.
define-generic-mode's parameter font-lock-list is used to set
font-lock-keywords, eventually.
My problem was that I didn't know that font-lock-keywords doesn't
take faces. It only takes expressions that evaluate to faces.
Therefore, the following font-lock-list doesn't work. Only the
keyword regexp is shown:
(defface mail-list-whitespace '((t (:background "orange"))) "For whitespace.")
(defface mail-list-empty-lines '((t (:background "red"))) "For empty lines.")
(define-generic-mode 'mail-list-mode
nil
nil
'(("address@hidden" . font-lock-keyword-face)
("[ \t]+" . mail-list-whitespace)
("^\n" . mail-list-empty-lines))
'("\\blist\\'")
nil
"Mode used for Minimalist lists: One email per line.")
I must either use variables:
(setq mail-list-whitespace 'mail-list-whitespace)
(setq mail-list-empty-lines 'mail-list-empty-lines)
Or I must use quotes inside the list:
(define-generic-mode 'mail-list-mode
nil
nil
'(("address@hidden" . font-lock-keyword-face)
("[ \t]+" . 'mail-list-whitespace)
("^\n" . 'mail-list-empty-lines))
'("\\blist\\'")
nil
"Mode used for Minimalist lists: One email per line.")
Is this on purpose? Would it break anything if using faces were
allowed directly?
Alex.
--
.O. http://www.emacswiki.org/alex/
..O Schroeder's fourth law:
OOO None of your friends and coworkers share your taste in music.