Data Pile

Against Digital Amnesia

Customizing Emacs

Some of you might be forced to spent nearly the whole day in a texteditor like e.g. emacs to do their work. This usually is especially true for developers, that have to write code the whole day and therefore are forced to look into theier editor the whole day. So why not customize it a little, so work might be more pleasant in the end?

This article will show you how you can customize emacs to hopefully suit your needs. Since I am using Ubuntu, which is a debian based distribution, the installation of packages might vary for your distro.

Prerequisites

In order for this customization to work, you need to get some things first. This includes the development version of emacs, which in my distribution is marked as emacs-snapshot, and the Terminus font, which is according to many users the font if you have to work long on your computer. That’s what I can say too, the font is very pleasant on the eyes.

So, be sure to have the following stuff available:

For the development (snapshot) version of emacs you’d probably have to check out the CVS repository, if you’re lucky, version 23 is released when you read this ;).

On an Ubuntu based installation, these packages are quite easy to get, simply enter the following commands in your terminal.

1
2
3
4
j@sigusr1:$ sudo aptitude install \
	    console-terminus xfonts-terminus \
	    xfonts-terminus-dos xfonts-terminus-oblique \
	    emacs-snapshot emacs-snapshot-gtk

If you do have the non-snapshot edition of emacs already installed on your system, you might want to update your default, be ecexuting the following commands and select the snapshot as the default being started when you type “emacs”:

1
2
$ sudo update-alternatives --config emacs
$ sudo update-alternatives --config emacsclient

You should now be able to type “emacs” into your terminal and the emacs-snapshot will be started.

Color Themes

I like colors, and I think the basic color theme that comes with emacs is not very nice. So I decided to install some color themes. Luckily these color themes can be easily installed on Ubuntu. If you are using another distribution which might not have support for that, you might want to try downloading and installing it manually. For the automatic version, simply do:

1
$ sudo apt-get install emacs-goodies-el

After the installation completes, you should be able to start emacs and select a color theme like “Subtle Hacker” or “Gnome 2” with M-x color-theme-select. The “Save customization” feature in the snapshot i am using (GNU Emacs 23.0.91.1) does not seem to work unfortunately. There is one “trick” though that might work; if the customization file does not yet exist, saving seems to work.

Customization Files

If you externalize your configuration into a -custom.el file, you end up with two files, the .emacs and the .emacs-custom.el file (or whatever you name it). My files look as follows.

My .emacs File (.emacs) download
1
2
(setq custom-file "~/.emacs-custom.el")
(load custom-file)
My .emacs-custom.el File (.emacs-custom.el) download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
(custom-set-variables
  ;; custom-set-variables was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(color-theme-selection "Subtle Hacker" nil (color-theme))
 '(global-hl-line-mode t)
 '(inhibit-startup-screen t)
 '(keyboard-coding-system (quote utf-8-unix))
 '(tool-bar-mode nil)
 '(woman-locale "en_US.UTF-8"))
(custom-set-faces
  ;; custom-set-faces was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(default ((t (:stipple nil :background "darkslategrey" :foreground "wheat" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 122 :width normal :foundry "xos4" :family "Terminus"))))
 '(hl-line ((t (:background "#3F6A6A" :foreground "white")))))

References