Example Emacs Configuration

There are uncountable ways to configure your Emacs. Over time I've found it extremely helpful to look at other people's configuration to find out about new tricks I didn't know before. This is why I'm providing my current configuration here for you to look at and hopefully benefit from it in some way.

You can also download my .emacs file in plain text format.




;; -*- mode: emacs-lisp -*-

; First, avoid the evil:
(when (featurep 'xemacs)
  (error "This machine runs xemacs, install GNU Emacs first."))

; Make ö, ü and such work
(set-language-environment 'german)
(set-terminal-coding-system 'iso-latin-1)

; Save space
(menu-bar-mode nil)

; Handle .gz files
(auto-compression-mode t)

; Provide templates for new files
(auto-insert-mode t)

; Allow completions like em-s-region to complete to emacspeak-speak-region
(partial-completion-mode)

; This somehow produced a failure on excelior
(add-hook 'after-init-hook 'server-start)
(add-hook 'server-done-hook
	  (lambda ()
	    (shell-command "screen -r -X select `cat ~/tmp/emacsclient-caller`")))

(add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)

(unless (featurep 'emacspeak)
  (add-hook 'emacs-lisp-mode-hook 'eldoc-mode))

; Update string in the first 8 lines looking like Timestamp: <> or " "
(add-hook 'write-file-hooks 'time-stamp)

(setq diary-file "~/emacs/diary")
(add-hook 'diary-hook 'appt-make-list)
(diary 0)

(eval-after-load "em-term"
  '(add-to-list 'eshell-visual-commands "zsh"))

(let ((chessdir (expand-file-name
		 "~/emacs/lisp/chess")))
  (when (file-directory-p chessdir)
    (add-to-list 'load-path chessdir)
    (setq chess-sound-directory (concat chessdir "/sounds"))))
(when (load "chess-auto" t)
  (setq
   chess-default-display 'chess-plain
   chess-ics-server-list '(("freechess.org" 5000 "mlang"))
   chess-plain-black-square-char 43
   chess-plain-draw-border t
   chess-plain-white-square-char 45
   chess-plain-spacing 0))


(setq gnus-init-file "~/emacs/.gnus.el")

; Use C-xaig to correct common typos
(setq abbrev-file-name "~/emacs/abbrev_defs")
(if (file-exists-p abbrev-file-name)
    (quietly-read-abbrev-file))
(set-default 'abbrev-mode t)

;; Misc options I just prefer everytime
(setq cperl-indent-level 2
      custom-buffer-indent 2
      gc-cons-threshold (* 1024 1024)
      european-calendar-style t
      mail-user-agent 'message-user-agent
      message-generate-headers-first t
      w3-display-frames 'ask
      widget-choice-toggle t
      widget-menu-minibuffer-flag t
      url-privacy-level '(os agent)
      vc-cvs-diff-switches "-u")


(put 'narrow-to-region 'disabled nil)


(require 'crypt++ nil t)
(setq crypt-encryption-type 'mcrypt)


(add-to-list 'load-path (expand-file-name "~/emacs/lisp/"))
(require 'itime)
(setq display-time-string-forms
      '(24-hours ":" minutes " "
		 (itime-string 24-hours minutes seconds)
		 (if mail
		     " Mail"
		   ""))
       display-time-interval 30)
(display-time-mode 1)


(condition-case data
    (let ((default-directory "~/emacs/"))
      (load-file "./local"))
  (file-error 'notfound))


(if (file-exists-p
     (setq custom-file
	   (concat "~/emacs/custom-"
		   (int-to-string emacs-major-version))))
    (load-file custom-file))


(unless (featurep 'emacspeak)
  (global-semantic-auto-parse-mode 1)
  (unless (featurep 'emacspeak)
    (setq semantic-auto-parse-no-working-message t))
  (add-hook 'semantic-init-hooks 'senator-minor-mode))


;; Emacs wiki

(require 'emacs-wiki)
(add-to-list 'emacs-wiki-interwiki-names '("Bug" . "http://bugs.debian.org/"))
(add-to-list 'emacs-wiki-interwiki-names '("Package" . "http://packages.debian.org/"))
(setq
 emacs-wiki-projects
 '(
   ("PrivateNotes"
    (emacs-wiki-directories "~/doc/private"))
   ("DebianWiki"
    (emacs-wiki-directories "~/debian/notes")
;    (emacs-wiki-publishing-directory . "/[su/mlang@gluck.debian.org]~/public_html/")
    (emacs-wiki-publishing-directory . "~/debian/public_html")
    )))

(when (featurep 'emacspeak)
  (defun viavoice-set-language (lang)
    (cond
     ((eq lang 'german)
      (dtk-interp-queue "`l4 Deutsch")
    (dtk-interp-speak))
     ((eq lang 'english)
      (dtk-interp-queue "`l1 English")
      (dtk-interp-speak))
     (t (error "Unknown language"))))
  (defun emacspeak-set-language-to-german ()
    (interactive)
    (viavoice-set-language 'german))
  (defun emacspeak-set-language-to-english ()
    (interactive)
    (viavoice-set-language 'english))
  (global-set-key (kbd "C-c e") 'emacspeak-set-language-to-english)
  (global-set-key (kbd "C-c d") 'emacspeak-set-language-to-german))

(define-prefix-command 'f8-map nil "f7=grep, f8=compile")
(define-key f8-map [f8] 'compile)
(define-key f8-map [f7] 'grep)
(global-set-key [f8] 'f8-map)
(custom-set-variables
 '(load-home-init-file t t))
(custom-set-faces)

Last Modified: 2006-11-27 00:01:38
You can view the Source Code of this page