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.

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:

j@sigusr1:$ 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:

root@sigusr1:$ 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.

.emacs [download .emacs file]

(setq custom-file "~/.emacs-custom.el")
(load custom-file)

.emacs-custom.el [download emacs-custom.el]

(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.
 '(inhibit-startup-screen t)
 '(keyboard-coding-system (quote utf-8-unix))
 '(tool-bar-mode nil)
 '(color-theme-selection "Subtle Hacker" nil (color-theme))
 '(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")))))
 
;; Add-Ons
 
;; ===== Turn on Auto Fill mode automatically in all modes =====
;; Auto-fill-mode the the automatic wrapping of lines and insertion of
;; newlines when the cursor goes over the column limit.
;; This should actually turn on auto-fill-mode by default in all major
;; modes. The other way to do this is to turn on the fill for specific modes
;; via hooks.
(setq auto-fill-mode 1)
;; ========== Set the fill column ==========
;; Enable backup files.
(setq-default fill-column 78)
;; ===== Set the highlight current line minor mode =====
;; In every buffer, the line which contains the cursor will be fully
;; highlighted
(global-hl-line-mode 1)
;; ========== Line by line scrolling ==========
;; This makes the buffer scroll by only a single line when the up or
;; down cursor keys push the cursor (tool-bar-mode) outside the
;; buffer. The standard emacs behaviour is to reposition the cursor in
;; the center of the screen, but this can make the scrolling confusing
 
(setq scroll-step 1)
;; ===== Turn off tab character =====
;;
;; Emacs normally uses both tabs and spaces to indent lines. If you
;; prefer, all indentation can be made from spaces only. To request this,
;; set `indent-tabs-mode' to `nil'. This is a per-buffer variable;
;; altering the variable affects only the current buffer, but it can be
;; disabled for all buffers.
 
;;
;; Use (setq ...) to set value locally to a buffer
;; Use (setq-default ...) to set value globally
;;
(setq-default indent-tabs-mode nil) 
;; ========== Place Backup Files in Specific Directory ==========
 
;; Enable backup files.
(setq make-backup-files t)
;; Enable versioning with default values (keep five last versions, I think!)
(setq version-control t)
;; Save all backup file in this directory.
(setq backup-directory-alist (quote ((".*" . "~/.emacs_backups/"))))

References

  1. http://www.gnu.org/software/emacs/emacs-faq.html#Installing-Emacs

  2. http://www.is-vn.bg/hamster/

  3. http://www.nongnu.org/color-theme/

  4. http://homepages.inf.ed.ac.uk/s0243221/emacs/

  5. http://amrmostafa.org/bearable-emacs-recipe

  6. http://peadrop.com/blog/2007/01/06/pretty-emacs/

  7. http://fractal.csie.org/~eric/wiki/Terminus_font

  8. http://copyleft.free.fr/wordpress/index.php/2009/04/24/nice-fonts-with-emacs-23-snapshot/