In c-mode, I would like all lines beginning with
to have that expression grey and the rest of the line in the default face. How might I achieve that?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.Sign up to join this community
The following will do something similar to what you asked for.
(let ((re "^[ ]*\\(exec sql\\)\\(.*\\)$")) (font-lock-add-keywords 'c-mode `((,re 1 font-lock-preprocessor-face t))) (font-lock-add-keywords 'c-mode `((,re 2 font-lock-string-face t))))
The numbers represent subexpression matches, and the
t mean that already present fontification should be overridden. Have a look at the documentation of