Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to unset the foreground color of whitespace-mode for Emacs

In programming files, I use whitespace-mode to highlight the tab and long lines. The default highlighting is too garnish for me.I just want to highlight them with a gray background and keep whatever normal color it should be for the font. How could I set that?

The following setup does not work. I'd like the code beyond 80 columns appearing yellowish, as the characters inside 80 columns in the snapshot.

;; face for long lines' tails
(set-face-attribute 'whitespace-line nil
                    :background "#555"
                    :weight 'bold)

;; face for Tabs
(set-face-attribute 'whitespace-tab nil
                    :background "#555"
                    :weight 'bold)

whitespace-mode

like image 411
RNA Avatar asked Jan 31 '13 23:01

RNA


2 Answers

set-face-attribute changes only the attributes you specify.

Set :foreground to nil:

(set-face-attribute 'whitespace-line nil
                    :foreground nil
                    :background "#555"
                    :weight 'bold)
like image 63
Dmitry Avatar answered Sep 22 '22 11:09

Dmitry


For me the unpleasant color turned out to be trailing-whitespace and I'm using this:

;; whitepace looks rediculous in color themes.
(defadvice color-theme-install (after my-color-theme-install-after activate)
  "Fix trailing-whitespace after color theme destroys it"
  (set-face-attribute 'trailing-whitespace nil
                      :foreground 'unspecified
                      :inverse-video 'unspecified
                      :slant 'unspecified
                      :weight 'unspecified
                      :background "#fff"))
like image 35
Dave Cohen Avatar answered Sep 21 '22 11:09

Dave Cohen