;; -*-emacs-lisp-*-

;;; Minimal .emacs for COM 3351

;;; To set up, do the following:
;;; cp /course/com3351/pub/.emacs ~/.emacs

;;; ****************************************************************
;;; Global Settings
;;; ****************************************************************

(setq inhibit-startup-message t)	; I hate all those startup messages
(require 'dabbrev)			; turn on dynamic abbrevs
(resize-minibuffer-mode)		; expand the minibuffer when needed
(require 'uniquify)			; do rational thing with buffer names.
(if window-system
    (transient-mark-mode 1))		; make region visible

;;; ****************************************************************
;;; Load Path for Emacs Packages
;;; ****************************************************************

(setq load-path 
      (append
       (mapcar 'expand-file-name
	       '( ; "~/emacs"           ; add this if you want
                 "/course/com3351/pub/emacs"
		 ; "~wand/courses/com1723/emacs"
		 ))
       load-path))


;;; ****************************************************************
;;; Scheme
;;; ****************************************************************

; for CCS Unix systems.  For PCs, put correct path name here (no spaces).
; (setq scheme-program-name "scheme")

;;; ****************************************************************
;;; Colors
;;; ****************************************************************

(global-font-lock-mode t)		; turn on font lock mode everywhere

(setq font-lock-support-mode 'lazy-lock-mode)
(setq lazy-lock-minimum-size 10000
      lazy-lock-defer-on-scrolling t
      lazy-lock-stealth-time 5)

(if window-system			; wand's favorite colors
    (progn
      (set-face-background 'modeline "dodgerblue4")
      (set-face-foreground 'modeline "white")
      ))

;;; ****************************************************************
;;; Printing  
;;; ****************************************************************

;; these use my customized copies of lpr.el and ps-print.el, which
;; are in /course/com1723/emacs

(define-key menu-bar-tools-menu [print-file]
  '("Print File" . print-current-file))

(setq lpr-add-switches nil)		; should be in defaults
(setq lpr-command "print")		; should be in defaults

; should be in loaddefs, modified to emit docstring (see Emacs-Lisp manual)
(autoload 'print-current-file "lpr"		
  "Print file for current buffer as with Unix command `lpr -p'.
If buffer is modified, offers to save all modified buffers.
`lpr-switches' is a string of extra switches (strings) to pass to lpr-command."
  t)

;;; ****************************************************************
;;; Utilities that should be in the default, but aren't
;;; ****************************************************************

(defun insert-time ()
  (interactive)
  (insert-string (current-time-string)))

;;;; comment and uncomment regions

(global-set-key "\C-c;" 'comment-region)
(global-set-key "\C-c:" 'uncomment-region)

(defun comment-region (start end)
  "Add comment symbol at the start of every line in this region"
  (interactive "r")
  (save-excursion
    (save-restriction 
      (narrow-to-region start end)
      (goto-char (point-min))
      (replace-regexp "^."
		      (concat (regexp-quote comment-start) " \\&")))))

(defun uncomment-region (start end)
  "Remove comment symbol at the start of every line in this region"
  (interactive "r")
  (save-excursion
    (save-restriction 
      (narrow-to-region start end)
      (goto-char (point-min))
      (replace-regexp (concat "^" (regexp-quote comment-start) " ") ""))))
