[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: highlighting keywords in comments

From: jpkotta
Subject: Re: highlighting keywords in comments
Date: Mon, 7 Mar 2011 08:18:59 -0800 (PST)
User-agent: G2/1.0

On Mar 6, 3:31 pm, Stefan Monnier <address@hidden> wrote:
> > In java-mode (and other cc-modes), I have the following code
> >                    (font-lock-add-keywords
> >                     nil
> >                     '(("\\(FIXME\\|TODO\\)" 1 font-lock-warning-face)))
> > However, this doesn't work on FIXME or TODO words in comments, making it
> > much less useful.  Is there a way for these keywords to be highlighted in
> > font-lock-warning-face, even in comments?
> Check the doc of `font-lock-keywords', especially the OVERRIDE part.
>         Stefan

(defvar warning-words-regexp
  (regexp-opt '("FIXME" "TODO" "BUG" "XXX" "DEBUG") 'words)
  "Regexp matching words that commonly denote something that
  warrants attention in programs.")

(setq warning-words-font-lock-spec
      (cons warning-words-regexp
             0 ;; use whole match
             t ;; OVERRIDE

 'c-mode ;; or nil for current buffer

reply via email to

[Prev in Thread] Current Thread [Next in Thread]