;;;
;;; [cjl] .emacs key bindings (standard epoch), plus a few additions...
;;; last hacked 9-1-90
;;; 
;;; First, the normal Epoch .emacs file
;;; -----------------------------------
;;(setq mh-progs "/local/bin/MH")
;;(setq mh-lib "/local/lib/mh")
;;(setq load-path (cons "/delta/stable/lib/epoch/epoch-lisp" load-path))

;; live dangerously
;;(put 'eval-expression 'disabled nil)

;;(if (boundp 'epoch::version)
;;    (progn
;;      (setq epoch::function-key-mapping nil)
;;      ))

;;(setq mh-summary-height 20)
;;(global-set-key "\C-l" 'goto-line)


;; Get rid of the startup message.  Once in history is enough.
(setq inhibit-startup-message t)

;; I know how to use eval-expression.
(put 'eval-expression 'disabled nil)

;;
;; Figure out what editor we are actually running
;;

(cond
 ((boundp 'epoch::version) (setq running-epoch t))
 ((boundp 'era-version) (progn (setq running-era t) (setq running-xemacs t)))
 ((string-match "XEmacs" emacs-version) (setq running-xemacs t))
 ((string-match "^19" emacs-version) (setq running-fsf19 t)))

;;
;; Set the load path.
;;

(setq load-path (append (list
                         (expand-file-name "~/Emacs")
                         (expand-file-name "~/Video")
                         ) load-path))

;; Change the help key to M-?
(setq help-char 0)
(global-set-key "\e?" 'help-command)

;; Set backspace to do a backspace and delete.
;;	Note:  "\^h" could be represented as '(control h) under XEmacs
(global-set-key "\^h" 'delete-backward-char)

;; Ask for confirmation we exiting to prevent leaving emacs unintentionally.
(global-set-key "\C-x\C-c" '(lambda () (interactive)
    (if (yes-or-no-p "Do you want to exit ")
      (save-buffers-kill-emacs)
    )
  )
)

(if (boundp 'running-xemacs)
    (progn
      (global-set-key 'f1 'goto-line)
      (global-set-key 'f2 'count-lines-page)
      (global-set-key 'f3 'other-window)
      (global-set-key 'f4 'what-line)
      (global-set-key 'f5 'trade-buffers)
      (global-set-key 'f6 'put-current-line-at-top)
      (global-set-key 'f7 'eval-region)
      (global-set-key 'f9 'shrink-window)
      ;; Set F29 (PgUp)
      (global-set-key 'f29 'scroll-down)
      ;; Set F35 (PgDn)
      (global-set-key 'f35 'scroll-up)
      ;; Set F27 (Home)
      (global-set-key 'f27 'beginning-of-buffer)
      ;; Set F33 (End)
      (global-set-key 'f33 'end-of-buffer)
      ;; Set F19 (Find)
      (global-set-key 'f19 'isearch-forward)
      ;; Set F14 (Undo)
      (global-set-key 'f14 'undo)
      (global-set-key '(control left) 'backward-word)
      (global-set-key '(control right) 'forward-word)))

;;
;; Setup mh mode
;;

(setq mh-summary-height 10)

(setq mh-progs
      (cond
       ((file-exists-p "/usr/local/all/inc") "/usr/local/all")
       ((file-exists-p "/local/bin/inc") "/local/bin/")
       ((file-exists-p "/local/all/inc") "/local/all/")
       (t "/usr/local/")))
(setq mh-lib
      (cond
       ((file-exists-p "/usr/dcs/local/lib/mh") "/usr/dcs/local/lib/mh")
       ((file-exists-p "/local/lib/mh") "/local/lib/mh/")
       ((file-exists-p "/usr/local/lib/mh") "/usr/local/lib/mh/")
       (t "/usr/local/mh/")))

(if (boundp 'running-xemacs)
    (progn
      (require 'mh-e)
      (require 'mh-comp))
  (load "/local/encap/emacs-18.59/lisp/mh-e.el"))

;;
;; Setup Emacs Lisp mode
;;

(setq emacs-lisp-mode-hook
      '(lambda ()
	 (if (boundp 'running-xemacs)
	     (progn
	       (define-key emacs-lisp-mode-map
		 '(control tab) 'lisp-indent-line)
	       (font-lock-mode 1)))))

;;
;; Setup text mode
;;
 
(if (boundp 'running-xemacs)
    (add-hook 'text-mode-hook 'turn-on-auto-fill))

;;
;; Setup highlighting
;;

(if (boundp 'running-xemacs)
    (progn
      (require 'highlight-headers)
      (setq highlight-headers-regexp "Subject[ \t]*:\\|From[ \t]*:")
      (require 'font-lock)
      
      (copy-face 'default 'font-lock-string-face)
      (copy-face 'default 'font-lock-comment-face)
      (copy-face 'default 'font-lock-doc-string-face)
      (copy-face 'default 'font-lock-function-name-face)
      (copy-face 'default 'font-lock-type-face)
      ;; green
      (set-face-foreground 'font-lock-string-face "#00ff01")
      ;; yellow
      (set-face-foreground 'font-lock-comment-face "#ffff00")
      ;; red
      (set-face-foreground 'font-lock-doc-string-face "#ff0000")
      ;; light blue
      (set-face-foreground 'font-lock-function-name-face "#6ca6fd")
      (set-face-foreground 'font-lock-keyword-face "magenta")
      (set-face-foreground 'font-lock-type-face "orange")
      
      (set-face-foreground 'message-headers "#ff0000")
      (set-face-foreground 'message-header-contents "#6ca6fd")
      (set-face-font 'message-cited-text
		     "-adobe-times-medium-r-*-*-*-120-*-*-*-*-iso8859-1")
      (set-face-foreground 'message-cited-text "chocolate")
      ;; yellow
      (set-face-foreground 'message-highlighted-header-contents "#ffff00")
      (set-face-background 'highlight "blue")
      
      (setq c-font-lock-keywords c-font-lock-keywords-2)
      (setq lisp-font-lock-keywords lisp-font-lock-keywords-2)
      (set-face-underline-p 'font-lock-string-face nil)))

(cond
 ((boundp 'running-xemacs)
  (progn
    ;(add-hook 'mh-show-hook '(lambda () (highlight-headers (point-min)
    ;							   (point-max) t)))
    (add-hook 'mh-show-mode-hook '(lambda ()
				    (highlight-headers (point-min)
						       (point-max) t)))
    (add-hook 'mh-letter-mode-hook '(lambda ()
				      (highlight-headers (point-min)
							 (point-max) t))))))

;;
;; Setup Supercite and filladapt
;;

(autoload 'sc-cite-original	"supercite" "Supercite 3.1" t)
(autoload 'sc-submit-bug-report	"supercite" "Supercite 3.1" t)
(if (boundp 'running-xemacs)
    (add-hook 'mail-citation-hook 'sc-cite-original))

(setq news-reply-header-hook nil)
(if (boundp 'running-xemacs)
    (add-hook 'mh-yank-hooks 'sc-cite-original))
(setq mh-yank-from-start-of-msg t)

(if (boundp 'running-xemacs)
    (progn
      (require 'filladapt)
      (add-hook 'sc-load-hook 'sc-setup-filladapt)))

;;
;; Setup up function keys in mh-mode to automatically send the
;; apropriate replies to people.
;;

(defun mh-refile-to-folder (folder)
  (mh-refile-msg (mh-get-msg-num t) folder)
  (message (format "Refiled to %s" (symbol-name folder))))

(defun mh-refile-xemacs-received ()
  (interactive)
  (mh-refile-to-folder '+XEmacs-Received))

(setq mh-reply-default-reply-to nil)
(setq mh-repl-formfile "replcomps")

(defun mh-reply-to-message (form msg)
  (let ((mh-repl-formfile form)
	(mh-reply-default-reply-to "from")
	(mh-compose-letter-function '(lambda (foo bar baz) (mh-send-letter))))
    (if (y-or-n-p msg)
	(mh-reply (mh-get-msg-num t) nil))))

(defun mh-reply-xemacs-welcome ()
  (interactive)
  (mh-reply-to-message "reply-xemacs-welcome" "Welcome xemacs? "))

(defun mh-reply-xemacs-goodbye ()
  (interactive)
  (mh-reply-to-message "reply-xemacs-goodbye" "Goodbye xemacs? "))

(defun mh-reply-xemacs-apology-goodbye ()
  (interactive)
  (mh-reply-to-message "reply-xemacs-apology-goodbye" "Goodbye apology xemacs? "))

(defun mh-reply-info-welcome ()
  (interactive)
  (mh-reply-to-message "reply-info-welcome" "Welcome info-bbdb? "))

(defun mh-reply-info-goodbye ()
  (interactive)
  (mh-reply-to-message "reply-info-goodbye" "Goodbye info-bbdb? "))

(defun mh-reply-bbdb-welcome ()
  (interactive)
  (mh-reply-to-message "reply-bbdb-welcome" "Welcome bbdb-announce? "))

(defun mh-reply-bbdb-goodbye ()
  (interactive)
  (mh-reply-to-message "reply-bbdb-goodbye" "Goodbye bbdb-announce? "))

(defun mh-xemacs-beta-welcome (to)
  (interactive (list
		(mh-read-address "To: ")))
  (let ((mh-comp-formfile "xemacs-beta-welcome")
	(mh-compose-letter-function '(lambda (foo bar baz) (mh-send-letter))))
    (mh-send to "" "welcome to xemacs-beta")))

(define-key mh-folder-mode-map 'f1 'mh-reply-xemacs-welcome)
(define-key mh-folder-mode-map '(shift f1) 'mh-reply-xemacs-goodbye)
(define-key mh-folder-mode-map 'f2 'mh-reply-info-welcome)
(define-key mh-folder-mode-map '(shift f2) 'mh-reply-info-goodbye)
(define-key mh-folder-mode-map 'f3 'mh-reply-bbdb-welcome)
(define-key mh-folder-mode-map '(shift f3) 'mh-reply-bbdb-goodbye)
(define-key mh-folder-mode-map 'f4 'mh-xemacs-beta-welcome)
(define-key mh-folder-mode-map 'f5 'mh-reply-xemacs-apology-goodbye)

;;
;; (ding) GNUS
;;

(setq load-path (append (list
                         (expand-file-name "/tmp/dgnus/lisp")
                         ) load-path))

(setq gnus-select-method '(nntp "news.cso.uiuc.edu"))
(setq gnus-subscribe-newsgroup-method 'gnus-subscribe-alphabetically)
(setq gnus-save-newsrc-file nil)
(setq gnus-options-not-subscribe "!uk.all !unihigh.all !uunet.all !vmsnet.all !za.all")