;;;;;;;;;;;;;;;;;;;;;;;;;;; -*- Mode: Emacs-Lisp -*- ;;;;;;;;;;;;;;;;;;;;;;;;;;
;; emacs.el --- Emacs 19 and above initialization
;; Author          : David Golombek, from bjaspan@mit.edu+marc@mit.edu
;; Time-stamp: <2007-10-18 11:27:30 daveg>
;; Update Count    : 39
;; Status          : Stable, please inform me of bugs

;; Put everything in one function, so that byte-compile does well
(defun startup-function ()
  "Function to perform all startup activity."
  (interactive)

  (defconst emacs-type 
    (cond  ((string-match "^20" emacs-version)            'emacs20)
	   ((string-match "^19" emacs-version)            'emacs19)
	   ((string-match "^18" emacs-version)            'emacs18)
	   (t  'unknown))
    "Type of emacs we're running.  One of epoch, lemacs, emacs18, or emacs19")

  (if (eq emacs-version 'unknown)
      (message "unknown version of emacs running -- BEWARE!"))
  
  (defconst env (getenv "HOSTTYPE"))
  (defconst site (getenv "HOST"))

  (defvar default-load-path-0 load-path)
  (setq load-path
	(delq nil
	      `(,(expand-file-name "~/Elisp")
		"/afs/sipb.mit.edu/contrib/emacs/packages/tm/share/emacs/site-lisp"
		"/afs/sipb.mit.edu/contrib/emacs/packages/mailcrypt"
		"/afs/athena.mit.edu/contrib/pgp/elisp"
		"/afs/sipb.mit.edu/contrib/emacs/packages/custom"
;		,@(if (>= emacs-major-version 20)
;		      `("/afs/sipb.mit.edu/contrib/emacs/packages/gnus-5.8.8"))
;		"/afs/sipb.mit.edu/contrib/emacs/packages/quassia-gnus/lisp"
;		"/afs/sipb/contrib/emacs/packages/red-gnus/lisp"
		"/afs/sipb.mit.edu/contrib/emacs/packages/gnus-5.10.6"
		,@default-load-path-0
		,@(if (string= site "foo.ne.mediaone.net")
		     '("/afs/sipb/contrib/emacs/elisp20"
		       "/afs/sipb/contrib/emacs/elisp19"
		       "/afs/sipb/contrib/emacs/elisp"
		       "/afs/athena/contrib/sipb/lib/elisp"
		       "/afs/athena/contrib/pgp/elisp"
		       ))
		"/afs/sipb/contrib/emacs/packages/bbdb-2.34/lisp"
		"/usr/athena/share/emacs/site-lisp"
		"/usr/athena/share/emacs/19.30/lisp"
		"/usr/athena/share/emacs/19.34/lisp"
		"/afs/sipb/contrib/emacs/elisp19"
		"/afs/sipb/contrib/emacs/elisp"
		"/afs/athena/contrib/sipb/lib/elisp"
		"/afs/athena/contrib/pgp/elisp"
		"/afs/sipb/contrib/emacs/packages/w3/lisp"
		)))

  (setq initial-major-mode
	(lambda ()
	  (lisp-interaction-mode)
	  (turn-on-auto-fill))

	completion-ignored-extensions (append 
				       completion-ignored-extensions
				       '(".obj"
					 ".class"
					 ".to"))
	auto-mode-alist (append
			 '(("\\.C$" . c++-mode)
			  ("\\.c$" . c-mode)
			  ("\\.h$" . c++-mode)
			  ("\\.H$" . c-mode)
			  ("\\.y$" . c-mode)
			  ("\\.cc$" . c-mode)
			  ("\\.el$" . emacs-lisp-mode)
			  ("\\.tex$" . latex-mode)
			  ("\\.texinfo$" . texinfo-mode)
			  ("\\.lsp$" . lisp-mode)
			  ("\\.scm$" . lisp-mode)
			  ("\\.pl$" . perl-mode)
			  ("\\.pm$" . perl-mode)
			  ("\\.html$" . html-helper-mode)
			  ("\\.java$" . java-mode))
			 auto-mode-alist)
	
	inhibit-startup-message t
	Info-default-directory-list '("/afs/athena/user/d/a/daveg/Elisp/Info")
	display-time-interval 10
	enable-recursive-minibuffers t
	next-line-add-newlines nil
	default-directory "~/"
	uniquify-buffer-name-style 'post-forward
	mime-editor/split-message nil
	use-emime t
	window-min-height 2
	diff-switches nil ; get rid of annoying -c
	auto-compression-mode t

	crypt-encryption-type 'des
	crypt-encryption-file-extension "\\(\\.e\\)$"
	crypt-bind-insert-file nil
	crypt-freeze-vs-fortran nil
	)

  (put 'eval-expression 'disabled nil)
  (put 'narrow-to-region 'disabled nil)
  (put 'narrow-to-page 'disabled nil)
  (put 'upcase-region 'disabled nil)
  (put 'downcase-region 'disabled nil)

  (autoload 'c++-mode "cc-mode" "C++ mode" t nil)
  (autoload 'c-mode "cc-mode" "C mode" t nil)
  (autoload 'java-mode "cc-mode" "Java Mode" t nil)
  (autoload 'php-mode "php-mode" "PHP Mode" t nil)
  (autoload 'html-helper-mode
    "/afs/athena/user/d/a/daveg/Elisp/html-helper-mode" "" t nil)
  (autoload 'calc "calc" "" t nil)
;  (autoload 'calc-extensions "calc-ext" "" t nil)
  (autoload 'cmd "/afs/athena/user/k/k/kkkken/elisp/cmd" "cmd mode" t nil)
  (autoload 'hippie-expand "hippie-exp" "Wicked cool completion everywhere" t)
  (autoload 'discuss "/usr/athena/share/emacs/site-lisp/discuss" "" t nil)
  (autoload 'zwgc "/afs/athena/user/d/a/daveg/Elisp/zwgc" "" t nil)

  (load "/afs/athena/user/m/a/marc/elisp/mutant-scrolling" t)
  (load "/afs/athena/user/d/a/daveg/.emacs-records")

  (defun byte-compile-load (fname)
    "Byte compile and load a file"
    (let ((elfile (expand-file-name fname)))
      (let ((elcfile (concat elfile "c")))
	(if (file-newer-than-file-p elfile elcfile)
	    (byte-compile-file elfile))
	(load-file elcfile))))
  
  ;; Mode hooks, mode variable definitions, mode related functions.
  (byte-compile-load "/afs/athena/user/d/a/daveg/Elisp/keymaps.el")
  (byte-compile-load "/afs/athena/user/d/a/daveg/Elisp/random-other.el")
;  (byte-compile-load "/afs/athena/user/d/a/daveg/Elisp/hooks.el")
  (load-file "/afs/athena/user/d/a/daveg/Elisp/hooks.el")

  (require 'uniquify)
  (require 'jka-compr)
;  (require 'crypt++)
  
  (require 'bbdb)
  (bbdb-initialize 'gnus 'message)
  
  (autoload 'zsend "/afs/athena/user/m/a/marc/elisp/zsend" "" t nil)
  (autoload 'olcr-list
    "/afs/athena/astaff/project/eolcdev/Emacs19/eolcr/olcr"
    "Emacs OLCR Version 3.4T-19" t)
  (menu-bar-mode -1)
  (if (string= window-system "x")
      (progn (scroll-bar-mode -1)
	     (set-default-font
	      (if (or (string= env "sgi") (string= env "iris4d"))
		  "8x13"
		"fixed"))
	     (setq mouse-yank-at-point t)
	     (setq initial-frame-alist
		   (cond ((or (string= env "sun4")
			      (string= env "sun4m_54"))
			  '((top . 0) (left . -1) (width . 80) (height
								. 64)))
			 ((or (string= env "sgi")
			      (string= env "iris4d"))
			  '((top . 0) (left . -1) (width . 80) (height
								. 74)))
			 (t
			  '((top . 0) (left . -1) (width . 80) (height
								. 54)))
			 ))
	     (require 'paren)
	     (show-paren-mode)
;		    (set-face-background 'show-paren-match-face "darkgreen")
	     (require 'font-lock)
	     (setq font-lock-maximum-decoration t)
	     (if (fboundp 'global-font-lock-mode)
		 (global-font-lock-mode t))

	     (autoload 'turn-on-lazy-lock "lazy-lock")
	     (add-hook 'font-lock-mode-hook 'turn-on-lazy-lock)
	     (setq lazy-lock-stealth-time 5)

	     (set-cursor-color "green")
	     (set-foreground-color "white")
	     (set-background-color "black")
	     (set-mouse-color "white")
	     (invert-face 'region)
	     (set-face-foreground 'modeline "lightgray")
	     (set-face-background 'modeline "DarkSlateBlue")
	     (set-face-background 'highlight "DarkGreen")
	     (set-face-background 'secondary-selection
				  "rgb:d2/22/32")
	     (set-face-foreground 'font-lock-comment-face
				  "OrangeRed")
	     (set-face-foreground 'font-lock-string-face
				  "LightSalmon")
	     (set-face-foreground 'font-lock-keyword-face
				  "LightSteelBlue")
	     (set-face-foreground 'font-lock-function-name-face
				  "LightSkyBlue")
	     (set-face-foreground 'font-lock-variable-name-face
				  "LightGoldenrod")
	     (set-face-foreground 'font-lock-type-face
				  "PaleGreen")
	     (require 'message)
;;;		    (set-face-foreground 'message-header-name-face
;;;					 "cyan")
;;;		    (set-face-foreground 'message-header-other-face
;;;					 "turquoise")
;;;		    (set-face-foreground 'message-separator-face
;;;					 "blue2")
;;;		    (copy-face 'bold 'info-xref)
;;;		    (set-face-foreground 'info-xref "cyan")
	     )
    (ctl-h-is-del)
    )

  (setq debug-on-error '(wrong-type-argument
			 wrong-number-of-arguments
			 void-variable
			 void-function
			 ;; search-failed
			 setting-constant
			 no-catch
			 ;; invalid-regexp
			 invalid-function
			 ;; file-already-exists
			 ;; file-error
			 ;; end-of-buffer
			 arith-error
			 args-out-of-range
			 ))
  
;  (server-start)
  (display-time)
  (message "Ready.")
  )


;;;; Run the startup activities now.  The above was all put into a
;;;; defun so that it will run much faster in byte-compiled form.
(startup-function)

