How to disable foreground color in space mode for Emacs

In programming files, I use the space mode to highlight the tab and long lines. The default highlighting is too garnishing for me. I just want to highlight them with a gray background and keep any normal color for the font. How can i install this?

The following setting does not work. I would like the code outside the 80 columns to look yellowish, like the characters inside the 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

+5
source share
2 answers

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

Set :foregroundto nil:

(set-face-attribute 'whitespace-line nil
                    :foreground nil
                    :background "#555"
                    :weight 'bold)
+4
source

For me, the unpleasant color turned out to be a hooked space, and I use 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"))
+3
source

All Articles