For better experience color-identifiers-mode recommends turning off colors for everything. The example in README does it by setting :foreground
of faces to nil
, which kinda works.
However doing it globally is unwanted for unsupported modes, e.g. for Markdown. So faces have to be set locally, which is the problem: setting :foreground
to nil
triggers an error:
(face-remap-add-relative 'font-lock-keyword-face '((:foreground nil)))
[*Messages* buffer ↓]
Invalid face attribute :foreground nil
Invalid face reference: font-lock-keyword-face
Setting to 'unspecified triggers:
(face-remap-add-relative 'font-lock-keyword-face '((:foreground 'unspecified)))
[*Messages* buffer ↓]
Invalid face attribute :foreground (quote unspecified)
Invalid face reference: font-lock-keyword-face
Using unspecified
without '
changes nothing.
And, finally, using an empty string does work, but triggers a warning:
(face-remap-add-relative 'font-lock-keyword-face '((:foreground "")))
[*Messages* buffer ↓]
Unable to load color ""
I personally could settle down with an empty string, but I'm going to change the README recommendation about setting faces, and triggering warnings for users not a good user experience.
So, what is the correct way of unsetting the :foreground
color?
face-remap-add-relative
, so that is what I have tried to use in some of my on-line answers. However, in my own setup I set theface-remapping-alist
directly as either global withsetq-default
or local withsetq-local
. It is something you may wish to consider, even though people will tell that the manual recommends usingface-remap-add-relative
. I change my modeline background this way, and also the faces in the minibuffer depending upon whether my cursor is in the minibuffer when open or elsewhere. – lawlist Sep 8 '17 at 0:15:foreground
tonil
should work. Unfortunately it doesn't. Minimal steps are: 1) split Emacs window to buffers *Messages* and a C++ with a function declaration 2) in C++ buffer execute M-:(add-to-list 'face-remapping-alist (cons 'font-lock-function-name-face '((:foreground nil))))
. 3) move around a little, and see how *Messages* got spammed with errors. – Hi-Angel Sep 18 '17 at 20:48