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

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

problem understanding font-lock-defaults structure


From: Xah
Subject: problem understanding font-lock-defaults structure
Date: Wed, 8 Oct 2008 11:46:33 -0700 (PDT)
User-agent: G2/1.0

2008-01-13

i'm having some problem understanding font-lock-defaults.

For example, i have the following text in a buffer:
------------------------

 Sin[x]^2 + Cos[y]^2 = 1

(setq font-lock-defaults
  '(
    (
      (
        ("Sin\\|Cos" . font-lock-function-name-face)
        ("x\\|y" . font-lock-variable-name-face)
        ("π" . font-lock-constant-face)
      ) ; level 1 fontlock
      nil ; no level 2 of fontlock
      nil ; no level 3 of fontlock
    )
;;     t     ; keywords only
;;     nil     ; case matters
;;     nil   ; no highlighting by syntax
;;     nil   ; no hint on syntax begin for highlighting
   )
)

(font-lock-fontify-buffer)
---------------------------------

After i evaluate the lisp code, i expect, the Sin should be syntax
highlighted but is not.

One thing i find elisp manual on this confusing is exactly what is the
structure of the keyword argument, i.e. the first element of the value
for font-lock-defaults. I'm not sure how many level of list is
required, or if the nesting is optional... The other thing i'm not
sure is perhaps my quoting is not correct?

After several variations, i can't get it to work. Any ideas?

Thanks.

  Xah
∑ http://xahlee.org/

reply via email to

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