About

Welcome to Panela, Matt Harrison's take on mostly Open Source, Linux, Python, innovation in those areas, other buzzwords and Dick Proenneke. It comes complete with the illustrations as needed. Note the opinions expressed here are merely my opinions and not the opinions of my employer.

about Matt

Calendar

««Nov 2009»»
SMTWTFS
1234567
8910
11
12
1314
151617
18
192021
22232425262728
2930

Mailing List

My RSS Feeds








Python and emacs (2): Color themes

posted 2009.03.09 Mon

(Not really python specific)

Emacs.reddit recently had two posts dealing with emacs color themes. Coincidentally, I had just installed color-theme last Friday and was playing around with it. I was getting sick of black on white. Sadly, I really didn't like a lot of the pre-installed themes with color-theme. Some of them change your fonts (which color-theme says not to do, though it is cool to see comments in non-mono spaced fonts), others just appear to try and provide the most shock values (or contrast). Another thing I wanted was bold keywords (just so they would visually be distinct from non keywords). So combining my two requirements, easy to look at, and bold keywords left me in somewhat of a pickle. Until I found this nice theme based on tango. (Tango is a set of icons and color guidelines for freedesktops.)

I just added the definition for the tango theme directly to my .emacs. (I should probably start to break this stuff up like the emacs starter kit (which sadly ignores the existence of python, ruby snobs...)). I guess it's good that my theme is somewhere where I manage, rather than crammed in with the others in the the color-theme file. Then I can tweak it if I feel so. All is well and good, until I start emacs in a terminal, which only support 256 colors... So I default to a TTY friendly theme while running in a console.

;; color theme (requires http://www.emacswiki.org/cgi-bin/wiki?ColorTheme )
(require 'color-theme)
(color-theme-initialize)

;;
(if window-system
    (color-theme-tango))
(if (not (window-system))
    (color-theme-tty-dark))

update - Tools like ecb can make your nicely tweaked color theme, look like lipstick on a pig. Use M-x list-faces-display to find the offending faces. Update them in your config as needed.

update - Here's the font/color theme I'm currently using. I'm still tweaking, but it's a start...

;; the following is size 7 for me...
(set-face-font 'default "-unknown-Envy Code R-normal-normal-normal-*-13-*-*-*-m-0-iso10646-1")
;;(set-default-font "Envy Code R-7") ;; doesn't work consistently ;(

;;; Color theme based on Tango Palette. Created by danranx@gmail.com
;;; http://www.emacswiki.org/cgi-bin/emacs/color-theme-tango.el
(defun color-theme-tango ()
  "A color theme based on Tango Palette."
  (interactive)
  (color-theme-install
   '(color-theme-tango
     ((background-color . "#2e3436")
      (background-mode . dark)
      (border-color . "#888a85")
      (cursor-color . "#fce94f")
      (foreground-color . "#eeeeec")
      (mouse-color . "#8ae234"))
     ((help-highlight-face . underline)
      (ibuffer-dired-buffer-face . font-lock-function-name-face)
      (ibuffer-help-buffer-face . font-lock-comment-face)
      (ibuffer-hidden-buffer-face . font-lock-warning-face)
      (ibuffer-occur-match-face . font-lock-warning-face)
      (ibuffer-read-only-buffer-face . font-lock-type-face)
      (ibuffer-special-buffer-face . font-lock-keyword-face)
      (ibuffer-title-face . font-lock-type-face))
     (border ((t (:background "#888a85"))))
     (fringe ((t (:background "grey10"))))
     (mode-line ((t (:foreground "#eeeeec" :background "#555753"))))
     (region ((t (:background "#555753"))))
     (font-lock-builtin-face ((t (:foreground "#729fcf"))))
     (font-lock-comment-face ((t (:foreground "#888a85"))))
     (font-lock-constant-face ((t (:foreground "#8ae234"))))
     (font-lock-doc-face ((t (:foreground "#888a85"))))
     (font-lock-keyword-face ((t (:foreground "#729fcf" :bold t))))
     ;; remove italic from strings
     (font-lock-string-face ((t (:foreground "#ad7fa8"))))
     (font-lock-type-face ((t (:foreground "#8ae234" :bold t))))
     (font-lock-variable-name-face ((t (:foreground "#eeeeec"))))
     (font-lock-warning-face ((t (:bold t :foreground "#f57900"))))
     (font-lock-function-name-face ((t (:foreground "#edd400" :bold t :italic t))))
     ;; ECB - matt added
     ;; see - http://ecb.sourceforge.net/docs/ecb-faces.html
     (ecb-default-highlight-face((t (:background "#75507b"))))
     ;; end ecb
     (comint-highlight-input ((t (:italic t :bold t))))
     (comint-highlight-prompt ((t (:foreground "#8ae234"))))
     (isearch ((t (:background "#f57900" :foreground "#2e3436"))))
     (isearch-lazy-highlight-face ((t (:foreground "#2e3436" :background "#e9b96e"))))
     (show-paren-match-face ((t (:foreground "#2e3436" :background "#73d216"))))
     (show-paren-mismatch-face ((t (:background "#ad7fa8" :foreground "#2e3436"))))
     (minibuffer-prompt ((t (:foreground "#729fcf" :bold t))))
     (info-xref ((t (:foreground "#729fcf"))))
     (info-xref-visited ((t (:foreground "#ad7fa8"))))
     
     )))

;; color theme (requires http://www.emacswiki.org/cgi-bin/wiki?ColorTheme )
(require 'color-theme)

;;
(if window-system
    (color-theme-tango))
(if (not (window-system))
    (color-theme-tty-dark))

tags:      

links: digg this    del.icio.us    reddit




1. MuadDib left...
2009.03.09 Mon 3:46 pm

<borat>Very niiice</borat>

Since I don't like the overhead of color-theme, and of course it does not play well with emacs --daemon in 23 (Always end with "console" mode) : I put a "home made translation" of your tango theme to pure .Xdefaults: http://dl.getdropbox.com/u/64259/emacs/dotXdefaults-emacs- tango-theme

Add the content to your .Xdefaults, then 'xrdb -merge .Xdefaults' to load new content

Remove all calls to 'color-theme' for windowing since it won't be needed anymore and and restart your emacs...

Side effect: All X sessions emacs (including X-fw) will start with your 'Xdefaulted' theme - regardless of the emacs setting where you start it.


2. nimai etheridge left...
2009.03.09 Mon 5:37 pm :: http://guidinglight.com.au

If you want to change a built in color theme, do M-x color-theme-select then highlight the theme you wish to use as a starting point and hit p. This will invoke the color-theme-print function which will print the color theme to a buffer which you can then change. To preview the built in emacs colors, do M-x list-colors-display. To preview your theme just hit C-c v in the buffer to execute it. Once you're finished C-x C-w to save it somewhere and then load it in your init.el. You now no longer need to load color-theme.el at all. It only took me a few minutes to adjust one of the existing themes to my liking...and funnily enough, it's actually pretty close to your one


3. Matt left...
2009.03.10 Tue 2:39 pm :: http://panela.blog-city.com/

Get replies. Thanks!

I've ended up removing italics from strings. (I tend to use | (pipe) a lot and when italicized it looks like a slash).


4. Jinha Jung left...
2009.08.29 Sat 8:11 pm :: http://jinha.info/blog

I really like this color theme. I used Zenburn color theme I found somewhere I don't remember, but I like this one much better. Thanks for sharing good information. :-)


5. bobby p left...
2009.09.04 Fri 2:03 pm

this is fantastic, just what I was looking for! thanks!!