;;;;;; Colors/Fonts

;; font lock everywhere
(global-font-lock-mode 1)

(defun eaw-zoom (amt)
  "Change font size globally. See also `text-scale-adjust'."
  (let* ((newval (+ (face-attribute 'default :height) amt)))
    (if (>= newval 70)
          (set-face-attribute 'default nil
                              :height newval)
      (message "Trying to set font too small!"))))
(global-set-key (kbd "C-+") '(lambda (arg) (interactive "p") (eaw-zoom (* 20 arg))))
(global-set-key (kbd "C-=") '(lambda (arg) (interactive "p") (eaw-zoom (* arg -20))))

(set-face-attribute 'default t :family "ProFont" :height 85)
(set-face-attribute 'fixed-pitch nil :family "ProFont" :height 85)

(set-face-background 'default "black")
(set-face-foreground 'default "white")
(setq frame-background-mode (quote dark))

;; ns_selection_color is yellow, which is bad for white text
(eval-after-load "ns-win" '(set-face-background 'region "blue3"))

;; diff-mode
(eval-after-load "diff-mode" '(lambda ()
                                (set-face-foreground 'diff-added "green")
                                (set-face-foreground 'diff-removed "red")))

;; info, jabber chat (aka "color-242" in xterm)
(defun eaw-set-colors (frame)
  (if (> (length (defined-colors frame)) 8)
      (set-face-background 'header-line "#6c6c6c" frame)
    (set-face-background 'header-line 'unspecified frame)))
(eaw-set-colors (selected-frame))
(add-hook 'after-make-frame-functions 'eaw-set-colors)

(setq mac-allow-anti-aliasing nil)

;; this brings up some bizarre font prompt
(global-unset-key (kbd "s-t"))

;; try to get all faces to conform
(defun list-nonconforming-faces ()
    (mapconcat 'symbol-name
               (let ((face-attribute-name-alist (delq nil (mapcar
                                                           (lambda (e)
                                                             (case (car e)
                                                               (:family e)
                                                               (:foundry e)
                                                               (:width e)
                                                               (:height e)
                                                               (:slant e)
                                                               (otherwise nil)))
                 (delq nil (mapcar (lambda (face) (if (face-differs-from-default-p face) face)) (face-list))))

(defun eaw-setup-info-faces ()
  (set-face-attribute 'info-node nil :slant 'normal)
  (set-face-attribute 'info-menu-header nil :inherit 'default)
  (set-face-attribute 'info-title-4 nil :inherit 'default)
  (set-face-attribute 'info-title-3 nil :height 'unspecified)
  (set-face-attribute 'info-title-2 nil :height 'unspecified)
  (set-face-attribute 'info-title-1 nil :height 'unspecified))

(add-hook 'Info-mode-hook 'eaw-setup-info-faces)

(provide 'ew-font)