2

I'm loading a deftheme theme using (load-theme). I'm very happy with it most cases, but in yaml-mode I'd like to change attributes for font-lock-variable-name-face.

How can I make the theme use different face attributes for it in a single buffer?

Drew
  • 75,699
  • 9
  • 109
  • 225
Rogach
  • 267
  • 1
  • 5
  • 1
    See https://emacs.stackexchange.com/questions/7281/how-to-modify-face-for-a-specific-buffer and https://github.com/vic/color-theme-buffer-local – lawlist Feb 28 '21 at 20:38
  • 1
    To use `face-remap-add-relative` in conjunction with a particular major-mode hook, see https://stackoverflow.com/a/28008006/2112489 – lawlist Feb 28 '21 at 22:33
  • @lawlist Thank you! That works, and is much cleaner than a hacky override I cooked up with font-lock-add-keywords. – Rogach Mar 01 '21 at 06:27
  • Please feel free to write up an answer at your convenience. I don't have a setup that uses themes or `yaml-mode`, so I could not test anything and that is why I did not want to venture to write up an answer ... – lawlist Mar 01 '21 at 06:34

1 Answers1

0

As @lawlist suggested I used face-remap-add-relative to achieve the required effect:

(add-hook 'yaml-mode-hook
  (lambda ()
    (face-remap-add-relative 'font-lock-variable-name-face :foreground "#fec66c")))
Rogach
  • 267
  • 1
  • 5