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: Wed, 8 Oct 2008 17:02:14 -0700 (PDT)
User-agent: G2/1.0

On Oct 8, 2:22 pm, Nikolaj Schumacher <address@hidden> wrote:
> Xah <address@hidden> wrote:
> > 2008-01-13
>
> ??
>
> > After i evaluate the lisp code, i expect, the Sin should be syntax
> > highlighted but is not.
>
> From the doc: "Defaults for Font Lock mode specified by the major mode."
>
> Setting this variable only works when you define a new major mode.  To
> add keywords afterwards, use `font-lock-add-keywords'
>
> > I'm not sure how many level of list is required, or if the nesting is
> > optional...
>
> Using multiple keywords is optional, i.e. you may leave out the two nils
> and one level of parentheses.  Your nesting and quoting is correct.
>
> You might also want to use "\\<Sin\\>" instead of "Sin", etc.
>
> regards,
> Nikolaj Schumacher

Thanks...

am having a headache with this.

;Why does the following works:

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

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

;But in the following, i put my keywords into a var, the value of
myKeywordsLevel1 is just the first element ("Sin\\|Cos" . font-lock-
function-name-face)?

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

  Xah
∑ http://xahlee.org/

reply via email to

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