unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* How to use non-font-lock face in font-lock-keywords?
@ 2009-12-23 20:31 Tassilo Horn
  2009-12-23 21:14 ` Drew Adams
  0 siblings, 1 reply; 6+ messages in thread
From: Tassilo Horn @ 2009-12-23 20:31 UTC (permalink / raw)
  To: emacs-devel

Hi all,

I have a problem with the specification of faces in font-lock entries.
When I use either

--8<---------------cut here---------------start------------->8---
(defparameter greql-fontlock-keywords-doc
  (let ((regex "foo"))
    (list (list (concat "\\(?:[`]?" regex "['(]\\)")
                1 'font-lock-function-name-face))))
--8<---------------cut here---------------end--------------->8---

or

--8<---------------cut here---------------start------------->8---
(defparameter greql-fontlock-keywords-doc
  (let ((regex "foo))
    (list (list (concat "\\(?:[`]?" regex "['(]\\)")
                1 font-lock-function-name-face))))
--8<---------------cut here---------------end--------------->8---

(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?

Bye,
Tassilo




^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: How to use non-font-lock face in font-lock-keywords?
  2009-12-23 20:31 How to use non-font-lock face in font-lock-keywords? Tassilo Horn
@ 2009-12-23 21:14 ` Drew Adams
  2009-12-23 21:45   ` Tassilo Horn
  0 siblings, 1 reply; 6+ messages in thread
From: Drew Adams @ 2009-12-23 21:14 UTC (permalink / raw)
  To: 'Tassilo Horn', emacs-devel

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





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to use non-font-lock face in font-lock-keywords?
  2009-12-23 21:14 ` Drew Adams
@ 2009-12-23 21:45   ` Tassilo Horn
  2009-12-23 21:50     ` Lennart Borgman
  0 siblings, 1 reply; 6+ messages in thread
From: Tassilo Horn @ 2009-12-23 21:45 UTC (permalink / raw)
  To: Drew Adams; +Cc: emacs-devel

"Drew Adams" <drew.adams@oracle.com> writes:

Hi Drew,

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

You are right, I have to use (quote 'bold), and then it works.

Thanks a ton!
Tassilo




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to use non-font-lock face in font-lock-keywords?
  2009-12-23 21:45   ` Tassilo Horn
@ 2009-12-23 21:50     ` Lennart Borgman
  2009-12-23 21:59       ` Drew Adams
  0 siblings, 1 reply; 6+ messages in thread
From: Lennart Borgman @ 2009-12-23 21:50 UTC (permalink / raw)
  To: Drew Adams, emacs-devel

On Wed, Dec 23, 2009 at 10:45 PM, Tassilo Horn <tassilo@member.fsf.org> wrote:
> "Drew Adams" <drew.adams@oracle.com> writes:
>
> Hi Drew,
>
>>> 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.
>
> You are right, I have to use (quote 'bold), and then it works.


I think Drew said (quote bold).


> Thanks a ton!
> Tassilo
>
>
>




^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: How to use non-font-lock face in font-lock-keywords?
  2009-12-23 21:50     ` Lennart Borgman
@ 2009-12-23 21:59       ` Drew Adams
  2009-12-23 22:08         ` Lennart Borgman
  0 siblings, 1 reply; 6+ messages in thread
From: Drew Adams @ 2009-12-23 21:59 UTC (permalink / raw)
  To: 'Lennart Borgman', emacs-devel

> >> 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.
> >
> > You are right, I have to use (quote 'bold), and then it works.
> 
> 
> I think Drew said (quote bold).

Nope. Tassilo understood correctly. In the source code, you need (quote (quote
bold)), which evaluates to (quote bold). The point is that the face name needs
to be quoted in the result.

I suggested

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

which is equivalent to using (quote (quote bold)) and which produces (quote
bold).





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to use non-font-lock face in font-lock-keywords?
  2009-12-23 21:59       ` Drew Adams
@ 2009-12-23 22:08         ` Lennart Borgman
  0 siblings, 0 replies; 6+ messages in thread
From: Lennart Borgman @ 2009-12-23 22:08 UTC (permalink / raw)
  To: Drew Adams; +Cc: emacs-devel

On Wed, Dec 23, 2009 at 10:59 PM, Drew Adams <drew.adams@oracle.com> wrote:
>> >> 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.
>> >
>> > You are right, I have to use (quote 'bold), and then it works.
>>
>>
>> I think Drew said (quote bold).
>
> Nope. Tassilo understood correctly. In the source code, you need (quote (quote
> bold)), which evaluates to (quote bold). The point is that the face name needs
> to be quoted in the result.
>
> I suggested
>
> `((,(concat "\\(?:[`]?" regex "['(]\\)") 1 'bold))
>
> which is equivalent to using (quote (quote bold)) and which produces (quote
> bold).


I see. Wrong context.




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-12-23 22:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-23 20:31 How to use non-font-lock face in font-lock-keywords? Tassilo Horn
2009-12-23 21:14 ` Drew Adams
2009-12-23 21:45   ` Tassilo Horn
2009-12-23 21:50     ` Lennart Borgman
2009-12-23 21:59       ` Drew Adams
2009-12-23 22:08         ` Lennart Borgman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).