all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Macro used for dynamic setting of font-lock-keywords
@ 2007-05-25 17:24 Sebastian Tennant
  0 siblings, 0 replies; 14+ messages in thread
From: Sebastian Tennant @ 2007-05-25 17:24 UTC (permalink / raw)
  To: help-gnu-emacs

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2007-06-10  0:51 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.1240.1180113798.32220.help-gnu-emacs@gnu.org>
2007-05-26  8:20 ` Macro used for dynamic setting of font-lock-keywords Tim X
2007-05-26 10:40   ` Sebastian Tennant
     [not found]   ` <mailman.1274.1180175941.32220.help-gnu-emacs@gnu.org>
2007-05-26 15:23     ` Tim X
2007-05-26 20:07       ` Sebastian Tennant
2007-06-02  3:29         ` Kevin Rodgers
     [not found]       ` <mailman.1303.1180209955.32220.help-gnu-emacs@gnu.org>
2007-05-27  3:30         ` Tim X
2007-05-27 21:45           ` Xavier Maillard
2007-05-28  9:22             ` Sebastian Tennant
2007-06-02  3:41               ` Kevin Rodgers
2007-06-02  7:26                 ` Eli Zaretskii
2007-06-03  9:39                 ` Sebastian Tennant
     [not found]           ` <mailman.1339.1180303291.32220.help-gnu-emacs@gnu.org>
2007-05-28  8:37             ` Tim X
2007-06-10  0:51 ` Stefan Monnier
2007-05-25 17:24 Sebastian Tennant

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.