;;; My init.el file, used to initialize Emacs

;; Author: Michael W. Olson (mwolson AT gnu DOT org)

;; URL: http://www.mwolson.org/projects/EmacsConfigFiles.html

;; The code in this file may be used, distributed, and modified
;; without restriction.

;; I use initsplit.el to separate customize settings on a per-project
;; basis.

;; Comment-out any (load ...) statements that load files you haven't
;; downloaded from me by putting `;;' in front of each line you wish
;; to comment out.

;; Also: I have a fixation with getting all of my emacs-related
;; configuration and settings stuff into the ~/.emacs.d/ directory.
;; Feel free to disagree with me and do a `M-x replace-regexp
;; \.emacs\.d/ <RET> <RET>'.

;; If this seems to be too much for you, perhaps you should download
;; my `emacs-primer.el' file.  The settings are more likely to work on
;; older versions of Emacs and are less tweaked out than what you see
;; here.  `emacs-primer.el' was made especially for those who are
;; trying out Emacs and want some sane defaults.

;;; Pre-customization stuff

;; Stuff that might not be in every version of Emacs
(add-to-list 'load-path "~/elisp" t)

;;; This was installed by package-install.el.
;;; This provides support for the package system and
;;; interfacing with ELPA, the package archive.
;;; Move this code earlier if you want to reference
;;; packages in your .emacs.
(when
    (load
     (expand-file-name "~/.emacs.d/elpa/package.el"))
  (package-initialize))

;;(setq debug-on-quit t)

;;; Debian packages -- I'm eccentric enough to make my own handling of
;;; this.
(load "~/.emacs.d/debian-init")

;;; Customizations

(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.
 '(add-log-keep-changes-together t)
 '(add-log-mailing-address "mwolson@gnu.org")
 '(allout-auto-activation t)
 '(apropos-do-all t)
 '(archive-downloader-after-download-hook (quote (mwolson/archive-downloader-write-m3u)))
 '(auto-compression-mode t nil (jka-compr))
 '(backup-directory-alist (quote (("." . "~/.emacs.d/backup"))))
 '(blink-cursor-mode nil nil (frame))
 '(blink-matching-delay 10)
 '(blink-matching-paren-on-screen t)
 '(bookmark-default-file "~/.emacs.d/.bookmark")
 '(browse-url-browser-function (quote w3m-browse-url))
 '(browse-url-generic-program "gnome-open")
 '(browse-url-new-window-flag t)
 '(bsh-classpath (quote ("/usr/share/java")))
 '(bsh-jar "/usr/share/java/bsh.jar")
 '(change-log-mode-hook (quote ((lambda nil (flyspell-mode 1)))))
 '(column-number-mode t)
 '(confirm-kill-emacs (quote y-or-n-p))
 '(current-language-environment "UTF-8")
 '(debian-changelog-full-name "Michael W. Olson (GNU address)")
 '(debian-changelog-mailing-address "mwolson@gnu.org")
 '(debian-changelog-mode-hook (quote (turn-on-auto-fill flyspell-mode turn-on-muse-list-edit-minor-mode)))
 '(default-input-method "TeX")
 '(delete-selection-mode t)
 '(develock-auto-enable t)
 '(dict-noauth t)
 '(dictionary-server "dict.tu-graz.ac.at")
 '(dictionary-use-single-buffer t)
 '(diff-switches "-u")
 '(dired-dwim-target t)
 '(dired-recursive-copies (quote always))
 '(dired-recursive-deletes (quote always))
 '(eldoc-minor-mode-string " E")
 '(eldoc-mode t t)
 '(enable-recursive-minibuffers t)
 '(eshell-modules-list (quote (eshell-alias eshell-banner eshell-basic eshell-cmpl eshell-dirs eshell-glob eshell-hist eshell-ls eshell-pred eshell-prompt eshell-rebind eshell-script eshell-term)))
 '(eshell-prefer-to-shell nil nil (eshell))
 '(eshell-term-name "vt100")
 '(eshell-visual-commands (quote ("vi" "screen" "top" "less" "more" "lynx" "ncftp" "pine" "tin" "trn" "elm" "dbaccess" "menu" "senter2" "most" "emacs")))
 '(ffap-machine-p-known (quote reject))
 '(flyspell-issue-welcome-flag nil)
 '(footnote-body-tag-spacing 1)
 '(gc-cons-threshold 4000000)
 '(grep-find-command "find . -type f ! -regex \".*/\\({arch}\\|\\.arch-ids\\|\\.svn\\|_darcs\\|\\.bzr\\|\\.git\\|\\.hg\\)/.*\" -print0 | xargs -0 -e grep -nH -e ")
 '(highlight-nonselected-windows t)
 '(icomplete-mode t)
 '(ido-default-buffer-method (quote selected-window))
 '(ido-everywhere nil)
 '(ido-mode (quote buffer) nil (ido))
 '(ido-save-directory-list-file "~/.emacs.d/.ido.last")
 '(imaxima-fnt-size "LARGE")
 '(imaxima-use-maxima-mode-flag t)
 '(indent-tabs-mode nil)
 '(initsplit-customizations-alist (quote (("^bbdb-" "~/.emacs.d/bbdb-init.el" t) ("^blosxom-" "~/.emacs.d/blosxom-init.el" t) ("^\\(bzr\\|dvc\\|tla\\|xgit\\)-" "~/.emacs.d/dvc-init.el" nil) ("^emacs-wiki-" "~/.emacs.d/emacs-wiki-init.el" nil) ("^emms-" "~/.emacs.d/emms-init.el" nil) ("^idledo-" "~/.emacs.d/erbot-init.el" t) ("^erc-" "~/.emacs.d/erc-init.el" nil) ("^jde-" "~/.emacs.d/jde-init.el" nil) ("^journal-" "~/.emacs.d/journal-init.el" t) ("^nethack-" "~/.emacs.d/nethack-init.el" t) ("^\\(appt\\|diary\\|planner\\|remember\\|calendar\\)-" "~/.emacs.d/planner-init.el" t) ("^\\(canlock\\|epg\\|gnus\\|message\\|mm\\|nnimap\\|nnmail\\|pgg\\|smtpmail\\|tls\\)-" "~/.emacs.d/.gnus.el" t) ("^muse-" "~/.emacs.d/muse-init.el" t) ("^\\(w3m\\|swc\\|simple-wiki\\)-" "~/.emacs.d/w3m-init.el" t))))
 '(initsplit-sort-customizations t)
 '(ispell-local-dictionary "american")
 '(ispell-personal-dictionary nil)
 '(ispell-program-name "aspell")
 '(ispell-silently-savep t)
 '(ledger-data-file "~/ledger-data")
 '(ls-lisp-dirs-first t)
 '(ls-lisp-ignore-case t)
 '(ls-lisp-support-shell-wildcards nil)
 '(ls-lisp-use-insert-directory-program nil)
 '(mail-interactive t)
 '(mail-user-agent (quote gnus-user-agent))
 '(mark-diary-entries-in-calendar t)
 '(max-lisp-eval-depth 1000)
 '(max-specpdl-size 1000)
 '(mouse-autoselect-window nil)
 '(mouse-wheel-mode t)
 '(mpc-mpd-music-directory "/stuff/music/mpd/tracks")
 '(post-email-address "mwolson@member.fsf.org")
 '(post-jump-header nil)
 '(recentf-mode nil)
 '(recentf-save-file "~/.emacs.d/.recentf")
 '(require-final-newline nil)
 '(safe-local-variable-values (quote ((unibyte . t) (flyspell-mode . -1) (allout-layout * 0 :))))
 '(save-place t nil (saveplace))
 '(save-place-file "~/.emacs.d/.places")
 '(save-place-limit 20)
 '(scroll-bar-mode nil)
 '(semanticdb-default-save-directory "~/.emacs.d/.semantic")
 '(session-save-file "/home/mwolson/.emacs.d/.session")
 '(show-paren-mode t)
 '(show-paren-style (quote parenthesis))
 '(sql-product (quote mysql))
 '(tab-stop-list (quote (4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100 104 108 112 116 120)))
 '(tab-width 8)
 '(text-mode-hook (quote (text-mode-hook-identify flyspell-mode-on)))
 '(todo-initials "mwo")
 '(tool-bar-mode nil)
 '(tooltip-use-echo-area t)
 '(tramp-auto-save-directory "~/.emacs.d/.autosave.d")
 '(tramp-backup-directory-alist (quote (("." . "~/.emacs.d/backup"))))
 '(tramp-remote-path (quote ("/usr/xpg4/bin" "/bin" "/usr/bin" "/usr/sbin" "/usr/local/bin" "/usr/ccs/bin" "/local/bin" "/local/freeware/bin" "/local/gnu/bin" "/usr/freeware/bin" "/usr/pkg/bin" "/usr/contrib/bin" "/p/perl/bin")))
 '(transient-mark-mode t)
 '(tumme-db-file "~/.emacs.d/.tumme/.tumme_db")
 '(tumme-dir "~/.emacs.d/.tumme/")
 '(tumme-external-viewer "display")
 '(tumme-gallery-dir "~/.emacs.d/.tumme/.tumme_gallery")
 '(tumme-main-image-directory "/stuff/pics/")
 '(tumme-temp-image-file "~/.emacs.d/.tumme/.tumme_temp")
 '(tumme-temp-rotate-image-file "~/.emacs.d/.tumme/.tumme_rotate_temp")
 '(tumme-thumbs-per-row 4)
 '(user-full-name "Michael Olson")
 '(user-mail-address "mwolson@member.fsf.org")
 '(vc-handled-backends (quote (RCS CVS SVN SCCS MCVS)))
 '(visible-bell t)
 '(winner-mode t nil (winner))
 '(woman-fill-column 72)
 '(woman-use-own-frame nil)
 '(wtf-custom-alist nil)
 '(wtf-removed-acronyms nil)
 '(x-select-enable-clipboard t))
(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 "Gainsboro" :foreground "black" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 130 :width semi-condensed :family "misc-fixed"))))
 '(font-lock-builtin-face ((((class color) (min-colors 88) (background light)) (:foreground "medium purple"))))
 '(font-lock-constant-face ((((class color) (min-colors 88) (background light)) (:foreground "medium slate blue"))))
 '(font-lock-string-face ((((class color) (min-colors 88) (background light)) (:foreground "forest green"))))
 '(font-lock-type-face ((((class color) (min-colors 88) (background light)) (:foreground "dodger blue"))))
 '(font-lock-variable-name-face ((((class color) (min-colors 88) (background light)) (:foreground "sienna"))))
 '(region ((((class color) (min-colors 88) (background light)) (:background "RoyalBlue2" :foreground "white"))))
 '(woman-italic ((t (:underline t :slant italic)))))

;;; Display

;; Set fonts
;; old: mule-unicode-0100-24ff:
;; -*-gothic-medium-r-normal-*-*-*-*-*-*-*-iso10646-1")

(when window-system
  ;; Make Greek characters look decent
  (create-fontset-from-fontset-spec
   "-*-terminus-medium-r-*-*-14-*-*-*-*-*-iso8859-15,
mule-unicode-0100-24ff:-*-freemono-medium-r-*-*-17-*-*-*-c-*-iso10646-1,
mule-unicode-2500-33ff:-*-freemono-medium-r-*-*-17-*-*-*-c-*-iso10646-1")

  (defun my-reset-font ()
    (interactive)
    (set-face-font 'default "-*-terminus-medium-r-*-*-14-*-*-*-*-*-iso8859-15")
    (setq-default line-spacing 1))
  (my-reset-font)

  (defun my-reset-frame-size ()
    "Reset the size of the current frame according to `default-frame-alist'."
    (interactive)
    (dolist (param '(width height))
      (set-frame-parameter nil param (cdr (assoc param default-frame-alist)))))

  ;; the width and height get changed inexplicably when the font
  ;; changes; this changes them back
  (my-reset-frame-size))

;;; Process startup files

;; Make additions to global-mode-string work as expected
(setq global-mode-string '(""))

;; Make sure DEL key does what I want
(when window-system
  (normal-erase-is-backspace-mode 1))

;;; This should not be evaluated when I use sudo
(when (not (string-equal "root" (getenv "USER")))
  (load "~/.emacs.d/bbdb-init")
;;  (load "~/.emacs.d/circe-init")
;;  (load "~/.emacs.d/emacs-wiki-init")
  (load "~/.emacs.d/emms-init")
;;  (load "~/.emacs.d/erbot-init")
  (load "~/.emacs.d/erc-init")
  (load "~/.emacs.d/gnus-init")
  (load "~/.emacs.d/muse-init")
  (load "~/.emacs.d/nethack-init")
  (load "~/.emacs.d/planner-init")
;;  (load "~/.emacs.d/xtla-init")
  (load "~/.emacs.d/dvc-init")
;;  (load "~/.emacs.d/w3m-init")
  (load "~/.emacs.d/auctex-init"))

;;; Functions

;; I'd prefer to use the gnome-open command, but it was being a pain
(defun my-fsck-gnome-open (url &rest crap)
  "Just open a browser window in a sane manner."
  (interactive (browse-url-interactive-arg "URL: "))
  (start-process (concat "firefox " url)
                 nil
                 "firefox" url))

(defun count-words (start end)
  "Print number of words in the region."
  (interactive "r")
  (save-excursion
    (let ((n 0))
      (goto-char start)
      (while (< (point) end)
        (when (forward-word 1)
          (setq n (1+ n))))
      (message "Region has %d words" n)
      n)))

(defmacro match-data-changed (&rest body)
  "Determine whether the match data has been modified by BODY."
  (let ((mdata (make-symbol "temp-buffer")))
    `(let ((,mdata (match-data)))
       (prog1 ,@body
         (if (equal ,mdata (match-data))
             (message "Match data has not been changed")
           (message "Match data has been changed!"))))))

(put 'match-data-changed 'lisp-indent-function 0)
(put 'match-data-changed 'edebug-form-spec '(body))

(defun byte-compile-this-file-temporarily ()
  (interactive)
  (let ((file buffer-file-name))
    (byte-compile-file file)
    (save-match-data
      (when (string-match "\\.el$" file)
        (delete-file (concat file "c"))))))

;;; Things that can't be changed easily using `customize'

;; Enable some commands
(put 'downcase-region 'disabled nil)
(put 'scroll-left 'disabled nil)
(put 'upcase-region 'disabled nil)

;; Make URL configuration directory conform
(setq url-configuration-directory "~/.emacs.d/.url")

;; Show lots of messages in the *Messages* buffer
(setq message-log-max 500)

;; Load `dired' itself, with `tramp' extension
(require 'dired)
(require 'dired-x)
(require 'wdired)
(require 'tramp)

;; List directories first in dired
(require 'ls-lisp)

;; Prefer woman to man for man pages
(require 'man)
(require 'woman)
(fset 'man-ext (symbol-function 'man))
(defalias 'man 'woman)

;; Pre-load this so it doesn't spew messages at me later
(condition-case nil
    (require 'eieio-opt)
  (error nil))

;; Use develock
(require 'develock)

;; Enable subversion support
(require 'vc-svn)
(require 'psvn)

;; Enable darcs support
(require 'vc-darcs)
(add-to-list 'vc-handled-backends 'DARCS)

;; Bind N and P in ediff so that I don't leave the control buffer
(defun my-ediff-next-difference (&rest args)
  (interactive)
  (save-selected-window
    (call-interactively 'ediff-next-difference)))

(defun my-ediff-previous-difference (&rest args)
  (interactive)
  (save-selected-window
    (call-interactively 'ediff-previous-difference)))

(defun my-ediff-extra-keys ()
  (define-key ediff-mode-map (kbd "N") #'my-ediff-next-difference)
  (define-key ediff-mode-map (kbd "P") #'my-ediff-previous-difference))
(add-hook 'ediff-keymap-setup-hook 'my-ediff-extra-keys)

;; Make TexInfo easier to work with
(defun my-texinfo-view-file ()
  "View the published version of the current file."
  (interactive)
  (let ((file (buffer-file-name)))
    (when (string-match "\\.tex\\(i\\|info\\)?\\'" file)
      (setq file (replace-match ".info" t t file))
      (when (buffer-live-p (get-buffer "*info*"))
        (kill-buffer "*info*"))
      (info file))))

(defun my-texinfo-extra-keys ()
  "Make texinfo stuff easier to work with."
  (define-key texinfo-mode-map (kbd "C-c C-p") #'makeinfo-buffer)
  (define-key texinfo-mode-map (kbd "C-c C-v") #'my-texinfo-view-file))
(add-hook 'texinfo-mode-hook 'my-texinfo-extra-keys)

;; Check out Stefan Monnier's mpc.el file
;;(add-to-list 'load-path "/stuff/proj/emacs/mpc/")
;;(require 'mpc)

;; Load lisp integration mode
;(add-to-list 'load-path "~/proj/emacs/slime-2.0" t)
(setq inferior-lisp-program "clisp")
(require 'slime)
;; work around bug in SLIME: nonexistent fn 'slime-quit
(define-key slime-repl-mode-map (kbd "C-c M-g") #'slime-quit-lisp)

;; Don't warn me when opening some Common Lisp files
(put 'package 'safe-local-variable 'symbolp)
(put 'Package 'safe-local-variable 'symbolp)
(put 'syntax 'safe-local-variable 'symbolp)
(put 'Syntax 'safe-local-variable 'symbolp)
(put 'Base 'safe-local-variable 'integerp)
(put 'base 'safe-local-variable 'integerp)

;; Deal with javacc stuff
(add-to-list 'auto-mode-alist '("\\.jj\\'" . java-mode))
(defun my-java-mode-stuff ()
  "Deal with the love of tabs."
  (setq indent-tabs-mode nil
        tab-width 4
        c-syntactic-indentation nil))
;; (eval-after-load "cc-mode"
;;   '(progn
;;      (define-key java-mode-map "\t" 'self-insert-command)))
;;(require 'beanshell) ; needs eieio, which I detest

;; spellcheck comments and documentation
(add-hook 'lisp-mode-hook 'flyspell-prog-mode)
(add-hook 'emacs-lisp-mode-hook 'flyspell-prog-mode)
(eval-after-load "cc-mode"
  '(progn
     (add-hook 'java-mode-hook 'my-java-mode-stuff)
     (add-hook 'java-mode-hook 'flyspell-prog-mode)
     (add-hook 'c-mode-hook 'flyspell-prog-mode)))

(defun stupid-4tabs-mode ()
  "Deal with the silly programmers who use the assumption TAB=4 spaces."
  (interactive)
  (setq indent-tabs-mode t
        tab-width 4
        c-syntactic-indentation nil)
  (develock-refontify-buffers))

;; Enable wdired on "r"
(define-key dired-mode-map "r" 'wdired-change-to-wdired-mode)

;; Make tramp's backup directories the same as the normal ones
(setq tramp-backup-directory-alist backup-directory-alist)

;; Don't show the menu unless we are using X
(unless window-system
  (menu-bar-mode 0))

;; Find funtions and files at point
(ffap-bindings)

;; Grand Unified Debugger
(require 'gud)

;; Show Emacs where to find its source files
(setq find-function-C-source-directory "/stuff/proj/emacs/emacs/git-emacs/src/")

;; Navigate the kill ring with the greatest of ease when doing M-y
(require 'browse-kill-ring)
(defadvice yank-pop (around kill-ring-browse-maybe (arg))
  "If last action was not a yank, run `browse-kill-ring' instead."
  (if (not (eq last-command 'yank))
      (browse-kill-ring)
    ad-do-it))
(ad-activate 'yank-pop)

;; Hack CSS mode
(setq cssm-newline-before-closing-bracket t)
(setq cssm-indent-function #'cssm-c-style-indenter)

;; Load imaxima
(add-to-list 'load-path "~/proj/emacs/imaxima-imath")
(require 'imaxima)

;; Split up various customizations into different files
(require 'initsplit)

;; Load info and sml-mode before trying to deal with their mode maps
(require 'info)
(require 'sml-mode)

;; Put abbrevs in their proper place
(setq abbrev-file-name "~/.emacs.d/.abbrev_defs")

;; Make a passable attempt at using UTF-8 in buffers
(setq default-buffer-file-coding-system 'utf-8)
(prefer-coding-system 'utf-8)

;; Load some miscellaneous files that I've made
(add-to-list 'load-path "~/proj/emacs/misc")
;; an attempt to code some things from my algorithms class as Lisp
(require 'algorithms)
;; wtf mode, which provides abbreviations and definitions
(require 'wtf)
;; a snazzy downloader of OGG tunes from archive.org
(require 'archive-downloader)

;; I don't know if I'll ever want this, but here's a paperclip ripoff
;; in the spirit of mockery for M$ Office
;;(require 'paperclip)

;; Load ledger
;;(require 'ledger)

;; Load nxml-mode
;; (add-to-list 'load-path "/usr/share/emacs/site-lisp/nxml-mode/")
;; (setq rng-schema-locating-file-schema-file
;;       "/usr/share/emacs/site-lisp/nxml-mode/schema/locate.rnc")
;; (setq rng-schema-locating-files
;;       '("schemas.xml" "/usr/share/emacs/site-lisp/nxml-mode/schema/schemas.xml"))

;; Load xscheme
;; (require 'xscheme)
;; (define-key scheme-interaction-mode-map "\C-c\C-e"
;;   #'advertised-xscheme-send-previous-expression)

;; Load scheme48.el
(require 'scheme48)
;; (add-hook 'hack-local-variables-hook
;;           (lambda ()
;;             (if (and (boundp 'scheme48-package)
;;                      scheme48-package)
;;                 (progn (scheme48-mode)
;;                        (hack-local-variables-prop-line)))))

(defun run-scheme-kali-ref ()
  (interactive)
  (let ((default-directory "/stuff/proj/research/s48/kali.reference/"))
    (run-scheme (concat default-directory "scheme48vm -i "
                        default-directory "scheme48.image"))))

(defun run-scheme-kali ()
  (interactive)
  (let ((default-directory "/stuff/proj/research/s48/kali/"))
    (run-scheme (concat default-directory "scheme48vm -i "
                        default-directory "scheme48.image"))))

(defun run-scheme-devel ()
  (interactive)
  (let ((default-directory "/stuff/proj/research/s48/devel/"))
    (run-scheme (concat default-directory "scheme48vm -i "
                        default-directory "scheme48.image"))))

;; Load flyspell mode
(require 'flyspell)

(defun my-parse-commandline-option (opt expect-followup)
  (let ((ret nil)
        (args nil))
    (while command-line-args
      (if (string= opt (car command-line-args))
          (progn
            (if expect-followup
                (progn
                  (setq ret (cadr command-line-args)
                        command-line-args (cddr command-line-args)))
              (setq ret t
                    command-line-args (cdr command-line-args))))
        (add-to-list 'args (car command-line-args) t)
        (setq command-line-args (cdr command-line-args))))
    (setq command-line-args args)
    ret))

;; Bring up planner page
(when (and (fboundp 'plan)
           (not (my-parse-commandline-option "--no-plan" nil)))
  (plan))

;;; Key customizations

(global-set-key "\C-cb" 'bbdb-display)
(global-set-key "\C-xg" 'goto-line)

;; Make adding entries to debian/changelog easy
(global-set-key "\C-xD" nil)
(global-set-key "\C-xDa" 'debian-changelog-add-entry)

;; Map some keys to find-function/find-variable
(global-set-key "\C-xF" nil)
(global-set-key "\C-xFf" 'find-function)
(global-set-key "\C-xFv" 'find-variable)
(global-set-key "\C-xFl" 'find-library)
(global-set-key "\C-xFa" 'find-face-definition)

;; Open a location quickly

(global-set-key "\C-ca" nil)

(global-set-key "\C-cae" (lambda () (interactive)
    (find-file                          ; work machine
     "/ssh:mwolson@exabyte.rcac.purdue.edu:/home/mwolson")))

(global-set-key "\C-caf" (lambda () (interactive)
    (find-file                          ; sourceforge server
     "/ssh:bigmike160@hangit.sf.org:/home/groups/h/ha/hangit")))

(global-set-key "\C-cak" (lambda () (interactive)
    (find-file                          ; work machine
     "/ssh:mwolson@kilobyte.rcac.purdue.edu:/home/mwolson")))

(global-set-key "\C-cah" nil)

(global-set-key "\C-caha" (lambda () (interactive)
    (find-file                          ; hcoop shell server
     "/ssh:mwolson@abulafia.hcoop.net:/etc")))

(global-set-key "\C-cahd" (lambda () (interactive)
    (find-file                          ; static hcoop server
     "/ssh:mwolson_admin@deleuze.hcoop.net#2222:/etc")))

(global-set-key "\C-cahf" (lambda () (interactive)
    (find-file                          ; primary hcoop server
     "/ssh:mwolson@fyodor.hcoop.net:/home/mwolson")))

(global-set-key "\C-cahm" (lambda () (interactive)
    (find-file                          ; dynamic hcoop server
     "/ssh:mwolson_admin@mire.hcoop.net:/etc")))

(global-set-key "\C-cal" (lambda () (interactive)
    (find-file                          ; lore undergrad server
     "/ssh:mwolson@lore.cs.purdue.edu:/homes/mwolson")))

(global-set-key "\C-cam" (lambda () (interactive)
    (find-file                          ; mentor server
     "/ssh:mwolson@mentor.cc.purdue.edu:/home/champion/v2/mwolson")))

(global-set-key "\C-cap" nil)

(global-set-key "\C-capm" (lambda () (interactive)
    (find-file                          ; PLUG music
     "/ssh:mwolson@plugmail:/home/mwolson")))

(global-set-key "\C-capo" (lambda () (interactive)
    (find-file                          ; PLUG office
     "/ssh:mwolson@plugoffice:/home/mwolson")))

(global-set-key "\C-capp" (lambda () (interactive)
    (find-file                          ; PLUG projects
     "/ssh:mwolson@plugprojects:/home/mwolson")))

(global-set-key "\C-capw" (lambda () (interactive)
    (find-file                          ; PLUG web
     "/ssh:mwolson@plugweb:/home/mwolson")))

(global-set-key "\C-caw" (lambda () (interactive)
    (find-file                          ; webmastering work
     "/ssh:mwolson@csociety.ecn.purdue.edu:/home/plug")))

(global-set-key "\C-cau" (lambda () (interactive)
    (find-file                          ; sudo on local server
     "/sudo::/")))

;; CS565 cruft
(global-set-key "\C-ct"
                (lambda () (interactive)
                  (insert "CM.make(\"sources.cm\"); MiniML.interpreter();")))

;; I don't have any lost love for the <insert> key, so disable it
(global-set-key [insert] (lambda () (interactive)))
(global-set-key [insertchar] (lambda () (interactive)))

;; Disable the C-z key and its variant
(global-set-key "\C-z" (lambda () (interactive)))
(global-set-key "\C-x\C-z" (lambda () (interactive)))

;; Make the `q' key bury the current buffer when viewing help
(define-key view-mode-map "q" 'bury-buffer)

;; Make the <DEL> key scroll backwards in Info mode
(define-key Info-mode-map [delete] 'Info-scroll-down)

;; Make the <DEL> key scroll backwards in View mode
(define-key view-mode-map [delete] 'View-scroll-page-backward)

;; Bad diff-mode!  Don't mess with M-q
(define-key diff-mode-map (kbd "M-q") 'fill-paragraph)

;; Bad SML mode!  Don't mess with M-SPC
(define-key sml-mode-map (kbd "M-SPC") 'just-one-space)

;; I don't like the buffer list
(global-set-key "\C-x\C-b" 'ido-switch-buffer)

;; Boo to transpose
(global-set-key "\C-t" (lambda () (interactive)))

;;; Do things differently if I am using sudo

(if (string-equal "root" (getenv "USER"))
    ;; If user is root (sudo-ing), do these things

    ;; Change default directory to /etc
    (cd "/etc")

  ;; If user is normal, do these things

  ;; Start server
  (require 'server)
  (server-start)

  ;; Change default directory to ~
  (cd (expand-file-name "~")))

;;; init.el ends here