;;;;;;;;;;;;;;;;;;;;;;;;;;;; PATHS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; tell emacs where else to look for packages
(setq load-path (append load-path (list 
                "~/.el"
		"~/.el/html-helper"
		"~/.el/speedbar-0.13a"
		"~/.el/eieio-0.16"
		"~/.el/semantic-1.4beta6"
		"~/.el/elib-1.0"
		"~/.el/jde-2.2.7.1/lisp"
		"~/.el/tdtd"
		"~/.el/psgml"
		)))
(setq exec-path (cons "c:/cygwin/usr/local/bin" exec-path))
(setq Info-default-directory-list (append Info-default-directory-list 
					  (list
					   "c:/cygwin/usr/info"
					   )))

;;;;;;;;;;;;;;;;;;;;;;;;;;;; BASIC ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq inhibit-startup-message t)
(setq display-time-day-and-date t)
(display-time)

; set current buffer's filename, and full path in titlebar
(setq frame-title-format '("%b" (buffer-file-name ": %f")))

; turn on syntax highlighting
(global-font-lock-mode)
(setq font-lock-maximum-decoration t)

(setq default-major-mode 'text-mode)
(setq require-final-newline t)

(require 'semantic-load)

(require 'flash-paren)
(flash-paren-mode 1)
;;;;;;;;;;;;;;;;;;;;;;;;;;;; CYGWIN ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'cygwin-mount)
(cygwin-mount-activate)

(setq process-coding-system-alist '(("bash" . undecided-unix)))
(setq w32-quote-process-args ?\")
(setq shell-file-name "bash")
(setenv "SHELL" shell-file-name) 
(setq explicit-shell-file-name shell-file-name) 

(add-hook 'comint-output-filter-functions 'comint-strip-ctrl-m)

;;;;;;;;;;;;;;;;;;;;;;;;;;;; FILES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; modes to always load
(require 'htmlize)
(require 'html-helper-mode)
(require 'psgml-startup)
(require 'ibuffer)

; modes to load when necessary
(autoload 'css-mode "css-mode")
(autoload 'jde-mode "jde" "JDE mode." t)
(autoload 'cperl-mode "cperl-mode" "alternate perl mode" t)
(autoload 'dtd-mode "tdtd" "Major mode for SGML and XML DTDs." t)
(autoload 'dtd-etags "tdtd"
  "Execute etags on FILESPEC and match on DTD-specific regular expressions."
  t)
(autoload 'dtd-grep "tdtd" "Grep for PATTERN in files matching FILESPEC." t)
(autoload 'apache-mode "apache-mode" "autoloaded" t)

; set the mode to use for various extensions
(setq auto-mode-alist
      (append
       (list
        '("\\.css$" . css-mode)
        '("\\.php$" . php-html-helper-mode)
        '("\\.asp$" . asp-html-helper-mode)
        '("\\.html$" . html-helper-mode)
	'("\\.java$" . jde-mode)
        '("\\.dcl$" . dtd-mode)
        '("\\.dec$" . dtd-mode)
        '("\\.dtd$" . dtd-mode)
        '("\\.ele$" . dtd-mode)
        '("\\.ent$" . dtd-mode)
        '("\\.mod$" . dtd-mode)
	'("\\.\\([pP][Llm]\\|al\\)$" . cperl-mode)
	'("\\.xml$" . xml-mode)
	'("\\.htaccess$"   . apache-mode)
	'("httpd\\.conf$"  . apache-mode)
	'("srm\\.conf$"    . apache-mode)
	'("access\\.conf$" . apache-mode)
	) auto-mode-alist))

; use cperl mode if perl is in the #!
(add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))

(setq cperl-hairy t)

(require 'imenu)
(require 'defaultcontent)

(add-hook 'cperl-mode-hook (function (lambda () (imenu-add-menubar-index))))
(add-hook 'cperl-mode-hook (function (lambda () (imenu-add-to-menubar 'Func))))
(add-hook 'apache-mode-hook (function (lambda () (setq tab-width 4))))

; prevent * buffers showing in ibuffer
(add-to-list 'ibuffer-never-show-regexps "^\\*")
;;;;;;;;;;;;;;;;;;;;;; KEYS/COMMANDS/MENUS ;;;;;;;;;;;;;;;;;;;;;;;;;
; use windows style selection and copy/cut/paste
(require 'pc-select)
(pc-selection-mode)

; map the windows key to hyper (windows method)
(setq w32-pass-lwindow-to-system nil)
(setq w32-lwindow-modifier 'hyper)

; map some keys
(global-set-key [(hyper c)] 'compile)
(global-set-key [(hyper g)] 'goto-line)
(global-set-key [(hyper s)] 'cvs-status)
(global-set-key [(f7)] 'ispell-buffer)
(global-set-key [(home)] 'beginning-of-line)
(global-set-key [(end)] 'end-of-line) 
(global-set-key [(f12)] 'revert-buffer)

; map some mouse clicks
(global-set-key [(mouse-3)] 'mouse-major-mode-menu)
(global-set-key [(shift mouse-3)] 'mouse-buffer-menu)

; add a menu
(define-key global-map [menu-bar extra] 
  (cons "Extra" (make-sparse-keymap "Extra")))

; add items to the menu
(global-set-key [menu-bar extra tetris] '("tetris" . tetris))
(global-set-key [menu-bar extra gomoku] '("gomoku" . gomoku))
(global-set-key [menu-bar extra isql] '("isql" . isql))
(global-set-key [menu-bar extra emacs] '(".emacs" . dot-emacs ))

; override default key mappings
(global-set-key [(control x)(control b)] 'ibuffer)

(defun isql () 
  (interactive)
  (require 'sql)
  (sql-ms)
)

(defun dot-emacs() 
  "opening dot emacs"
  (interactive)
  (find-file "~/cfg/home/.emacs")
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;; VARS ;;;;;;;;;;;;;
(setq compile-command "make -ks")
(setq sql-user "perl")
(setq sql-server "CENTRAL")
(setq set-database "central")
(setq next-line-add-newlines nil)
(setq gnus-show-mime t)
;;;;;;;;;;;;;;;;;;;;;;;;;;;; COLOURS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq default-frame-alist 
      '((cursor-color . "yellow")
	(background-color . "black")
	(foreground-color . "white")))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;; EMACS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;do this to force the custom stuf into a separate file
(setq custom-file "~/.emacs.mycustom")
(load custom-file)

;;;;;;;;;;;;;;;;;;;;;;;;;; MORE BASIC ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; load previously open files
;; this needs to be done after all the modes are set
(desktop-load-default)
(desktop-read)