I am trying to view XML files in Emacs, but I am not seeing any font highlighting. The entire document appears as white on black (which is my default font). The following note appears on the EmacsWiki page for nXML:

Note the colorization (font-lock) won’t work if you change the emacs colors.

But there is no additional explanation. I verified that if I start emacs as emacs -Q somefile.xml, I will in fact get font-lock highlighting that works how I would expect. That is, the element tags are displayed in a different color from the element text. Why does font-lock seem to go away when I apply a custom theme?

  • 2
    Perhaps it would help if you describe in detail what the current behavior is and how it is that you'd like to change that behavior, and specify what you have already tried (which did not yield the result you expected and describe what happened instead). The comment you have cited conveys very little meaning -- the comment may have been posted on EmacsWiki by some random person who was not very familiar with Emacs and/or elisp, and it might have been relating to an outdated version of Emacs and the comment would be moot at this point in any event -- in other words, who knows what that means?
    – lawlist
    Commented Jul 14, 2015 at 23:13

1 Answer 1


I found out that the issue was that the nxml faces were inheriting from faces that were not defined in my theme (more accurately, they inherited from the default face) . For example, the face nxml-local-element-face inherits from font-lock-function-name-face, which is set to blue by default, but in my color theme it was set to white. So font-lock was working all along, I just couldn't tell because everything was displaying in the default face.

So the comment on EmacsWiki which I referred to in the question was just a red herring. Customize the face nxml-element-local-name and nxml-text and font-lock should work just fine, even if you are using a custom theme.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.