[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Add font-lock pattern to all modes in Emacs 22.x
From: |
Scott Frazer |
Subject: |
Add font-lock pattern to all modes in Emacs 22.x |
Date: |
22 Feb 2007 13:13:22 -0800 |
User-agent: |
G2/1.0 |
I'd like to add a font-lock pattern that will show up in all modes.
It highlights TODO/FIXME strings in comments only ... here's what I
have that works in Emacs 21.x:
(custom-set-faces
'(my-todo-face ((((class color)) (:weight bold :foreground
"firebrick2" :background "yellow"))) t))
(defun my-font-lock-mode-hook ()
(font-lock-add-keywords
nil
(list (cons (concat "^.*" (replace-regexp-in-string "[ \t]+$" ""
comment-start)
".*?\\(TODO\\|todo\\|Todo\\|FIXME\\|fixme\\|
Fixme\\)")
(list '(1 'my-todo-face t))))
'add-to-end))
(add-hook 'font-lock-mode-hook 'my-font-lock-mode-hook)
Yeah, yeah, it won't work in the middle of multi-line comments, but
does for 99% of cases I usually see. As I said, it works in 21.x, but
in 22.x it seems like comment-start may not be set before font-lock-
mode-hook gets run. If I run the function after the mode has been
loaded, it's fine. I'm running Emacs under WinXP if that matters ...
Scott
- Add font-lock pattern to all modes in Emacs 22.x,
Scott Frazer <=