This the configuration I use for GNU Emacs.
.emacs
;;; These two lines are my real .emacs
(setq load-path (append '("~/elisp") load-path))
(load "init")
;;; From here onwards, emacs wrote it not me.
(put 'eval-expression 'disabled nil)
(put 'narrow-to-region 'disabled nil)
elisp/init.el
;;;
;;; Tim Waugh's emacs startup file
;;;
;;; Set up TeX mode to use some sensible defaults
(setq tex-dvi-view-command "xdvi")
(setq tex-directory "/tmp/")
;;; Don't add newlines when at the bottom of a document
(setq next-line-add-newlines nil)
;;; Universal diffs rule
(setq diff-switches "-u")
;;; Update copyright automatically
(add-hook 'write-file-hooks 'copyright-update)
;;; Scroll bar on right
(setq scroll-bar-mode "right")
(defun my-c-mode-common-hook ()
(c-set-style "K&R")
(setq c-basic-offset 8)
(c-toggle-auto-hungry-state 1)
)
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
;;; Turn on paragraph filling when going into text mode
(add-hook 'text-mode-hook 'turn-on-auto-fill)
;;; Turn on pound signs in text mode
(add-hook 'text-mode-hook
(function (lambda ()
(standard-display-european 1))))
;;; Make C-c C-g do M-x goto-line
(global-set-key "\C-c\C-g" 'goto-line)
;;; C-c C-z too, to pacify Xemacs
(global-set-key "\C-c\C-z" 'goto-line)
;;; No initial scratch message, thank you very much
(setq initial-scratch-message nil)
;;; Put the line number of the file into the status bar
(line-number-mode 42)
;;; Allow you to seamlessly edit .gz, .Z, files
(require 'crypt++)
(setq font-lock-maximum-decoration t)
(global-font-lock-mode)
;;; If this is under X, then move the mouse cursor out of the way of
;;; the text cursor when it gets in the way.
(cond (window-system
(require 'avoid)
(mouse-avoidance-mode 'cat-and-mouse)
;;; If this is X, then colour in C, Modula-3, pascal, perl, lisp, ML, etc
(setq hilit-mode-enable-list '(not text-mode c-mode)
hilit-background-mode 'light
hilit-inhibit-hooks nil
hilit-inhibit-rebinding nil)
(require 'hilit19)
;;; Under X, show matching parentheses
(show-paren-mode t)
))
;;; Editing a file ending in .m3, .i3, .ig, .mg fires up Modula-3 mode
(autoload 'modula-3-mode "modula3" "m3 mode" t)
(setq auto-mode-alist (cons '("\\.[im][g3]$" . modula-3-mode) auto-mode-alist))
;;; Editing a file ending in .ml puts emacs into ML mode
(autoload 'sml-mode "sml-mode" "Major mode for editing SML." t)
(setq auto-mode-alist (cons '("\\.ml$" . sml-mode) auto-mode-alist))
;;; Shell scripts
(autoload 'sh-mode "sh-mode" "Major mode for editing shell scripts" t)
(setq auto-mode-alist (cons '("\\.sh$" . sh-mode) auto-mode-alist))
(setq interpreter-mode-alist (cons '("sh" . sh-mode) interpreter-mode-alist))
(setq interpreter-mode-alist (cons '("bash" . sh-mode) interpreter-mode-alist))
;; Use text mode when editing mail messages
(setq auto-mode-alist
(cons '("^/tmp/\\(pico\\)\\|\\(mutt-\\)" . text-mode) auto-mode-alist))
;; For add-log
(setq user-mail-address "twaugh@redhat.com")
(setq user-full-name "Tim Waugh")