Customizing Emacs Tutorial BY Dummy – Change Color Theme
Change Color Theme in Emacs 24
- for dummies like me. I just want to use emacs to edit some files. I don’t plan to run my entire life with it.
- If any emacs expert sees my post, please correct my mistakes
Part I: Default Themes.
1. In Emacs 24, it is easy to change basic theme. Do the following: Open Emacs, type: M-x load-theme. That is: Hit Meta X, then type load-theme, then hit Enter. You should see “Load custom theme:”. If you know the name of the theme you want to use, type it, if not, hit Tab. Possible themes are listed. Click one.
2. If hitting TAB doesn’t bring up a list of themes…(searching for an answer online, please let me know if you have a solution). Default themes on my machine include: adwaita, deeper-blue, dichromacy, light-blue, manoj-dark, tango, tango-dark, tsdh-dark, tsdh-light, wheatgrass, whiteboard, wombat. (So to change to tango, type :
M-x load-theme, hit Enter, type
tango, hit Enter.)
Part II: Use Other Good Looking Themes.
Main Idea: Download the theme file (a .el file) —> Put it in a folder —> Let Emacs know to look for interesting things in that folder (by editing the .emacs file) —> Ask Emacs to use the theme
1. Download a theme. My friends recommended two themes: zenburn and monokai. They can be downloaded from
- Download the .el file. (For example monokai-theme.el). Note: For some reason if I right click on the download theme, and choose save file, my computer downloads a .el file with html codes in it (not what we want). So make sure you have the correct .el file (for example, download the zip file and extract .el from it). The first few lines of my monokai-theme.el file looks like this
;;; monokai-theme.el — REQUIRES EMACS 24: Monokai Color Theme for Emacs.
;; Copyright (C) 2012 Lorenzo Villani.
- Put the .el files in your emacs folder (see below)
- Where is the folder: Actually you can choose any folder, but since you need to type the path to this folder later, put it somewhere close to your home directory, usually ~/emacs.d/themes/ .
- Windows 7: Internet told me I should put it in /emacs.d/themes. If that folder doesn’t exists, create one. On my Windows 7 machine I put in C:\emacs\emacs.d\themes.
- Linux or Macs: look for this folder: ~/.emacs.d/themes. The folder may be hidden (because of the “.” in front of the name). So type ls -a from the terminal to see all folders and files (that’s what -a is for). If it is not there, or you just don’t want to look for it, create one.
- Note: Remember the path of this folder. You need to let Emacs know to look into this folder! (see 2,3 below)
2. The magical .emacs file. (You can skip this part.)
- .emacs is a Very Important file … which may not exist. Every time Emacs starts it will run .emacs. By changing contents of this file, you customize the behavior of emacs.
- How does Emacs know where to find the .emacs file? Most of the time you don’t need to worry about it. I guess in Macs or Linux, Emacs looks for it in the home directory (in the system PATH). With Windows 7, look at my other post “how to install Emacs on Windows”, which I stole from http://www.claremontmckenna.edu/pages/faculty/alee/emacs/emacs.html.
- The file is written in the “emacs lisp” language (no idea). I don’t plan on learning it in the near future. If you want to, look at this Emacs lisp introduction: http://www.gnu.org/software/emacs/emacs-lisp-intro/
3. Locate your .emacs file.
- Note: If this is the first time you customize your Emacs, the .emacs file may not exist! So you need to create one (see the last bullet point in this paragraph).
- Linux: Should be in the home directory ~/. Note this is a hidden file, you can see it by typing “ls -a” in the terminal. Alternatively or just run “emacs .emacs”, at home directory, which will open (create if it doesn’t exist) the file “.emacs” using Emacs.
- Mac: Click terminal, then follow the steps above.
- Windows 7: Too complicated. Mine was put in “C:/emacs/”. See http://www.claremontmckenna.edu/pages/faculty/alee/emacs/emacs.html.
- Alternative way of finding .emacs: Open (create) it directly in emacs: Open emacs, type
C-x C-f, (the command for finding or creating file), then type
4. Edit the .emacs file.
- Open your .emacs file. Either use Emacs, or use any other text editor. It doesn’t matter. Add the following line to the end of the file:
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/")
- Remember to change “~/.emacs.d/themes/” to which ever folder you put the .el theme file. On my Windows 7 the line looks like:
- (add-to-list ‘custom-theme-load-path “C:/emacs/.emacs.d/themes/”)
- On my Mac the line looks like
- (add-to-list ‘custom-theme-load-path “~/.emacs.d/color-theme/”)
5. Save the .emacs file. Restart Emacs.
6. Do Part I: Hit M-x, type load-theme, hit TAB, the new themes should be in the list. If hitting TAB doesn’t bring up a list of themes, just type the name of the theme and hit Enter.
7. Last step. If you want emacs to automatically load the theme, add another line:
(load-theme 'zenburn t)