[Top][All Lists]

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

Re: Macro used for dynamic setting of font-lock-keywords

From: Kevin Rodgers
Subject: Re: Macro used for dynamic setting of font-lock-keywords
Date: Fri, 01 Jun 2007 21:29:01 -0600
User-agent: Thunderbird (Macintosh/20070509)

Sebastian Tennant wrote:
Quoth Tim X <address@hidden>:
symbol word is getting added to the list. Try this

(defun my-add-keyword (word) (font-lock-add-keywords nil (cons word font-lock-warning-face)) t))

Your function (above) needs an extra cons but now it works:

(defun my-add-keyword (word) (font-lock-add-keywords nil (cons (cons word font-lock-warning-face) '(t))))

You might find this more readable:

(defun my-add-keyword (word)
  (font-lock-add-keywords nil `((,word . ,font-lock-warning-face) t)))

Thanks for pointing out the obvious, although I enjoyed cobbling
together my macro kludge.  I can't believe it didn't occur to me to
use cons.  I suppose it's because I'm thinking macros generally at the
moment, and hell... why use a simple cons or two, when you can write a
complicated macro!

Or a simple backquote :-)

Kevin Rodgers
Denver, Colorado, USA

reply via email to

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