My font-lock-warning-face has a red color. Which works well in almost all circumstances, it is very pronounced.

The problem is, my font-lock-string-face has orange color. So warnings inside strings are hardly visible, because orange is similar to red. For example, it is hard to notice a regexp problem around \.

Is it possible to have a different foreground color in font-lock-warning-face, if the warning is inside a string?

Look at this screen shot, here the \ has a different color, which is hardly noticable. I'd like to use a very different warning color (maybe a red background color) in this case (I don't want to change my string color, neither my global warning color).


  • What major-mode (and/or minor-mode, if applicable) are you using that generates the warning relating to the backslash that is the subject of your question? E.g., lisp-interaction-mode; or, perhaps emacs-lisp-mode? The solution may need to be custom tailored to that major-mode and/or minor-mode (if applicable).
    – lawlist
    Jul 19, 2020 at 22:58
  • @lawlist: currently this is an issue in emacs-lisp-mode. But if I manage to get a solution, I may extend this to c-mode, for example (like marking invalid escape sequences, format specifiers in strings).
    – geza
    Jul 19, 2020 at 23:34


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.