Next: , Previous: , Up: Emacs Initialization   [Contents][Index]

16.12 X11 Colors

You can specify colors when you use Emacs with the MIT X Windowing system.

I dislike the default colors and specify my own.

Here are the expressions in my .emacs file that set values:

;; Set cursor color
(set-cursor-color "white")

;; Set mouse color
(set-mouse-color "white")

;; Set foreground and background
(set-foreground-color "white")
(set-background-color "darkblue")
;;; Set highlighting colors for isearch and drag
(set-face-foreground 'highlight "white")
(set-face-background 'highlight "blue")
(set-face-foreground 'region "cyan")
(set-face-background 'region "blue")
(set-face-foreground 'secondary-selection "skyblue")
(set-face-background 'secondary-selection "darkblue")
;; Set calendar highlighting colors
(add-hook 'calendar-load-hook
      (lambda ()
        (set-face-foreground 'diary-face   "skyblue")
        (set-face-background 'holiday-face "slate blue")
        (set-face-foreground 'holiday-face "white")))

The various shades of blue soothe my eye and prevent me from seeing the screen flicker.

Alternatively, I could have set my specifications in various X initialization files. For example, I could set the foreground, background, cursor, and pointer (i.e., mouse) colors in my ~/.Xresources file like this:

Emacs*foreground:   white
Emacs*background:   darkblue
Emacs*cursorColor:  white
Emacs*pointerColor: white

In any event, since it is not part of Emacs, I set the root color of my X window in my ~/.xinitrc file, like this16:

xsetroot -solid Navy -fg white &



I also run more modern window managers, such as Enlightenment, Gnome, or KDE; in those cases, I often specify an image rather than a plain color.