unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* problem understanding font-lock-defaults structure
@ 2008-10-08 18:46 Xah
  2008-10-08 21:22 ` Nikolaj Schumacher
       [not found] ` <mailman.619.1223500981.25473.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 16+ messages in thread
From: Xah @ 2008-10-08 18:46 UTC (permalink / raw)
  To: help-gnu-emacs

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/^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2008-10-10  0:45 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-08 18:46 problem understanding font-lock-defaults structure Xah
2008-10-08 21:22 ` Nikolaj Schumacher
     [not found] ` <mailman.619.1223500981.25473.help-gnu-emacs@gnu.org>
2008-10-09  0:02   ` Xah
2008-10-09  0:54     ` Lennart Borgman (gmail)
2008-10-09  2:25       ` Kevin Rodgers
     [not found]       ` <mailman.643.1223519147.25473.help-gnu-emacs@gnu.org>
2008-10-09 21:18         ` Xah
2008-10-09 11:13     ` Nikolaj Schumacher
     [not found]     ` <mailman.637.1223513718.25473.help-gnu-emacs@gnu.org>
2008-10-09 15:04       ` Xah
2008-10-09 15:26         ` harven
2008-10-09 17:17           ` Nikolaj Schumacher
     [not found]     ` <mailman.677.1223550826.25473.help-gnu-emacs@gnu.org>
2008-10-09 15:29       ` Xah
2008-10-09 17:16         ` Nikolaj Schumacher
     [not found]         ` <mailman.719.1223572620.25473.help-gnu-emacs@gnu.org>
2008-10-09 21:40           ` Xah
2008-10-09 23:27             ` Nikolaj Schumacher
     [not found]             ` <mailman.739.1223594868.25473.help-gnu-emacs@gnu.org>
2008-10-10  0:20               ` Xah
2008-10-10  0:45             ` Tim X

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