emacs-devel
[Top][All Lists]
Advanced

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

RE: How to use non-font-lock face in font-lock-keywords?


From: Drew Adams
Subject: RE: How to use non-font-lock face in font-lock-keywords?
Date: Wed, 23 Dec 2009 13:14:41 -0800

> I have a problem with the specification of faces in font-lock entries.
> When I use either
> 
> (defparameter greql-fontlock-keywords-doc
>   (let ((regex "foo"))
>     (list (list (concat "\\(?:[`]?" regex "['(]\\)")
>                 1 'font-lock-function-name-face))))
> or
> (defparameter greql-fontlock-keywords-doc
>   (let ((regex "foo))
>     (list (list (concat "\\(?:[`]?" regex "['(]\\)")
>                 1 font-lock-function-name-face))))
> 
> (the difference is the quoting of f-l-function-name-face) and then use
> this variable as single entry in `font-lock-defaults', it works as
> expected.  But when I use 'bold instead of some font-lock-*-face,
> nothing is fontified.
> 
> I also tried using a FACESPEC (face 'bold), or defined a variable
> greql-doc-face with the value 'bold and used the variable as FACESPEC,
> neither of those did work. :-(
> 
> Why?  What do I need to do to use an arbitrary face?

Without looking closely at your code, my guess is this:

1. `font-lock-function-name-face' is a variable (whose value is the symbol
`font-lock-function-name-face'). There is no variable `bold'.

2. When you use
(list (list (concat "\\(?:[`]?" regex "['(]\\)") 1 'bold))))

you get a list with the face name (symbol), but it is not quoted. Try something
like this instead:

`((,(concat "\\(?:[`]?" regex "['(]\\)") 1 'bold))

IOW, instead of this (for regex=""):
(("\\(?:[`]?['(]\\)" 1 bold))

you want this:
(("\\(?:[`]?['(]\\)" 1 (quote bold)))





reply via email to

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