[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Macro used for dynamic setting of font-lock-keywords
From: |
Sebastian Tennant |
Subject: |
Macro used for dynamic setting of font-lock-keywords |
Date: |
Fri, 25 May 2007 20:24:45 +0300 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.95 (gnu/linux) |
Hi all,
This works:
(defun foo (word)
(display-buffer (set-buffer (get-buffer-create "*bar*")))
(insert (format "baz\n"))
(unless (fboundp 'foo-dynamic-add-keyword) ;only define it once
(defmacro foo-dynamic-add-keyword ()
`(font-lock-add-keywords nil '((,word . font-lock-warning-face)) 'set)))
(foo-dynamic-add-keyword) ;call the macro
(font-lock-mode 1))
(foo "baz")
in that the string argument to foo is added to the buffer's
font-lock-keywords and the string is highlighted wherever it occurs,
but it seems like something of a kludge to me.
Just out of interest really, is there a better way of passing the
value of a variable as an argument to the function
font-lock-add-keywords?
Sebastian
- Macro used for dynamic setting of font-lock-keywords,
Sebastian Tennant <=
- Re: Macro used for dynamic setting of font-lock-keywords, Tim X, 2007/05/26
- Re: Macro used for dynamic setting of font-lock-keywords, Sebastian Tennant, 2007/05/26
- Message not available
- Re: Macro used for dynamic setting of font-lock-keywords, Tim X, 2007/05/26
- Re: Macro used for dynamic setting of font-lock-keywords, Sebastian Tennant, 2007/05/26
- Message not available
- Re: Macro used for dynamic setting of font-lock-keywords, Tim X, 2007/05/26
- Re: Macro used for dynamic setting of font-lock-keywords, Xavier Maillard, 2007/05/27
- Re: Macro used for dynamic setting of font-lock-keywords, Sebastian Tennant, 2007/05/28
- Message not available
- Re: Macro used for dynamic setting of font-lock-keywords, Tim X, 2007/05/28