all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Add font-lock pattern to all modes in Emacs 22.x
@ 2007-02-22 21:13 Scott Frazer
  2007-02-22 21:28 ` Scott Frazer
  2007-02-23 17:31 ` Stefan Monnier
  0 siblings, 2 replies; 3+ messages in thread
From: Scott Frazer @ 2007-02-22 21:13 UTC (permalink / raw)
  To: help-gnu-emacs

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

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

end of thread, other threads:[~2007-02-23 17:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-22 21:13 Add font-lock pattern to all modes in Emacs 22.x Scott Frazer
2007-02-22 21:28 ` Scott Frazer
2007-02-23 17:31 ` Stefan Monnier

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.