My dot Emacs file

Recently I upgraded to Emacs 23.1, customised some options, saved them and went about my work. However, whenever I used emacs on the command line I was greeted to a greyish background that just did not look like it belonged. And the plain white background was getting a bit old fashioned. So I decided it was high time that I setup my .emacs file amongst others.

Note: There are a lot of code samples in this post, Facebook removes the style, WordPress does not, Hyves I dunno. So if you want syntax highlighting then goto the wordpress version.

Remove Gray Backgroun Colour in TTY

First thing to do is use the Options menu to set most of your options like: font (mijn is DejaVu Sans Mono at 9) use standard copy and paste commands etc. However this will also set a default background and foreground colour scheme, to fix this open ~/.emacs and remove from (custom-set-faces...: , “:background white :foreground black"

You should have something similar to:

Generated using GeSHi

;; Custom Variables
(column-number-mode t)
(cua-mode t nil (cua-base))
(scroll-bar-mode (quote right))

(show-paren-mode t)
(size-indication-mode t)
(uniquify-buffer-name-style (quote forward) nil (uniquify)))

(default ((t (:inherit nil :stipple nil :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 88 :width normal :foundry “unknown” :family “DejaVu Sans Mono”)))))

Misc Stuff

This is some misc stuff. The following entry shall set the default tab width, stop the splash screen from occurring, write filename into the titlebar and enable markdown mode if you have installed emacs extras i.e. i.e. emacs-goodies-el in ubuntu.

Generated using GeSHi

(defvar HOME (expand-file-name “~”))
(setq EMACS “emacs”)
(setq HOSTNAME (substring (system-name) 0 (string-match \\.” (system-name))))

(setq FULLHOSTNAME (system-name))
(setq USERNAME (getenv “USER”))

;; Stop Splash screen

(setq inhibit-splash-screen t)

;; Tab width
(setq default-tab-width 4)
(setq-default tab-width 4)

;; Write filename into titlebar.
(setq frame-title-format `(,EMACS “[“USERNAME “@” HOSTNAME “]: “

(buffer-file-name “%f” (dired-directory dired-directory  “%b”))))

;; Add Markdown mode

(autoload ‘markdown-mode “markdown-mode.el” “Major mode for editing Markdown files” t)
(setq auto-mode-alist (cons(\\.mdt” . markdown-mode) auto-mode-alist))

A coloured Emacs

If you have installed the color-theme package for emacs (i.e. emacs-goodies-el in ubuntu) then you can get some nice themes going. I currently use color-theme-gnome2 for graphical emacs and color-theme-tty-dark when in TTY mode i.e. in a terminal. However gnome2 doesn’t look well when run in the terminal as does tty-dark and vice-versa. The code below ensures that each theme is used when required. A full list of themes can be found be the following command:

M-x color-theme-select

The lisp code is:

Generated using GeSHi

;; Add colour theme stuff
(require ‘color-theme)
;; hook: test win sys and rerun color-theme
(defun test-win-sys(frame)
(let ((color-theme-is-global nil))

(select-frame frame)
(if (window-system frame)(color-theme-gnome2)(color-theme-tty-dark))))

;; hook on after-make-frame-functions
(add-hook ‘after-make-frame-functions ‘test-win-sys)

;; default coloue schemes start
(let ((color-theme-is-global nil))

(if (window-system)(color-theme-gnome2)(color-theme-tty-dark)))


[4] The Internet


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: