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: Lennart Borgman (gmail)
Subject: Re: problem understanding font-lock-defaults structure
Date: Thu, 09 Oct 2008 02:54:10 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071031 Thunderbird/2.0.0.9 Mnenhy/0.7.5.666

Xah wrote:
> On Oct 8, 2:22 pm, Nikolaj Schumacher <m...@nschum.de> wrote:
>> Xah <xah...@gmail.com> 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)
>  )
> )

Could it be that the `quote' just takes one argument?

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