7

What is the root mode I need to hook to highlight TODOs in Ruby, Lisp, and C-like languages. I tried the following, but it doesn't highlight TODO in Ruby or Lisp:

(defun highlight-todos (font-lock-add-keywords nil
             '(("\\<\\(FIXME\\|TODO\\|BUG\\):" 1 font-lock-warning-face t))))
(add-hook 'text-mode-hook 'highlight-todos)
Drew
  • 29,895
  • 7
  • 74
  • 104
Natan Yellin
  • 6,063
  • 5
  • 38
  • 57
  • 1
    The likely problem with this code is that the TODOs lie within comment regions, and comments are typically identified and fontified using the syntax tables for the active mode; your font-lock keywords don't get chance to be applied, because the region has already been marked as a comment. – sanityinc Dec 18 '11 at 14:48
  • 2
    possible duplicate of [Emacs: highlighting TODO *only* in comments](http://stackoverflow.com/questions/2367611/emacs-highlighting-todo-only-in-comments) – sanityinc Dec 18 '11 at 14:50

1 Answers1

6

I think to get it to all programming modes to work use prog-mode-hook

(add-hook 'prog-mode-hook 'highlight-todos)
kindahero
  • 5,817
  • 3
  • 25
  • 32