Search code examples
emacselispdot-emacsemacs-faces

How set colors for a specific mode?


I'm trying Emacs. I would like to set colors for Eshell. I tried that first with set-foreground-color. But it affects my other modes too.

  (add-hook 'eshell-mode-hook (lambda ( default ((t (:foreground "#BD8700"))))))

But that's not working either. Or it's affecting the colors on other modes/scratch too.

Have anyone a suggestion? This is not a duplicate question, because the other answers change the colors of other buffers as well.


Solution

  • Here is a link to the documentation regarding remapping faces: http://www.gnu.org/software/emacs/manual/html_node/elisp/Face-Remapping.html

    (defun my-eshell-mode-faces ()
      (face-remap-add-relative 'default '(:foreground "#BD8700")))
    
    (add-hook 'eshell-mode-hook 'my-eshell-mode-faces)