Emacs configuration - mostly just loading the modes I need. There isn't a whole lot of customization.
;;; Emacs configuration file
;; Base text mode and other configuration ------------------------------
(setq inhibit-startup-message t)
(setq initial-scratch-message nil)
(setq default-major-mode 'text-mode)
(line-number-mode t)
(column-number-mode t)
(scroll-bar-mode nil)
(show-paren-mode t)
(transient-mark-mode t)
(mouse-wheel-mode t)
(setq-default inhibit-eol-conversion t)
; Base of user Emacs Lisp libraries
(add-to-list 'load-path "~/elisp")
;; Font lock support ---------------------------------------------------
;(setq font-lock-support-mode '((latex-mode . fast-lock-mode) (t . lazy-lock-mode)))
(add-hook 'after-init-hook '(lambda () (global-font-lock-mode 1)))
(require 'font-lock)
;; Calendar and diary stuff --------------------------------------------
(display-time)
(add-hook 'diary-hook 'appt-make-list)
(diary 0)
;; X related setup -----------------------------------------------------
(if (and (fboundp window-system)
(window-system))
(progn
(setq x-pointer-shape x-pointer-left-ptr)
(setq mouse-scroll-delay 0)
(setq x-selection-timeout 0)))
;; emacsclient: automatic popup under X11 ------------------------------
(defun server-make-window-visible ()
"Try to make this window even more visible."
(if window-system
(progn
(let ((foo (selected-frame)))
(sit-for 0)
(make-frame-visible foo))
(accept-process-output))))
(add-hook 'server-switch-hook '(lambda () (server-make-window-visible)))
(add-hook 'server-visit-hook '(lambda () (server-make-window-visible)))
;; kill-emacs-hook does not seem to do what I would want.
(defvar my-before-kill-emacs-hook nil
"Hook to run before `save-buffers-kill-emacs'.")
(defadvice save-buffers-kill-emacs (around before-kill-hook activate)
"Run `my-before-kill-emacs-hook' before save-buffers-kill-emacs."
;; This is so that an abortive exit does not mess up our session.
;; Also quite nice since it means we do not get prompted to save
;; files etc unless we have really decided to exit emacs.
;; But maybe we will change our mind if we know files have to be saved?
(when (yes-or-no-p "Really exit Emacs? ")
(run-hooks 'my-before-kill-emacs-hook)
(setq confirm-kill-emacs nil) ; no need to ask twice
ad-do-it))
(defun my-server-delete-socket ()
"Delete the server socket."
(if (boundp 'server-socket-dir)
;; delete-directory only for empty directories.
(call-process "rm" nil nil nil "-r" server-socket-dir)
(delete-file (format "/tmp/emacs%s/server" (user-uid)))))
;; Note this hook does not seem to work reliably with `kill-emacs-hook'.
;; `my-before-kill-emacs-hook' prompts before starting exit, so
;; as not to needlessly kill server.
(add-hook 'my-before-kill-emacs-hook 'my-server-delete-socket)
(server-start)
;; Interactively do ----------------------------------------------------
(ido-mode t)
;; Gnus news and mail --------------------------------------------------
(setq user-mail-address "jbromley@gmail.com")
(setq user-full-name "Jay Bromley")
(load-library "smtpmail")
(load-library "nnimap")
(load-library "starttls")
(setq gnus-invalid-group-regexp "[:`'\"]\\|^$")
(setq gnus-ignored-newsgroups "")
(setq gnus-thread-hide-subtree t)
(setq gnus-select-method '(nntp "news.dslextreme.com"))
(add-to-list 'gnus-secondary-select-methods
'(nnimap "gmail"
(nnimap-address "imap.gmail.com")
(nnimap-server-port 993)
(nnimap-authinfo-file "~/.authinfo")
(nnimap-stream ssl)))
(setq smtpmail-starttls-credentials '(("smtp.gmail.com" 587 nil nil))
smtpmail-default-smtp-server "smtp.gmail.com"
smtpmail-smtp-server "smtp.gmail.com"
message-send-mail-function 'smtpmail-send-it
smtpmail-smtp-service 587
smtpmail-auth-credentials '(("smtp.gmail.com" 587 "jbromley@gmail.com" nil)))
;; Redo mode -----------------------------------------------------------
(require 'redo)
; Unset zap-to-char, Ctrl+z (minimize) and Ctrl+Z (?)
(global-unset-key "\M-z")
(global-unset-key "\C-z")
(global-unset-key "\C-Z")
; Move minimize to Alt+z so that undo will be more Windows-like
(global-set-key "\M-z" 'iconify-or-deiconify-frame)
; Set some decent undo/redo keys.
(global-set-key "\C-z" 'undo)
(global-set-key [?\C-\S-z] 'redo)
;; Org mode -----------------------------------------------------------
;; (add-to-list 'load-path "~/elisp/org")
;; (require 'org-install)
;; (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
;; (define-key global-map "\C-cl" 'org-store-link)
;; (define-key global-map "\C-ca" 'org-agenda)
;; (setq org-log-done t)
;; (setq org-agenda-include-diary t)
;; Remember mode ------------------------------------------------------
(add-to-list 'load-path "~/elisp/remember")
(require 'remember-autoloads)
;; Muse mode ----------------------------------------------------------
(require 'muse-mode)
(require 'muse-html)
; (require 'muse-latex)
(require 'muse-project)
(require 'muse-journal)
;; Planner mode --------------------------------------------------------
(setq planner-project "WikiPlanner")
;; The following is set using the emacs customization mode
;; (setq muse-project-alist
;; '(("WikiPlanner"
;; ("~/plans"
;; :default "TaskPool"
;; :major-mode planner-mode
;; :visit-link planner-visit-link)
;; (:base "planner-xhtml" :path "~/public/plans"))))
(require 'planner)
(require 'planner-multi)
(require 'planner-diary)
(require 'remember-planner)
; Diary integration
(add-hook 'diary-display-hook 'fancy-diary-display)
; Remember integration
(setq remember-handler-functions '(remember-planner-append))
(setq remember-annotation-functions planner-annotation-functions)
(global-set-key (kbd "C-c r") 'remember)
;; Ruby mode -----------------------------------------------------------
(autoload 'ruby-mode "ruby-mode" "Ruby Mode." t)
(add-to-list 'auto-mode-alist '("\\.rb\\'" . ruby-mode))
;; Python mode ---------------------------------------------------------
(autoload 'python-mode "python-mode.el" "Python mode." t)
(setq auto-mode-alist (append '(("/*.\.py$" . python-mode)) auto-mode-alist))
;; Lua mode ------------------------------------------------------------
(setq auto-mode-alist (cons '("\.lua$" . lua-mode) auto-mode-alist))
(autoload 'lua-mode "lua-mode" "Lua editing mode." t)
;; Distel mode for Erlang ----------------------------------------------
(add-to-list 'load-path "~/elisp/distel")
(setq erlang-root-dir "/usr/lib/erlang")
;;(setq load-path (cons "/usr/local/lib/erlang/lib/tools-2.5.1/emacs" load-path))
(setq exec-path (cons "/usr/lib/erlang/bin" exec-path))
(require 'erlang-start)
;; This is needed for Distel setup
(let ((distel-dir "~/elisp/distel/elisp"))
(unless (member distel-dir load-path)
;; Add distel-dir to the end of load-path
(setq load-path (append load-path (list distel-dir)))))
(require 'distel)
(distel-setup)
;; Haskell mode --------------------------------------------------------
(setq auto-mode-alist
(append auto-mode-alist
'(("\\.[hg]s$" . haskell-mode)
("\\.hi$" . haskell-mode)
("\\.l[hg]s$" . literate-haskell-mode))))
(autoload 'haskell-mode "haskell-mode"
"Major mode for editing Haskell scripts." t)
(autoload 'literate-haskell-mode "haskell-mode"
"Major mode for editing literate Haskell scripts." t)
(add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
; Only enable one of the following indent modes
(add-hook 'haskell-mode-hook 'turn-on-haskell-indent)
;(add-hook 'haskell-mode-hook 'turn-on-haskell-simple-indent)
(add-hook 'haskell-mode-hook
#'(lambda ()
(setq comment-padding " ")
(setq comment-start "--")))
;; Color themes --------------------------------------------------------
(require 'color-theme)
; The following fixes some problems with faces and emacs 22
(defun color-theme-face-attr-construct (face frame)
(if (atom face)
(custom-face-attributes-get face frame)
(if (and (consp face) (eq (car face) 'quote))
(custom-face-attributes-get (cadr face) frame)
(custom-face-attributes-get (car face) frame))))
;; Open non-text files -------------------------------------------------
(defun open-document-file (fname)
(interactive "FOpen file: ")
(let ((file-extension (nth 0 (last (split-string fname "\\.")))))
(cond
((string= file-extension "doc")
(setq open-command (concat "antiword \\"" fname "\\"")))
((string= file-extension "xls")
(setq open-command
(concat "xlhtml " fname " 2>/dev/null | w3m -T text/html -dump")))
((string= file-extension "pps")
(setq open-command
(concat "ppthtml " fname " 2>/dev/null | w3m -T text/html -dump")))
((t) nil))
(let ((buf (create-file-buffer fname)))
(shell-command open-command buf)
(set-buffer buf)
(kill-line)(kill-line)
(toggle-read-only)
(not-modified))))
;; Custom settings file ------------------------------------------------
(setq custom-file "~/.emacs-custom")
(load "~/.emacs-custom" t t)
(put 'narrow-to-region 'disabled nil)