Highlighting TODOs in all programming modes
Asked Answered
U

1

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)
Ulterior answered 18/12, 2011 at 11:9 Comment(2)
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.Solfatara
possible duplicate of Emacs: highlighting TODO only in commentsSolfatara
F
6

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

(add-hook 'prog-mode-hook 'highlight-todos)
Fabliau answered 19/12, 2011 at 0:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.