2013-01-31 26 views
5

在編程文件時,我使用空白模式來突出顯示標籤和長行。默認突出顯示對我來說太重要了。我只是想用灰色背景突出顯示它們,並保留字體所需的任何正常顏色。我怎麼能設置它?如何取消Emacs的空白模式的前景色

以下設置不起作用。我希望80列以外的代碼顯示爲淡黃色,作爲快照中80列內的字符。

;; 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

+0

同樣的問題。在默認主題中,尾隨空格是一個很好的灰色。在所有其他顏色的主題中,它就像一些致命的錯誤一樣閃爍着紅色。下面的設置面屬性答案不起作用。 –

回答

4

set-face-attribute變化只有您指定的屬性。

設置:foregroundnil

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

我知道,但零將設置字體白色不黃。 – RNA

+0

我明白了。簡短的回答:你不能這樣做。較長的答案:你需要補丁whitespace.el:https://gist.github.com/72d39c507d56c5c5e0ed – Dmitry

+0

我正在尋找類似於defadvice的東西,因爲功能 – RNA

3

對我來說,不愉快的色彩竟然是尾隨空白,我用這個:

;; 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")) 
+0

這樣做爲尾隨空白和空白行爲emacs 24.4工作 - 除了我使用(加入鉤'python-mode-hook'(lambda()(set-face-attribute ...)) )。毫無疑問,這不是最好的地方,但爲我的目的而工作。 –