(set-foreground-color "white")
(set-background-color "black")
(setq explicit-shell-file-name "/bin/csh")
(setq shell-file-name "/bin/csh")
(setq load-path (cons (expand-file-name "~/lib/emacs") load-path))
(display-time)
(setq make-backup-files)
(setq backup-inhibited 1)
(setq inhibit-local-variables t)
(setq default-case-fold-search 1)
(setq delete-auto-save-files t)
(setq fill-column 200)
(setq dired-listing-switches "-Flag")
(setq require-final-newline t)
(setq completion-ignored-extensions       ; ignore these extensions
    (append completion-ignored-extensions
        (quote (".bak" ".#*#" ".ps"))))

(setq trim-versions-without-asking t)
(set-mouse-color "yellow")
(set-cursor-color "white")
(set-face-foreground 'modeline "blue")
(set-face-background 'modeline "white")
(set-face-foreground 'default "lightgreen")
(tool-bar-mode 0)
(scroll-bar-mode `right)
(global-set-key "\M-#"    'goto-line)
(global-set-key "\M-*"    'set-mark-command)
(global-set-key "\M-&"    'replace-string)
(global-set-key "\C-^"    'rmail)
(global-set-key "\C-h"    'help-for-help)
(global-set-key "\C-u"    'undo)
(global-set-key "\C-x\C-r"'query-replace)
(global-set-key "\C-p"    'print-region)

(require 'mouse-extras)
(global-set-key [M-down-mouse-1] 'pasting-mouse-drag-secondary)
(global-set-key [M-S-down-mouse-1] 'moving-mouse-drag-secondary)
(global-set-key [down-mouse-2] 'mouse-drag-throw)

;; File Handling
;
; These all customize the internal operations of the editor.
; The first few set up which modes to use for which types of files.
(setq auto-mode-alist
 '(("\\.text$" . text-mode)
  ("\\.asm$" . m68k-mode)
  ("\\.68k$" . m68k-mode)
  ("\\.inc$" . m68k-mode)
  ("\\.C$"  . c++-mode)
  ("\\.cc$" . c++-mode)
  ("\\.c$" . c-mode)
  ("\\.h$" . c-mode)
  ("\\.r$" . c-mode)
  ("\\.f$" . c-mode)
  ("\\.mss$" . text-mode)
  ("\\.tex$" . LaTeX-mode)
  ("\\.el$" . emacs-lisp-mode)
  ("\\.scm$" . scheme-mode)
  ("\\.l$" . lisp-mode)
  ("\\.lsp$" . lisp-mode)
  ("\\.lisp$" . lisp-mode)
  ("(Makefile\\|makefile)?" . makefile-mode)
  ("\\.f$" . fortran-mode)
  ("\\.TeX$" . TeX-mode)
  ("\\.sty$" . LaTeX-mode)
  ("\\.bbl$" . LaTeX-mode)
  ("\\.bib$" . text-mode)
  ("\\.texinfo$" . texinfo-mode)
  ("^/tmp/Re" . text-mode)
  ("^/tmp/fol/" . text-mode)
  ("/Message[0-9]*$" . text-mode)
  ("\\.y$" . c-mode)
  ("\\.scm.[0-9]*$" . scheme-mode)
  ("/\\..*emacs" . emacs-lisp-mode)
  ("\\.pl$" . perl-mode)
  ("\\.pm$" . perl-mode)
  ("\\.tar$" . tar-mode)
  ("\\.Z$" . uncompress-while-visiting)
  ("\\.gz$" . uncompress-while-visiting)
  ("\\.ml$" . lisp-mode)))


;(require 'multi-click)
(load  "/Users/zimmy/lib/emacs/sun-keys.el")
(global-set-key [f1] 'delete-other-windows)   ; f1
(global-set-key [f2] 'split-window-vertically); f2
(global-set-key [f3] 'goto-line)             ; f3
(global-set-key [f4] 'split-window-horizontally)            ; f4
(global-set-key [f5] 'kill-word)              ; f5
(global-set-key [f6] 'kill-line)              ; f6
;     (global-set-key [f7] ' )                      ; f7
(global-set-key [f8] 'help )                      ; f8
(global-set-key [f9] 'scroll-down-in-place)   ; f9
(global-set-key [f10] 'scroll-up-in-place)    ; f10
;     (global-set-key [f11] ' )                     ; f11
(global-set-key [f12] 'help )                     ; f12
;     (global-set-key [f13] ' )                     ; ??
(global-set-key [f14] 'undo)                   ; UNDO
;     (global-set-key [f15] ' )                     ; FRONT..dont use
;     (global-set-key [f16] 'clipboard-kill-ring-save ) ; COPY..dont use
;     (global-set-key [f17] ' )                     ; OPEN..dont use
;     (global-set-key [f18] ' clipboard-yank)       ; PASTE..dont use
     (global-set-key [f19] 'search-forward)         ; FIND
;(global-set-key [f19] 'isearch-forward)
;(global-set-key [S-f19] 'isearch-backward)
;     (global-set-key [f20] 'clipboard-kill-region) ; CUT..dont use
;     (global-set-key [f21] ' )              ; f21
;     (global-set-key [f22] ' )              ; f22
;     (global-set-key [f23] ' )              ; f23
(global-set-key [f24] 'delete-char )          ; K- forward delete
;     (global-set-key [f25] ' )              ; K/
(global-set-key [f26] 'query-replace )        ; K*
(global-set-key [home] 'beginning-of-buffer )  ; K7
(global-set-key [f28] 'previous-line )        ; K8
(global-set-key [f29] 'scroll-down )          ; K9
(global-set-key [f30] 'backward-char )        ; K4
(global-set-key [f31] 'recenter )              ; K5
(global-set-key [f32] 'forward-char )         ; K6
(global-set-key [end] 'end-of-buffer )        ; K1
(global-set-key [f34] 'next-line )            ; K2
(global-set-key [f35] 'scroll-up )            ; K3
(global-set-key [S-right] 'forward-word )
(global-set-key [S-left ] 'backward-word )
(global-set-key [C-left] 'beginning-of-line )
(global-set-key [C-right ] 'end-of-line )



 ;;; - HERE -
(defvar background-mode 'light)
(defvar display-type 'color)
  ;; figure out background color.  We could ask the user, but that would be too easy
(cond
 ((and
   (fboundp 'device-type)
   (string= "x" (device-type)))
  (setq display-type (device-class)
       background-mode
       (condition-case nil
           (let ((bg-resource (x-get-resource ".backgroundMode" "BackgroundMode" 'string))
                 (params (frame-parameters)))
             (cond (bg-resource (intern (downcase bg-resource)))
                   ((and (cdr (assq 'background-color params))
                         (< (apply '+ (x-color-values
                                       (cdr (assq 'background-color params))))
                            (/ (apply '+ (x-color-values "white")) 3)))
                    'dark)
                   ((and (cdr (assq 'border-color params))
                         (> (apply '+ (color-instance-rgb-components
                                       (make-color-instance (cdr (assq 'border-color params)))))
                            (/ 255 3)))
                    'dark)
                   (t 'light)))
         (error 'light))
       )
  )
 ((and
   (boundp 'window-system)
   (string= window-system "x"))
  (setq display-type
       (condition-case nil
           (let ((display-resource (x-get-resource ".displayType" "DisplayType")))
             (cond (display-resource (intern (downcase display-resource)))
                   ((x-display-color-p) 'color)

                   ((x-display-grayscale-p) 'grayscale)
                   (t 'mono)))
         (error 'mono))
       )
  (setq background-mode
       (condition-case nil
           (let ((bg-resource (x-get-resource ".backgroundMode"
                                              "BackgroundMode" ))
                 (params (frame-parameters)))
             (cond (bg-resource (intern (downcase bg-resource)))
                   ((and (cdr (assq 'background-color params))
                         (< (apply '+ (x-color-values
                                       (cdr (assq 'background-color params))))
                            (/ (apply '+ (x-color-values "white")) 3)))
                    'dark)
                   ((and (fboundp 'color-instance-rgb-components )
                         (cdr (assq 'border-color params))
                         (> (apply '+ (color-instance-rgb-components
                                       (make-color-instance (cdr (assq 'border-color params)))))
                            (/ 255 3)))
                    'dark)
                   (t 'light)))
         (error 'light))
       )
  ))

(message "It appears you have a %s background" background-mode)

  (setq font-lock-use-default-fonts nil)
  (setq font-lock-use-default-colors nil)
  (require 'font-lock)
;  (set-face-underline-p 'font-lock-comment-face nil 'global 'tty)
;  (set-face-highlight-p 'font-lock-comment-face t 'global 'tty)
  (make-face-unitalic 'font-lock-comment-face)
  (make-face-unitalic 'font-lock-string-face)
  (copy-face 'bold 'font-lock-function-name-face)
  (set-face-foreground 'font-lock-comment-face "#efc80c")
  (set-face-foreground 'font-lock-function-name-face "red")
  (set-face-foreground 'font-lock-keyword-face "tan")
  (set-face-foreground 'font-lock-string-face  "lightskyblue")
  (set-face-foreground 'font-lock-type-face   "Aquamarine")
;  (find-face 'font-lock-preprocessor-face) ; 19.13 and above
;  (copy-face 'bold 'font-lock-preprocessor-face)

;  (font-lock-comment-face "#efc80c"               nil nil t nil)
;  (font-lock-function-name-face "red"             nil t   nil nil)
;  (font-lock-keyword-face "tan"           nil nil nil nil)
;  (font-lock-reference-face "indianred"         nil t nil nil)
;  (font-lock-string-face  "lightskyblue"  nil nil nil nil)
;  (font-lock-type-face      "Aquamarine"          nil nil nil nil)
;  (font-lock-variable-name-face "LightGoldenrod")

(message "progn")
          (progn
         (make-face 'my-font-lock-function-name-face)
         (set-face-foreground 'my-font-lock-function-name-face "red")
         (setq  font-lock-function-name-face 'my-font-lock-function-name-face)

         (make-face 'my-font-lock-keyword-face)
         (set-face-foreground 'my-font-lock-keyword-face "tan")
         (setq  font-lock-keyword-face  'my-font-lock-keyword-face)

         (make-face 'my-font-lock-string-face)
         (set-face-foreground 'my-font-lock-string-face      "lightskyblue")
         (setq  font-lock-string-face  'my-font-lock-string-face)

         (make-face 'my-font-lock-type-face)
         (set-face-foreground 'my-font-lock-type-face        "#efc80c") ; yellow
         (setq  font-lock-type-face  'my-font-lock-type-face)

         (make-face 'my-font-lock-variable-name-face)
         (set-face-foreground 'my-font-lock-variable-name-face "LightGoldenrod")
         (setq  font-lock-variable-name-face 'my-font-lock-variable-name-face)
         )
    
 (message "end progn")
    
;ok here
  ;; Pretty Colors in source windows.
  (require 'font-lock)
  (autoload 'turn-on-fast-lock "fast-lock"
    "Unconditionally turn on Fast Lock mode.")
  (add-hook 'c-mode-hook 'font-lock-mode)
  (add-hook 'verilog-mode-hook 'font-lock-mode)
  (add-hook 'perl-mode-hook 'font-lock-mode)
  (add-hook 'elisp-mode-hook 'font-lock-mode)
  (add-hook 'asm-mode-hook 'font-lock-mode)
  (setq fast-lock-cache-directories '("~/.backups" "."))
  (setq c-font-lock-keywords c-font-lock-keywords-2)
  (setq c++-font-lock-keywords c++-font-lock-keywords-2)
  (autoload 'verilog-make-faces "verilog-mode" "Set up faces for verilog")
         (set-face-background (quote region) "gray30")
