I am a little new to emacs and have managed to get the color theme to my liking. However, I want to be able to use the same theme on a different machine and have been struggling to get it to work.

I used M-x color-theme-print, to extract the current theme settings, saved the file, moved it to the new computer, placed it under ~/.emacs.d/name-theme.el

Now, when I try M-x color-theme-select, my theme is not in the list, but when I go into M-x customize-themes, and try to select my new theme I get the error: "Undefined Custom theme". But now when I try, M-x color-theme-select, I can see my theme and can select it!

I would very much appreciate some help with getting this fixed and setting up my emacs so I can load this theme at start up. Thanks in advance.

Here is the code to my color theme:

(eval-when-compile    (require 'color-theme))
(defun my-color-theme ()
  "Color theme by JS, created 2017-01-27."
     ((background-color . "black")
      (background-mode . dark)
      (cursor-color . "thistle")
      (foreground-color . "wheat"))
     ((list-matching-lines-buffer-name-face . underline)
      (list-matching-lines-face . match)
      (list-matching-lines-prefix-face . shadow)
      (widget-mouse-face . highlight))
     (default ((t (:stipple nil :background "black" :foreground "wheat" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 1 :width normal :foundry "default" :family "default"))))
     (bold ((t (:bold t :weight bold))))
     (bold-italic ((t (:italic t :bold t :slant italic :weight bold))))
     (border ((t (nil))))
     (buffer-menu-buffer ((t (:bold t :weight bold))))
     (button ((t (:underline t :foreground "cyan"))))
     (comint-highlight-input ((t (:bold t :weight bold))))
     (comint-highlight-prompt ((t (:foreground "cyan"))))
     (completions-annotations ((t (:italic t :slant italic))))
     (completions-common-part ((t (nil))))
     (completions-first-difference ((t (:bold t :weight bold))))
     (cursor ((t (:background "thistle"))))
     (error ((t (:foreground "salmon1"))))
     (escape-glyph ((t (:foreground "cyan"))))
     (file-name-shadow ((t (:foreground "grey70"))))
     (fixed-pitch ((t (:family "Monospace"))))
     (font-lock-builtin-face ((t (:foreground "LightSteelBlue"))))
     (font-lock-comment-delimiter-face ((t (:foreground "SpringGreen3"))))
     (font-lock-comment-face ((t (:foreground "SpringGreen3"))))
     (font-lock-constant-face ((t (:foreground "turquoise"))))
     (font-lock-doc-face ((t (:foreground "dark khaki"))))
     (font-lock-function-name-face ((t (:foreground "pale green"))))
     (font-lock-keyword-face ((t (:foreground "white"))))
     (font-lock-negation-char-face ((t (nil))))
     (font-lock-preprocessor-face ((t (:foreground "LightSteelBlue"))))
     (font-lock-regexp-grouping-backslash ((t (:bold t :weight bold))))
     (font-lock-regexp-grouping-construct ((t (:bold t :weight bold))))
     (font-lock-string-face ((t (:foreground "dark khaki"))))
     (font-lock-type-face ((t (:foreground "aquamarine"))))
     (font-lock-variable-name-face ((t (:foreground "yellow green"))))
     (font-lock-warning-face ((t (:foreground "salmon1"))))
     (fringe ((t (:background "grey10"))))
     (glyphless-char ((t (:underline t))))
     (header-line ((t (:box (:line-width -1 :style released-button) :foreground "black" :background "grey75" :inverse-video nil :underline t))))
     (help-argument-name ((t (:italic t :slant italic))))
     (highlight ((t (:background "dark green" :foreground "white"))))
     (isearch ((t (:background "dark goldenrod" :foreground "white"))))
     (isearch-fail ((t (:background "red4"))))
     (italic ((t (:italic t :slant italic))))
     (lazy-highlight ((t (:background "gray25"))))
     (link ((t (:foreground "cyan" :underline t))))
     (link-visited ((t (:foreground "dark cyan" :underline t))))
     (match ((t (:background "RoyalBlue3"))))
     (menu ((t (nil))))
     (message-cited-text ((t (:foreground "SpringGreen3"))))
     (message-header-cc ((t (:foreground "yellow green"))))
     (message-header-name ((t (:foreground "dark turquoise"))))
     (message-header-newsgroups ((t (:italic t :bold t :foreground "yellow" :slant italic :weight bold))))
     (message-header-other ((t (:foreground "dark khaki"))))
     (message-header-subject ((t (:foreground "pale turquoise"))))
     (message-header-to ((t (:foreground "pale green"))))
     (message-header-xheader ((t (:foreground "DeepSkyBlue1"))))
     (message-mml ((t (:foreground "MediumSpringGreen"))))
     (message-separator ((t (:foreground "deep sky blue"))))
     (minibuffer-prompt ((t (:foreground "cyan"))))
     (mm-command-output ((t (:foreground "ForestGreen"))))
     (mode-line ((t (:background "grey75" :foreground "black" :box (:line-width -1 :style released-button)))))
     (mode-line-buffer-id ((t (:bold t :weight bold))))
     (mode-line-emphasis ((t (:bold t :weight bold))))
     (mode-line-highlight ((t (:box (:line-width 2 :color "grey40" :style released-button)))))
     (mode-line-inactive ((t (:background "grey30" :foreground "grey80" :box (:line-width -1 :color "grey40" :style nil) :weight light))))
     (mouse ((t (nil))))
     (next-error ((t (:foreground "white" :background "dark green"))))
     (nobreak-space ((t (:foreground "cyan" :underline t))))
     (pp^L-highlight ((t (nil))))
     (query-replace ((t (:foreground "white" :background "dark goldenrod"))))
     (region ((t (:background "dark green" :foreground "white"))))
     (scroll-bar ((t (nil))))
     (secondary-selection ((t (:background "dark slate gray"))))
     (shadow ((t (:foreground "grey70"))))
     (show-paren-match ((t (:background "steelblue3"))))
     (show-paren-mismatch ((t (:background "purple" :foreground "white"))))
     (success ((t (:foreground "yellow green"))))
     (tool-bar ((t (:foreground "black" :box (:line-width 1 :style released-button)))))
     (tooltip ((t (:family "Sans Serif" :background "lightyellow" :foreground "black"))))
     (trailing-whitespace ((t (:background "red1"))))
     (tty-menu-disabled-face ((t (:background "blue" :foreground "lightgray"))))
     (tty-menu-enabled-face ((t (:bold t :background "blue" :foreground "yellow" :weight bold))))
     (tty-menu-selected-face ((t (:background "red"))))
     (underline ((t (:underline t))))
     (variable-pitch ((t (:family "Sans Serif"))))
     (vertical-border ((t (:weight light :box (:line-width -1 :color "grey40" :style nil) :foreground "grey80" :background "grey30"))))
     (warning ((t (:foreground "orange"))))
     (widget-button ((t (:bold t :weight bold))))
     (widget-button-pressed ((t (:foreground "red1"))))
     (widget-documentation ((t (:foreground "lime green"))))
     (widget-field ((t (:background "yellow3" :foreground "black"))))
     (widget-inactive ((t (:foreground "grey70"))))
     (widget-single-line-field ((t (:background "green3" :foreground "black"))))
     (window-divider ((t (:foreground "gray60"))))
     (window-divider-first-pixel ((t (:foreground "gray80"))))
     (window-divider-last-pixel ((t (:foreground "gray40")))))))
(add-to-list 'color-themes '(my-color-theme  "JS" "JS"))

2 Answers 2


First, you are mixing up 2 different color theme types. color-theme is a separate package that predates emacs 24's built-in theme support (so your middle attempt to customize-theme will never do what you want). Why does your 1st attempt fail, but your 2nd doesn't? Apparently something in the intermediate, abortive attempt to customize-theme provides a necessary ingredient. I have some suggestions to get the color-theme working.

  1. Examine the value of load-path before and after your 1st and 3rd attempt. It needs to include both the file color-theme.el, and the actual file you created with your new color theme.

  2. You probably also want to unconditionally require 'color-theme. Currently you're only doing so when compiling; but this is also needed at runtime. (I was never able to autoload color-theme on demand back when I used it, but always had to load it up front. This is one reason I consider emacs 24 and later's built-in theme support superior.)

  3. Call (color-theme-initialize)

You may also want to consider moving to the new (load-theme) supported by recent emacs.


Sounds to me like your theme isn't being loaded at first. Let me explain.

For Emacs to be able to use the code in a file, two things need to be true: Emacs needs to be able to find it; it must be loaded with require. I haven't seen a color theme set up like yours before, but I also don't know a reason why it wouldn't work. What you need is to "hook it up" to the rest of Emacs. (My hypothesis is that one of the functions you're calling is able to find and evaluate your theme, making it "available" to Emacs. What I imagine you'd want is to have that happen automatically -- when you turn emacs on, say.)

When Emacs loads, it loads a configuration file. Per emacs, this file can be configured in a plethora of different ways; for now I'll assume a bog-standard/out-of-the-box configuration, which goes like this: if $HOME/.emacs.d is an emacs lisp file, load it; if it isn't, load $HOME/.emacs.d/init.el. Your init file is the perfect place to put stuff like this.

What I would do is:

  1. Remove the line (add-to-list 'color-themes '(my-color-theme "JS" "JS")) from your theme. Add the line, (provides 'name-theme) (Where name-theme is the name of the file your theme is living in.
  2. In your init file, add these lines: (require 'name-theme) ;; the name of your file and "module" (my-color-theme) ;; calling the theme function you defined within your module.

I'm not familiar with wrapping a theme in a function the way you have; if this doesn't get you where you need to be, you may also need to add (load-theme 'my-color-theme).

(I also use a custom theme, but approach it slightly differently; happy to link to examples if it would be helpful.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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