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

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

Re: Evaluating a 'variable' in a nested list


From: Tim Johnson
Subject: Re: Evaluating a 'variable' in a nested list
Date: Wed, 21 Apr 2010 16:44:48 -0500
User-agent: slrn/0.9.9p1 (Linux)

On 2010-04-21, Dmitry Dzhus <dima@sphinx.net.ru> wrote:
> Tim Johnson wrote:
<<..>> Incorrectly, so that 'scheme-user-keywords-regexp is being treated 
>> as a function when the hook is run.
>
> By reading docs for `font-lock-add-keywords` function and
> `font-lock-keywords`, you may find out that each element of keywords
> list starts from either regexp or name of function to be called to match
> string for highlighting. Since you've used the quote syntax,
> `scheme-user-keywords` is added into the list of font lock rules as a
> symbol and is then treated as a function name. You may use the
> quasiquote syntax to evaluate just one element of list you use for
> `font-lock-add-keywords`:
 I did find the quasi-quote solution independently, but thank you for
 the explanation above. That explains things quite well.

> (add-hook 'scheme-mode-hook
>           (lambda ()
>             (font-lock-add-keywords 
>               nil 
>               `((,scheme-user-keywords-regexp 0 
>                   scheme-font-lock-user-keywords-face t)))))
>
> So *the value* of `scheme-user-keywords-regexp` gets into the list.
 :)
> Note that since your matcher regular expression has no subexpressions,
> you must use index 0 to highlight the whole matched string; instead, you
> could've just used this:
 And I did arrive at index 0 myself. Your reformatted example below
> (add-hook 'scheme-mode-hook
>    (lambda ()
>       (font-lock-add-keywords 
>        nil 
>         `((,scheme-user-keywords-regexp . ;; Note the dot
>           scheme-font-lock-user-keywords-face)))))
  Ah!  
        Thanks very much

-- 
Tim 
tim@ johnsons-web.com||akwebsoft.com
http://www.akwebsoft.com


reply via email to

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