Is there a way to prevent font-locking from changing the font family (and change color only)?

917 views Asked by At

Admittedly, this is something of a first world problem, but I'm sort of picky about the appearance of the display, and I find it really annoying when some mode sets a new font size, family, bold/italic, etc. What I'd like to do is put (set-frame-font "Menlo-10") near the top of my .emacs, and then force emacs to never change any aspect from that default font except for color.

I can sort of get the effect I want by doing something like this:

(mapc (lambda (face) 
    (set-face-attribute face nil
                        :family "Menlo"
                        ;; something like (cdr (assoc 'font (frame-parameters)) would be better
                        ;; for the :family, but it didn't immediately work
                        :width 'normal
                        :height 1.0
                        :weight 'normal 
                        :underline nil
                        :slant 'normal))
    (remove 'default (face-list)))

but that only works after I've loaded a new buffer that has created font-lock faces to be changed, and it's a dreadful hack regardless. I suspect there just isn't really in facility in font-locking for ignoring some parts of what a mode requests, but I thought I'd ask.

Also, AUCTeX is by far the worst offender here, so if there's alternately just an AUCTeX setting somewhere to prevent it from requesting changes in family, size, etc. in the first place, that would at least make the problem less annoying.

I'm currently using a recent Emacs 24 pulled from HEAD.

1

There are 1 answers

1
Ivan Andrus On BEST ANSWER

Running customize-face with your cursor on the face you are interested in will allow you to see how that face is defined (and change it). Doing this on the section title gives me font-latex-sectioning-1-face. This inherits from font-latex-sectioning-2-face etc. down to font-latex-sectioning-5-face which in turn inherits form variable-pitch (which is what changes the font family). The documentation also mentions that it's best to change the base face font-latex-sectioning-5-face, or the variable font-latex-fontify-sectioning. You can set this last to 'color which will do what you want (I think). Alternately, you can customize font-latex-sectioning-5-face to not inherit from variable-pitch, or change variable-pitch to not be variable pitch.