;;; Clu prep stuff...
;;; (defvar clu-lisp-directory "/mit/nocturne/home/elisp"
;;;  "CLU lisp directory location")
;;;
;;; (setq auto-mode-alist
;;;       (append (list (cons "\\.clu$"     'clu-mode)
;;;                     (cons "\\.equ$"     'clu-mode)
;;;                     )
;;;               auto-mode-alist
;;;               )
;;;       )
;;;
;;; (setq load-path (cons clu-lisp-directory load-path))
;;;
;;; (autoload 'clu-mode "clu" "Clu mode" t)
;;;

(defvar default-load-path load-path)

(setq
 load-path (append
            (list
             (expand-file-name "~/elisp")
             "/afs/sipb.mit.edu/contrib/emacs/elisp"
             "/mit/watchmaker/lib/elisp"
             "/afs/sipb.mit.edu/project/sipb/lib/elisp"
             "/mit/consult/elisp"
             "/mit/outland/lib/elisp"
	     )
            default-load-path))

(load "fill1")
(setq fill-extra-space-after-period nil)

(setq rmail-file-name (expand-file-name "/mit/nocturne/home/rmail/inbox"))
(setq rmail-secondary-file-directory
      (expand-file-name "/mit/nocturne/home/rmail"))
;; (setq rmail-last-file "/mit/nocturne/home/rmail/w")
;; (setq rmail-last-rmail-file "/mit/nocturne/home/rmail/w")
(setq rmail-delete-after-output t)
; (setq rmail-dont-reply-to-names "info-\\|nocturne\\>")

(autoload 'staple "/afs/athena.mit.edu/user/e/i/eichin/elisp/staple.el")
(autoload 'stapler "/afs/athena.mit.edu/user/e/i/eichin/elisp/staple.el")

(load "/afs/sipb/project/outland/lib/elisp/w3-setup")
(setq w3-default-homepage "file://localhost/afs/sipb/user/nocturne/www-lib/private/my_startup.html")

(autoload 'gnus "gnus" "Read network news." t)
(autoload 'gnus-post-news "gnuspost" "Post a new news." t)

(setq gnus-nntp-server "news.mit.edu"
      load-path (append load-path
			(list "/mit/sipb/lib/elisp")))

; Very important definition: doesn't bother you with new newsgroups.
; You can keep your .newsrc* short and neat.
(setq gnus-subscribe-newsgroup-method
      '(lambda (newsgroup) nil))

(setq discuss-DWIM t)
(setq truncate-partial-width-windows nil)
(autoload 'perl-mode "/afs/athena/contrib/perl/elisp/perl-mode"
          "Major mode for editing Perl code." t)
(autoload 'display-current-line-number
                  "/mit/consult/lib/elisp/current-line"
                  "Display the current line number on the status line."
                  t)
(setq delete-auto-save-files t)
(defun highlight-region (string)
  "Inserts STRING at the beginning of every line in the region.
Called interactively, STRING defaults to '> ' unless a prefix
argument is given."
  (interactive (list (if current-prefix-arg
                         (read-string "String to insert: ")
                       "> ")))
  (save-excursion
    (if (bolp)
        (forward-line -1))
    (save-restriction
      (narrow-to-region (point) (mark))
      (goto-char (point-min))
      (replace-regexp "^" string))))

;;;Everything after this point was snarfed from marc@athena's .emacs
(defvar default-auto-mode-alist auto-mode-alist)
(setq
 auto-mode-alist (append
                  '(
                    ("\\.m$" . c-mode)
                    ("\\.\\(pl\\|ph\\|perl\\)$" . perl-mode)
                    ("\\.\\(C\\|H\\|cc\\|hh\\)$" . c++-mode)
                    ("cat[0-9]/.*\\.1$" . fundamental-mode)
                    ("\\.1$" . nroff-mode)
		    ("\\.gwm$" . lisp-mode)
                    )
                  default-auto-mode-alist))

(defvar default-completion-ignored-extensions completion-ignored-extensions)
(setq
 completion-ignored-extensions (append
                                '("./" "../")
                                default-completion-ignored-extensions))

(autoload 'zwgc "/afs/athena.mit.edu/user/b/j/bjaspan/elisp/zwgc"
          "Emacs mode zwgc" t)
(autoload 'zsend "zsend" "Emacs zephyr send" t)
(autoload 'zsend-region "zsend" "Emacs zephyr send" t)
(autoload 'browse-mode "browse-mode" "A mode for browsing files" t)
(autoload 'cmd "/afs/athena.mit.edu/user/k/k/kkkken/elisp/cmd"
          "Ken's studly shell mode" t)
(autoload 'perl-mode "/afs/athena.mit.edu/contrib/perl/elisp/perl-mode"
          "perl mode for perl files" t)
(autoload 'describe-perl-symbol
          "/afs/athena.mit.edu/contrib/perl/elisp/perl-descr"
          "Describes a perl expression" t)
(setq text-mode-hook (function (lambda ()
                                 (abbrev-mode 1)
                                 (setq fill-column 76)
                                 (auto-fill-mode 1))))

;; indenting hacks

(defun indent-level (spaces)
  "set c-indent-level more easily"
  (interactive "nlevel: ")
  (make-local-variable 'c-indent-level)
  (setq c-indent-level spaces)
  (setq c-continued-statement-offset spaces))

(defun i3 () (interactive) (indent-level 3))
(defun i4 () (interactive) (indent-level 4))
(defun i8 () (interactive) (indent-level 8))

(defun try-attach ()
  (cond ((string-match "^/mit/\\([^/]+\\)/" buffer-file-name)
         (let ((filsys (substring buffer-file-name
                                  (match-beginning 1)
                                  (match-end 1))))
           (if (not (file-exists-p (concat "/mit/" filsys)))
               (progn
                 (princ (format "Attaching %s..." filsys))
                 (sit-for 0)
                 (call-process "attach" nil nil nil
                               filsys)
                 (if (condition-case ()
                         (insert-file-contents filename t)
                       (file-error nil))
                     (progn (setq error nil)
                            t))))))))
(setq
 find-file-not-found-hooks
 '(
   try-attach
   ))
(setq man-program
      (cond ((file-readable-p "/usr/athena/bin/man") "/usr/athena/bin/man")
            ((file-readable-p "/usr/ucb/man") "/usr/ucb/man")
            (t "/bin/false")))

(load "mutant-scrolling")
(put 'eval-expression 'disabled nil)
