;; ========================
;;  CMPU-181, Spring 2013
;;  Sample .emacs file
;; ========================
;;  Copy this file into your own home directory, making sure that
;;  it is called ".emacs" (without the quotes).  Then, every time
;;  you start up the emacs program, this file will be loaded, making
;;  things work like we want them to!  :)

(autoload 'lisp-mode "lisp" "Major Mode to edit Lisp files." t)

(set-default 'auto-mode-alist
	     (append '(("\\.lisp$" . fi:common-lisp-mode)
		       ("\\.lsp$" . fi:common-lisp-mode)
		       ("\\.cl$" . fi:common-lisp-mode)) auto-mode-alist))

(add-hook 'fi:common-lisp-mode-hook
	  '(lambda () (font-lock-mode 1)))
(add-hook 'fi:inferior-common-lisp-mode-hook
	  '(lambda () (font-lock-mode 1)))
(add-hook 'fi:emacs-lisp-mode-hook
	  '(lambda () (font-lock-mode 1)))

(global-font-lock-mode t)

(define-key global-map "\C-h" 'delete-backward-char)
(define-key global-map "\C-z" 'suspend-emacs)

(line-number-mode 1)

(display-time)

(put 'upcase-region 'disabled nil)

(put 'downcase-region 'disabled nil)

;; ==========================================
;;    adds for cs102 on 2000.09.06
;; ==========================================

;;; visting file modes
(setq auto-mode-alist
      (quote (("\\.perl$" . perl-mode)
              ("\\.pl$" . perl-mode)
              ("\\.c$" . c-mode)
	      ("\\.php$" . java-mode)
	      ("\\.H$" . c++-mode)
              ("\\.h$" . c++-mode)
	      ("\\.java$" . java-mode)
              ("\\.pc$" . c-mode)
	      ("\\.s$" . asm-mode)
              ("\\.txt$" . text-mode)
              ("\\.z$" . uncompress-while-visiting)
              ("\\.Z$" . uncompress-while-visiting)
              ("\\.html$" . html-mode)
              ("\\.cpp$" . c++-mode)
              ("\\.CC$" . c++-mode)
	      ("\\.cc$" . c++-mode)	
              ("\\.C$" . c++-mode)
	      ("\\.y$" . c++-mode)
	      ("\\.l$" . c++-mode)
	      ("\\.tex$" . latex-mode) ;; <--- :)
	      ("\\.lisp$" . lisp-mode) ;; <************************
	      ("\\.scm$" . scheme-mode) ;; <--- :)
              ("Makefile$" . makefile-mode)
	      ("makefile$" . makefile-mode)
              ("\\.mk$" . makefile-mode)
              )))

(defun cs102-c-hook ()
  (c-set-style "ellemtel")
  (local-set-key [f5] 'compile)
  (local-set-key "\r" 'newline-and-indent)
  (local-set-key [DEL] 'delete-char)
  (define-key ctl-x-map "f" 'indent-region)
)

(global-set-key [f6] 'print-buffer)
(global-set-key [home] 'beginning-of-line)
(global-set-key [end] 'end-of-line)
;(global-set-key " " 'beginning-of-buffer)
(define-key ctl-x-map "g" 'goto-line)
;(define-key ctl-x-map [home] 'beginning-of-buffer)
(define-key ctl-x-map [end] 'end-of-buffer)
(global-font-lock-mode 1)
(add-hook 'c-mode-hook 'cs102-c-hook)
(add-hook 'c++-mode-hook 'cs102-c-hook)

(add-hook 'java-mode-hook
      (function 
       (lambda ()
	 (unless (or (file-exists-p "makefile")
                     (file-exists-p "Makefile"))
           (make-local-variable 'compile-command)
           (setq compile-command
                 (concat "javac "
                         (buffer-file-name))))  
		  (local-set-key [f5] 'compile)
		  (local-set-key "\r" 'newline-and-indent)
		  (local-set-key [DEL] 'delete-char)
		  (define-key ctl-x-map "f" 'indent-region)
                           )))



;;
;; end adds for cs102
;;


   
(custom-set-variables
  ;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.
 '(case-fold-search t)
 '(current-language-environment "Latin-1")
 '(default-input-method "latin-1-prefix")
 '(global-font-lock-mode t nil (font-lock))
 '(show-paren-mode t nil (paren))
 '(transient-mark-mode t))
(custom-set-faces
  ;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.
 )
