unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Face specifications in font-lock-keywords (part II).
@ 2005-04-07 10:35 Lute Kamstra
  2005-04-07 11:34 ` Kim F. Storm
  2005-04-07 13:01 ` Stefan Monnier
  0 siblings, 2 replies; 6+ messages in thread
From: Lute Kamstra @ 2005-04-07 10:35 UTC (permalink / raw)


I'm experimenting a bit with font-lock-keywords to test whether the
documentation is correct...

Consider these two types of elements of font-lock-keywords:

  (MATCHER . FACESPEC)
  (MATCHER . (SUBEXP FACESPEC))

and their use in combination with a fancy FACESPEC

  (face FACE)

When I do (setq my-face '(face font-lock-builtin-face)), both types
work fine like this:

  ("oele" . my-face)
  ("oele" . (0 my-face))

However, using the fancy FACESPEC directly like this:

  ("oele" . '(face font-lock-builtin-face))
  ("oele" . (0 '(face font-lock-builtin-face)))

works only in the second case.  Is this a bug?

Lute.

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

* Re: Face specifications in font-lock-keywords (part II).
  2005-04-07 10:35 Face specifications in font-lock-keywords (part II) Lute Kamstra
@ 2005-04-07 11:34 ` Kim F. Storm
  2005-04-07 12:06   ` Lute Kamstra
  2005-04-07 13:01 ` Stefan Monnier
  1 sibling, 1 reply; 6+ messages in thread
From: Kim F. Storm @ 2005-04-07 11:34 UTC (permalink / raw)
  Cc: emacs-devel

Lute Kamstra <Lute.Kamstra.lists@xs4all.nl> writes:

> However, using the fancy FACESPEC directly like this:
>
>   ("oele" . '(face font-lock-builtin-face))
>   ("oele" . (0 '(face font-lock-builtin-face)))
>
> works only in the second case.  Is this a bug?

Does removing the quotes work?

  ("oele" . (face font-lock-builtin-face))
  ("oele" . (0 (face font-lock-builtin-face)))

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

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

* Re: Face specifications in font-lock-keywords (part II).
  2005-04-07 11:34 ` Kim F. Storm
@ 2005-04-07 12:06   ` Lute Kamstra
  0 siblings, 0 replies; 6+ messages in thread
From: Lute Kamstra @ 2005-04-07 12:06 UTC (permalink / raw)
  Cc: emacs-devel

storm@cua.dk (Kim F. Storm) writes:

> Lute Kamstra <Lute.Kamstra.lists@xs4all.nl> writes:
>
>> However, using the fancy FACESPEC directly like this:
>>
>>   ("oele" . '(face font-lock-builtin-face))
>>   ("oele" . (0 '(face font-lock-builtin-face)))
>>
>> works only in the second case.  Is this a bug?
>
> Does removing the quotes work?
>
>   ("oele" . (face font-lock-builtin-face))
>   ("oele" . (0 (face font-lock-builtin-face)))

No.  (I tried.)  I think that Font Lock evaluates FACESPEC and uses
the result.  Maybe it doesn't parse font-lock-keywords correctly so
that it doesn't recognize a FACESPEC in this case:

  ("oele" . '(face font-lock-builtin-face))

Lute.

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

* Re: Face specifications in font-lock-keywords (part II).
  2005-04-07 10:35 Face specifications in font-lock-keywords (part II) Lute Kamstra
  2005-04-07 11:34 ` Kim F. Storm
@ 2005-04-07 13:01 ` Stefan Monnier
  2005-04-07 13:33   ` Lute Kamstra
  1 sibling, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2005-04-07 13:01 UTC (permalink / raw)
  Cc: emacs-devel

> However, using the fancy FACESPEC directly like this:

>   ("oele" . '(face font-lock-builtin-face))
>   ("oele" . (0 '(face font-lock-builtin-face)))

> works only in the second case.  Is this a bug?

Check the value of font-lock-keywords in the buffer after turning font-lock
mode ON (font-lock "compiles" the keywords before using them.  "compiles"
here only means use a canonical format which IIRC would be something like
("oele" (0 font-lock-builtin-face))).


        Stefan

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

* Re: Face specifications in font-lock-keywords (part II).
  2005-04-07 13:01 ` Stefan Monnier
@ 2005-04-07 13:33   ` Lute Kamstra
  2005-04-07 15:32     ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Lute Kamstra @ 2005-04-07 13:33 UTC (permalink / raw)
  Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> However, using the fancy FACESPEC directly like this:
>
>>   ("oele" . '(face font-lock-builtin-face))
>>   ("oele" . (0 '(face font-lock-builtin-face)))
>
>> works only in the second case.  Is this a bug?
>
> Check the value of font-lock-keywords in the buffer after turning font-lock
> mode ON (font-lock "compiles" the keywords before using them.  "compiles"
> here only means use a canonical format which IIRC would be something like
> ("oele" (0 font-lock-builtin-face))).

First case:

font-lock-keywords =>
(t
 (("oele" quote
   (face font-lock-builtin-face)))
 ("oele"
  (face font-lock-builtin-face)))

Second case:

font-lock-keywords =>
(t
 (("oele" 0
   '(face font-lock-builtin-face)))
 ("oele"
  (0
   '(face font-lock-builtin-face))))

Does that mean that Font Lock erroneously strips the quote in the
first case?

Lute.

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

* Re: Face specifications in font-lock-keywords (part II).
  2005-04-07 13:33   ` Lute Kamstra
@ 2005-04-07 15:32     ` Stefan Monnier
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2005-04-07 15:32 UTC (permalink / raw)
  Cc: emacs-devel

> Does that mean that Font Lock erroneously strips the quote in the
> first case?

Looks like it.  And looks like it's done on purpose, although I don't know
what this purpose is:

(defun font-lock-compile-keyword (keyword)
  (cond ((nlistp keyword)			; MATCHER
	 (list keyword '(0 font-lock-keyword-face)))
	((eq (car keyword) 'eval)		; (eval . FORM)
	 (font-lock-compile-keyword (eval (cdr keyword))))
	((eq (car-safe (cdr keyword)) 'quote)	; (MATCHER . 'FORM)
	 ;; If FORM is a FACENAME then quote it.  Otherwise ignore the quote.
	 (if (symbolp (nth 2 keyword))
	     (list (car keyword) (list 0 (cdr keyword)))
	   (font-lock-compile-keyword (cons (car keyword) (nth 2 keyword)))))
	((numberp (cdr keyword))		; (MATCHER . MATCH)
	 (list (car keyword) (list (cdr keyword) 'font-lock-keyword-face)))
	((symbolp (cdr keyword))		; (MATCHER . FACENAME)
	 (list (car keyword) (list 0 (cdr keyword))))
	((nlistp (nth 1 keyword))		; (MATCHER . HIGHLIGHT)
	 (list (car keyword) (cdr keyword)))
	(t					; (MATCHER HIGHLIGHT ...)
	 keyword)))


-- Stefan

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

end of thread, other threads:[~2005-04-07 15:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-07 10:35 Face specifications in font-lock-keywords (part II) Lute Kamstra
2005-04-07 11:34 ` Kim F. Storm
2005-04-07 12:06   ` Lute Kamstra
2005-04-07 13:01 ` Stefan Monnier
2005-04-07 13:33   ` Lute Kamstra
2005-04-07 15:32     ` Stefan Monnier

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