;; -*- lisp -*- 

;; Jeff Miller (miller@zipcon.net) _emacs file
;; Last update Thu Sep 30, 1999  2:00 AM  (M-x insert-date :-)

;; ============================================================================
;; Emacs customize section
;; ============================================================================

; FAQ 34: Highlight regions of text
(transient-mark-mode t)

; FAQ 48: Highlight parens
(show-paren-mode 1)

; FAQ 66: font-lock-mode for all major modes
(global-font-lock-mode t)
(setq font-lock-maximum-decoration 't)


; FAQ 67: Only scroll one line when moving past screen
(setq scroll-step 1)
(setq scroll-conservatively 1)

; Dont show the GNU splash screen
(setq inhibit-startup-message t)

; Tab length
(setq default-tab-width 4)

; Always set filenames to lowercase (useful for FINDSTR below)
(setq win32-downcase-file-names t)

; Use FINDSTR rather than GREP
(setq grep-command "findstr /n ")

; Turn off the bell
(setq visible-bell t)

; Don't automatically add new lines at end
(setq next-line-add-newlines nil)

;; Set default font
; -maker-family-weight-slant-widthtype-style-pixels-height-horiz-vert-spacing-width-charset
(set-default-font "-*-Courier-medium-r-normal-Terminal-10-*-*-m-*-iso8859-1")
(setq w32-use-w32-font-dialog nil)

; Make all "yes or no" prompts show "y or n" instead
; (fset 'yes-or-no-p 'y-or-n-p)

; Ask to quit emacs
(setq kill-emacs-query-functions
      (cons (lambda () (yes-or-no-p "Really kill Emacs? "))
            kill-emacs-query-functions))

;; ============================================================================
;; My preferred key bindings
;; ============================================================================

; Set C-g to goto-line
(global-set-key "\C-cg" 'goto-line)

;; ============================================================================
;; CC Mode setup
;; http://www.python.org/emacs/cc-mode/cc-mode-html/Sample-.emacs-File.html
;; The stroustrup built in style works fine for me, so I'll just use that
;; ============================================================================

(defun stroustrup-common-hook () 
	(c-set-style "stroustrup") 
	(setq tab-width 4 indent-tabs-mode nil)
)
(add-hook 'c-mode-common-hook 'stroustrup-common-hook)

;; ============================================================================
;; Other hooks
;; ============================================================================

; turn on auto fill mode when editing text files

(add-hook 'text-mode-hook 'turn-on-auto-fill)

;; ============================================================================
;; Printer settings
;; ============================================================================

; Use this if you have a network printer
; (setq printer-name "//red-prn-12/corp0066")


; Use this if you have GhostScript 5.50 installed
(setenv "GS_LIB" "d:\\gstools\\gs5.50;d:\\gstools\\gs5.50\\fonts")
(setq ps-lpr-command "d:/gstools/gs5.50/gswin32c")
(setq ps-lpr-switches '("-q" "-dNOPAUSE" "-dBATCH" "-sDEVICE=mswinprn2"))
(setq ps-printer-name t)

;; ============================================================================
;; Fun stuff
;; ============================================================================

(defun ascii-table ()
  "Print the ascii table. Based on a defun by Alex Schroeder <asc@bsiag.com>"
  (interactive)
  (switch-to-buffer "*ASCII*")
  (erase-buffer)
  (insert (format "ASCII characters up to number %d.\n" 254))
  (let ((i 0))
    (while (< i 254)
      (setq i (+ i 1))
      (insert (format "%4d %c\n" i i))))
  (beginning-of-buffer))

(defun insert-date ()
  "Insert date at point."
  (interactive)
  (insert (format-time-string "%a %b %e, %Y %l:%M %p")))

(defun dos-unix ()
  (interactive)
    (goto-char (point-min))
      (while (search-forward "\r" nil t) (replace-match "")))


(defun unix-dos ()
  (interactive)
    (goto-char (point-min))
      (while (search-forward "\n" nil t) (replace-match "\r\n")))
