;;; primer.el --- My .emacs file, made simpler

;; Author: Michael Olson

;; This file is meant for those who want Emacs to start up with sane
;; defaults, like coloring and stuff like that.  Most of the hackish
;; stuff has been dropped for simplicity's sake.

;; To use:
;; - Download
;; - Place in ~/.emacs.el
;;   or ~/.emacs if you prefer

;;; Stuff that I couldn't put in the Customize section

;; Load `dired' ahead of time
(require 'dired)
(require 'dired-x)
(require 'ange-ftp)

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

;; When not using X, don't show the menu
(if (not window-system)
    (menu-bar-mode 0))

;; Enable font-lock mode, which colorizes things nicely
(global-font-lock-mode t)

;; Find funtions and files at point
(find-function-setup-keys)
(ffap-bindings)

;; Grand Unified Debugger
(require 'gud)

;; Navigate the kill ring with the greatest of ease when doing M-y
(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)

;; Load info before trying to deal with its mode map
(require 'info)

;;; Key customizations

;; I don't have any lost love for the <insert> key.  This segment of
;; code will disable it
(global-set-key [insert] (lambda () (interactive)))
(global-set-key [insertchar] (lambda () (interactive)))

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

;; Map some keys to find-function/find-variable
;; Use C-x F to find function, C-x V to find variable
(define-key ctl-x-map "F" 'find-function)
(define-key ctl-x-map "V" 'find-variable)

;;; Do things differently if I am using sudo

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

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

  (progn
    ;; If user is normal, do these things

    ;;; Local-level tweaks and called functions

    ;; Allow for resuming stuff when not running in X
    (require 'resume)

    ;; Change default directory to ~
    (cd "~")))

;;; 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.
 '(apropos-do-all t)
 '(auto-compression-mode t nil (jka-compr))
 '(auto-image-file-mode t nil (image-file))
 '(backup-directory-alist (quote (("." . "~/.emacs.d/backup"))))
 '(blink-cursor nil)
 '(blink-matching-paren-on-screen t)
 '(column-number-mode t)
 '(delete-selection-mode t nil (delsel))
 '(dired-dwim-target t)
 '(dired-recursive-copies (quote always))
 '(dired-recursive-deletes (quote top))
 '(eldoc-minor-mode-string " E")
 '(eldoc-mode t t)
 '(flyspell-issue-welcome-flag nil)
 '(frame-title-format (quote (:eval (concat "(" user-login-name "@" (nth 0 (split-string system-name "\\.")) ") " invocation-name ": " (if buffer-file-name default-directory "%b")))) t)
 '(icomplete-mode t nil (icomplete))
 '(indent-tabs-mode nil)
 '(ispell-local-dictionary "american")
 '(ispell-program-name "aspell")
 '(ls-lisp-dirs-first t)
 '(ls-lisp-ignore-case t)
 '(ls-lisp-use-insert-directory-program nil)
 '(mail-interactive t)
 '(mark-diary-entries-in-calendar t)
 '(max-lisp-eval-depth 1000)
 '(mouse-wheel-mode t nil (mwheel))
 '(nuke-trailing-whitespace-never-major-modes nil)
 '(nuke-trailing-whitespace-p (quote nuke-trailing-whitespace-check-mode))
 '(post-jump-header nil)
 '(recentf-mode nil nil (recentf))
 '(require-final-newline t)
 '(save-place t nil (saveplace))
 '(save-place-limit 20)
 '(scroll-bar-mode 'right)
 '(server-done-hook (quote (delete-frame)))
 '(server-window (quote switch-to-buffer-other-frame))
 '(show-paren-mode t nil (paren))
 '(show-paren-style (quote parenthesis))
 '(sql-product (quote mysql))
 '(tab-width 8)
 '(text-mode-hook (quote (flyspell-mode text-mode-hook-identify)))
 '(transient-mark-mode t)
 '(visible-bell 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.
 )

;;;; .emacs ends here