Tutorial :Why does this Emacs Lisp snippet break list-colors-display?



Question:

I like Emacs to highlight tab characters using the trailing-whitespace face, which I set to be a slightly grayer version of my background color. That way, all whitespace that I consider unwanted (tab characters and trailing whitespace) will have a slightly gray background.

This is the code I use:

(add-hook 'font-lock-mode-hook    '(lambda ()       (font-lock-add-keywords         nil          '(("\t" 0 'trailing-whitespace prepend))       )     )  )  

However, it seems to break list-colors-display: This function still lists all the colors, but they're monochrome. I don't get the dazzling spectrum of colors it's supposed to provide.

Why is this happening? Can it be fixed?


Solution:1

You could wrap your function so it doesn't do the whitespace thing in buffers that start/end in *'s. You probably don't want it in those types of buffers anyway:

(add-hook ...    (unless (string-match "\\*.+\\*" (buffer-name))      (font-lock-add-keywords ...)))  


Solution:2

Unsure why the error. There is a mode available on the wiki that shows tabs (show-wspace.el) that works pretty well.

(require 'show-wspace)  (show-ws-toggle-show-tabs) ; default is no tabs shown, turn it on  ;; the face used is 'show-ws-tab, which you can customize at will      

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »