24

Emacs blue (on dark background) is too dark. classA is readable with difficulty in the example below:

enter image description here

How to fix the dark blue colour?

Viesturs
  • 805
  • 8
  • 19
  • 5
    Are you using the terminal and a theme that's aware of dark/light backgrounds? In this case it could be that Emacs doesn't detect your terminal's background color correctly (as it's just guessing) and customizing `frame-background-mode` will fix it and other faces. – wasamasa Oct 06 '17 at 16:37
  • 1
    @wasamasa's comment is applicable to my situation. It should be made into an answer IMO. – Henry Oct 09 '17 at 18:22

5 Answers5

20

Add frame-background-mode to your init file:

(setq frame-background-mode 'dark)
x-yuri
  • 281
  • 1
  • 8
Viesturs
  • 805
  • 8
  • 19
  • This is the best answer, affirming the 2nd highest vote getter is the most correct in stack exchange. – Chris Sep 28 '21 at 17:36
  • 1
    I agree, I have upvoted (both this answer and @wasamasa's answer) and I've commented on the superiority of this answer to mine (the current top vote getter). The main problem is that it came about a month after mine. wasamasa's answer came only three days after and should have been *the* answer but the OP took another month to post his answer and mark it correct. It's probably that time gap that explains the situation here, not any tongue-in-cheek "2nd is first" SE phenomenon :-) – NickD Oct 03 '21 at 02:15
  • [Light](https://i.imgur.com/A8ABLRZ.png), [dark](https://i.imgur.com/2FJZ9km.png). Am I doing it wrong? Any prerequisites? That's `emacs -Q`. – x-yuri Dec 10 '21 at 10:54
  • @x-yuri : You should post this as a separate question. Nobody will see a comment that was posted two years after the original answer (and well, yes, I saw it, but it was purely an accident :-) ) – NickD Oct 11 '22 at 01:45
  • @NickD It doesn't add much. The one who sees will see. And the the Occam's razor says me to [stop it](https://www.youtube.com/watch?v=Ow0lr63y4Mw) (c) :) It's probably best to edit this answer. – x-yuri Oct 11 '22 at 02:27
19

Put the cursor on the blue word, and say C-u C-x =. Find the face entry and click on its value. Then click on customize this face and change the foreground value to e.g. Cyan1.

If you are in a console or are doing emacs -nw in a terminal, instead of clicking, put the cursor on the appropriate element and press RET.

NickD
  • 27,023
  • 3
  • 23
  • 42
  • How can I move the cursor in `emacs -nw` mode to the right pane? RET the same as ENTER ? – Viesturs Oct 06 '17 at 08:49
  • 1
    `C-x o` will cycle through the windows. And yes, `RET` is the commonly used emacs name for the key that is usually labeled `Enter`. – NickD Oct 06 '17 at 08:53
  • I managed to do it. – Viesturs Oct 06 '17 at 09:03
  • Congratulations! – NickD Oct 06 '17 at 09:10
  • If the problem is to change *one* face (or a few), then my answer stands. But if the problem is as @wasamasa describes in the comment to the question and the answer below, then that is the better answer: customize `frame-background-mode`. – NickD Oct 13 '17 at 17:53
  • I'm trying to do this on a console and `C-u C-x` makes the selected word ALL CAPS :( Is there a meta-x command I could type in instead? – Rick Smith Jul 12 '18 at 17:23
  • 1
    Try `C-u M-x what-cursor-position RET` but you should fix your setup: C-x is much too valuable as a prefix to waste. – NickD Jul 12 '18 at 18:01
11

Faces in Emacs can have different values, depending on display attributes such as the number of colors supported or whether they're displayed on a light/dark background. Emacs can guess the latter without any issues in graphical mode, for textual frames however the guessing isn't nearly as good. If it turns out to be wrong, you'll get dark blue on black (because it mistakenly assums a light background on which there would be enough contrast to the dark blue), like in the screenshot above.

To check whether that's the case for you, inspect the value of frame-background-mode and customize it if needed.

wasamasa
  • 21,803
  • 1
  • 65
  • 97
5

NickD has a good answer but doesn't update your menu bar which may also have the same dark blue (can you see what it says when you type ctrl + s?). This method will also fix hard to read menus.

  1. Run emacs
  2. Type alt + x customize-themes
  3. Arrow down to manoj-dark and hit return (or pick a different theme)
  4. Type ctrl + x, ctrl + s to save the settings
  5. Type ctrl + x, ctrl + c to quit

This theme is saved to your .emacs file and will be used when you use emacs in the future. Here are more exhaustive instructions.

Rick Smith
  • 151
  • 1
  • 3
0

To change the colors of a part of a text, you put the cursor there, press C-u C-x =, and find the face name:

Knowing the face name you can change the foreground (M-x set-face-foreground), or the background (M-x set-face-background). There's also (set-face-attribute):

(set-face-attribute 'package-name nil :foreground "cyan1")

Replace package-name with the desired face name. nil means "for existing and newly created frames."

To display the list of colors use M-x list-colors-display.

You can execute non-interactive functions (like set-face-attribute) via M-:, in a scratch buffer (C-x C-e), or put them into ~/.emacs.

The same applies to interactive functions (like set-face-foreground, set-face-background). But they can also be executed via M-x.

x-yuri
  • 281
  • 1
  • 8