help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: problem understanding font-lock-defaults structure


From: Xah
Subject: Re: problem understanding font-lock-defaults structure
Date: Thu, 9 Oct 2008 14:40:13 -0700 (PDT)
User-agent: G2/1.0

On Oct 9, 10:16 am, Nikolaj Schumacher <m...@nschum.de> wrote:

> Here's a complete, working example:
>
> (setq myKeywordsLevel1
>  '(("Sin\\|Cos" . font-lock-function-name-face)
>    ("π\\|∞" . font-lock-constant-face)
>    ("x\\|y" . font-lock-variable-name-face)))
>
> (define-derived-mode foo-mode fundamental-mode
>   (setq font-lock-defaults '(myKeywordsLevel1)))
>
> > Its value is
> > (t
> >  (myKeywordsLevel1)
> >  (myKeywordsLevel1
> >   (0 font-lock-keyword-face)))
>
> > Local in buffer untitled<3>;
> > »
>
> > Where did all the extra came from?
>
> The list has been "compiled".  The t marks it as such, so it isn't
> processed twice.  Due to this kind of voodoo, I avoid touching
> `font-lock-keywords'.  I use `font-lock-add-keywords'.

Thanks a lot. That's helpful and much info in this thread.

possibly begging, is it possible to get this to work with using font-
lock-keywords?

Here's what i have now based on all the info in this thread. I
couldn't see where it went wrong.

; Sin[x]^2 + Cos[y]^2 = 1
; π^2/6 == Sum[1/x^2,{x,1,∞}]

(setq myKeywordsLevel1
 (quote
(
   ("Sin\\|Cos" . font-lock-function-name-face)
   ("π\\|∞" . font-lock-constant-face)
   ("x\\|y" . font-lock-variable-name-face)
)
 )
)

(setq font-lock-keywords
 (
 myKeywordsLevel1
 nil
 nil
 )
)

(font-lock-fontify-buffer)

In the “setq font-lock-keywords”, block, i tried various quoting and
nesting but no go.

  Xah
∑ http://xahlee.org/

reply via email to

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