Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Using M-x customize-face RET RET when the cursor is on a type name (this opens the customization of font-lock-type-face) in a c++ code, I managed to make the face of type names bold. Next, when I opened a .tex file, the face of the text of a caption was boldded as well... Seems like the two are sharing something (font-lock-type-face?) in common.

How can I set the font-lock-type-face to have one face when the mode is c++, and another face when the mode is LaTeX?

share|improve this question

1 Answer 1

I don't have the code for tex mode with me now, but yes, it is possible, in fact all too common, IMHO, that the same font-lock face is reused for something quite different. If that is the case here, i.e., if the tex-mode code hard-codes the face it uses as the same face, then you are out of luck (modulo rewriting that code to use a different face).

To see what face is actually used, in your tex-mode buffer, put the cursor on the text in question and hit C-u C-x =. That will display lots of info about the position and character, and near the bottom it will tell you about any text properties, including property face, that are on that character. If it says font-lock-type-face then yes, the same face is used.

If that is not the case, so you see a different face name, then the problem is perhaps only that that face's definition inherits from font-lock-type-face. In that case, you're in luck: just customize that face, whatever it is.

In the out-of-luck case, consider also using M-x report-emacs-bug to suggest that Emacs Dev not simply reuse the same face, font-lock-type-face, but instead they create a tex mode-specific face for this. They can have that face inherit from font-lock-type-face if they want, but they should not just reuse that face. This is my opinion, not necessarily shared by Emacs Dev -- just letting you know.

share|improve this answer
Seems like I'm out of luck :) –  Dror Sep 2 '13 at 11:49
You can trump it with your own defvar | set-face-attribute | font-lock-add-keywords:… For example, I have colorized my own begin/end document in latex-mode to make it stand out better. –  lawlist Sep 2 '13 at 16:05
It should be pretty clear. If the same face is used in the code, you can either (a) change the code (or request that Emacs Dev do that) or (b) change the face appearance here and there, now and again, as @lawlist suggested. There is no miracle here. Faces are not mode-local or buffer-local. You might not like the answer but that's it. Take your pick. But first verify the guesses about the same face being used. If two different faces are used and it's just that one inherits from the other, then there is no problem --- just customize one or the other. –  Drew Sep 5 '13 at 4:33
As far as I can tell the same face is used. See my comment above. –  Dror Sep 6 '13 at 11:37
In that case, either change the code (or request that it be changed in Emacs) or follow @lawlist's suggestion. You say "as far as I can tell". Did you use C-u C-x = as I suggested? That will tell you exactly which faces are used -- no guessing needed. –  Drew Sep 6 '13 at 15:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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