I switched to Emacs 29.1 recently.

I noticed that the tex-verbatim face used in latex-mode to highlight the \href argument has priority on font-lock-comment-face.


The tex-verbatim face is defined in tex-mode.el:

(defface tex-verbatim
  '((t :inherit fixed-pitch-serif))
  "Face used to highlight TeX verbatim environments."
  :group 'tex)

How can I fix this face, in my .emacs file, to make font-lock-comment-face has priority on it?

1 Answer 1


I checked the value of the font-lock-keywords variable and found:

("\\\(ProvidesFile\|href\|nolinkurl\|path\|url\) \(\[[^]]\] \){\(\(?:[^{}\]\|\\.\|{[^}]}\)+\)" 3 'tex-verbatim t)

If I remove the fontification with:

 '(("\\\\\\(ProvidesFile\\|href\\|nolinkurl\\|path\\|url\\) *\\(\\[[^]]*\\] *\\)*{\\(\\(?:[^{}\\]\\|\\\\.\\|{[^}]*}\\)+\\)" 
    3 'tex-verbatim t)))


and run this command to add fontification:

 '(("\\\\\\(ProvidesFile\\|href\\|nolinkurl\\|path\\|url\\) *\\(\\[[^]]*\\] *\\)*{\\(\\(?:[^{}\\]\\|\\\\.\\|{[^}]*}\\)+\\)"
    3 'tex-verbatim keep)))


the problem disappears.

The manual says:

The last two values in subexp-highlighter, override and laxmatch, are optional flags. If override is t, this element can override existing fontification made by previous elements of font-lock-keywords. If it is keep, then each character is fontified if it has not been fontified already by some other element. If it is prepend, the face specified by facespec is added to the beginning of the font-lock-face property. If it is append, the face is added to the end of the font-lock-face property.

So I think that keep should be the right choice.

I submitted a bug report.

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.