views:

408

answers:

5

I am using emacs on MacOS 10.6 with Terminal. I have a white background.

It's very hard to read quoted C++ strings. They are coming up in pale green. Keywords are in turquoise.

After searching through the source I cam across cpp.el and have determined that I am using the cpp-face-light-name-list instead of cpp-face-dark-name-list.

Apparently this function is supposed to chose the correct list based on the background color:

(defcustom cpp-face-default-list nil
  "Alist of faces you can choose from for cpp conditionals.                                                           
Each element has the form (STRING . FACE), where STRING                                                               
serves as a name (for `cpp-highlight-buffer' only)                                                                    
and FACE is either a face (a symbol)                                                                                  
or a cons cell (background-color . COLOR)."
  :type '(repeat (cons string (choice face (cons (const background-color) string))))
  :group 'cpp)

But it doesn't seem to be working.

What should I put in my .emacs file so that I get the cpp-face-dark-list instead of cpp-face-light-list?

Thanks!

A: 

might be worthwhile to make sure your terminal is color enabled: export TERM=xterm-256color

aaa
Since he sees fonts in pale green I think it's safe to assume that colors in the terminal are enabled.
Bozhidar Batsov
+3  A: 

As suggested in one of the comments - check out the color-theme package. It's a much more generic solution to problems such as yours and it's much easier to use than manually adjusting font faces.

Bozhidar Batsov
+1  A: 

If you explicity set the default-face's foreground to black and background to white ( M-x customize-group basic-faces), font lock will make sure everything is readable automatically. Those two colors are the only ones you need to set if all you need is enough contrast to have font lock be readable.

I have tried colortheme.el, and especially with emacs23 it tends to make things less rather than more readable, I ended up having to restart in order to recover faces that it set to unreadable foreground/background combos and did not reset.

Justin Smith
+2  A: 

I have the same problem, my chosen themes are always unreadable on the terminal. The answer is to use the color-theme package, as others have said, then select one theme for Emacs in a terminal, and another theme for Emacs running in its own window, just like this:

(require 'color-theme)
(setq color-theme-is-global t)
(if window-system
    (color-theme-deep-blue)   ;; Emacs in own window
    (color-theme-dark-laptop) ;; Emacs in tty
)

In Emacs, you can type M-x color-theme-Tab to get a list of available themes. Equally, you could add hooks for major modes to change the color-theme depending on what sort of code you are editing.

snim2
A: 

This is another way to do it, and it's especially handy if you use the daemon mode in Emacs 23+. While using daemon mode, one is sometimes using a graphical client and some other times a terminal client. The "snippet" below tries to figure out what client you are using, and then switches to the appropriate theme (from color-theme-choices). Found it on emacswiki.

(require 'color-theme)
(eval-after-load "color-theme"
    (color-theme-initialize))

;; http://www.emacswiki.org/emacs/ColorTheme#toc10
;; select theme - first list element is for windowing system, second is for console/terminal
(setq color-theme-choices 
      '(color-theme-tangotango color-theme-standard))

(funcall (lambda (cols)
           (let ((color-theme-is-global nil))
             (eval 
              (append '(if (window-system))
                  (mapcar (lambda (x) (cons x nil)) 
                      cols)))))
         color-theme-choices)

(require 'cl)
(fset 'test-win-sys 
      (funcall (lambda (cols)
             (lexical-let ((cols cols))
               (lambda (frame)
                 (let ((color-theme-is-global nil))
               (select-frame frame)
               (eval 
            (append '(if (window-system frame)) 
                (mapcar (lambda (x) (cons x nil)) 
                    cols)))))))
               color-theme-choices ))
(add-hook 'after-make-frame-functions 'test-win-sys)
monotux