I'm running Emacs, editing files in C++ mode and PHP mode. I love syntax highlighting as a concept, but the default colors are a travesty. I can barely read some of them: way too dark. What is the easiest way to change their values? I can't seem to find anything about this on the web. I don't even mind changing the binary as I'm compiling my own Emacs. I just want to find the place where it says blue is #0000FF and change it to #AAAAFF for example.

share|improve this question
up vote 60 down vote accepted

I find it easiest to use color-theme for this sort of thing.

https://www.emacswiki.org/emacs/ColorThemes

But if you don't want to do that, put the cursor over the offending text, hit M-x customize-face. It should default to the face that the cursor is over.

http://www.gnu.org/software/emacs/manual/html_node/emacs/Specific-Customization.html

share|improve this answer
    
A nice color theme. – Benoit Jan 10 '13 at 14:22
    
Problem is, one of the colors I simply can't read (it's a dark blue that's practically invisible over the black background) is whatever text is being displayed when I type M-x customize-face! (Also, the ColorTheme link appears to have an issue) – Michael Aug 4 '16 at 18:09
    
Well I tried to fix the link to one that worked, but when it gets followed from this page it still doesn't work!!! – Michael Aug 4 '16 at 18:14

If you don't care about color highlighting at all, or none of the above answers work for you (or take too much time and effort to figure out), here is a very simple solution that will get rid of colors altogether.

Typing the following will get rid of colors:

M-x global-font-lock-mode

You can also do this as an interim step to allow you to actually see everything your screen to try any of the above answers. In my case this was very useful because the color of certain key pieces of text which would allow me to change colors were themselves nearly invisible - for instance, the prompt of M-x.

If you want the change to be permanent, you can add this to your .emacs file:

(setq-default global-font-lock-mode nil)

share|improve this answer

Put the cursor on a face ("color") that you want to change. Hit C-u C-x =. That will tell you which face(s) are present at that position, and it will let you click to customize it/them. Save your customizations.

share|improve this answer
    
I'm clueless about what I am supposed to enter in the customization screen. For one thing, some of the important stuff is in a font color that I can't read (that's what I'm trying to fix in the first place!) and second, I don't see any obvious references to color or how to change them. – Michael Aug 4 '16 at 18:12
    
@Michael: If you can't read the text in Customize, then use it from an Emacs session that is virgin: start Emacs using emacs -Q. If you can read the text then you should be able to see checkboxes for the attributes currently used to define the face you are customizing. Click the link Show all attributes to show all attributes. Check or uncheck any of the attributes, as needed. When you check a box you see its current value. If attribute Background or Foreground is checked then you can use the Choose button next to the current value to choose a different color for that attribute. – Drew Aug 4 '16 at 20:04

2 ways - you can install the package color-theme, which has lots of nice schemes to select and is easier to do it by hand. The by-hand looks like this (in your .emacs)

(custom-set-faces
   custom-set-faces was added by Custom.
   If you edit it by hand, you could mess it up, so be careful.
   Your init file should contain only one such instance.
   If there is more than one, they won't work right.
  '(default ((t (:inherit nil :stipple nil :background "lightyellow2" :foreground "gray20" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight bold :width normal :family "liberation mono"))))
  '(background "blue")
  '(font-lock-builtin-face ((((class color) (background dark)) (:foreground "Turquoise"))))
  '(font-lock-comment-face ((t (:foreground "MediumAquamarine"))))
  '(font-lock-constant-face ((((class color) (background dark)) (:bold t :foreground "DarkOrchid"))))
  '(font-lock-doc-string-face ((t (:foreground "green2"))))
  '(font-lock-function-name-face ((t (:foreground "SkyBlue"))))
  '(font-lock-keyword-face ((t (:bold t :foreground "CornflowerBlue"))))
  '(font-lock-preprocessor-face ((t (:italic nil :foreground "CornFlowerBlue"))))
  '(font-lock-reference-face ((t (:foreground "DodgerBlue"))))
  '(font-lock-string-face ((t (:foreground "LimeGreen"))))

...

etc. etc.

You can also type

`M-x customize-face RET`

which will give you all the customizations to set, ultimately end up in your .emacs.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.