 (add-to-list 'load-path (locate-user-emacs-file "custom"))
 
 
-(defvar user-preferred-license "GPL-3"
+(defvar my-user-preferred-license "GPL-3"
   "License to use by default with some modes")
 
 (customize-set-variable 'user-mail-address "guiltydolphin@gmail.com")

;; Magit
(use-package magit
  :init
  (defvar evil-leader-magit-map
    (make-sparse-keymap "keymap for magit bindings under leader key"))
  (evil-leader/set-key
    "m" evil-leader-magit-map)
  :config
  (emaps-define-key evil-leader-magit-map
    "d" 'magit-diff-working-tree
    "s" 'magit-status))


    (mapcar (lambda (x) (date-to-time (concat wrap-start x wrap-end)))
            (list sunrise-time sunset-time))))

(defun my-time-greater-p (time1 time2)
  "Return non-nil if TIME1 is later than TIME2."
  (not (or (time-less-p time1 time2) (eq time1 time2))))

(defun my-location-sunrise-sunset (location)
  "Get the '(SUNRISE SUNSET) times for LOCATION."
  (let ((loc-name (car location))
        (loc-lat (cadr location))
        (loc-lon  (caddr location)))
    (my-sunrise-sunset-times loc-name loc-lat loc-lon)))

(defun my-date-in-daylight-hours (date)
  "Return non-nil if DATE is within the daylight hours for the current location.

Default to NIL if daylight times cannot be retrieved."
  (let* ((sunrise-sunset (my-location-sunrise-sunset my-location-loc))
         (sunrise-time (car sunrise-sunset))
         (sunset-time (cadr sunrise-sunset))
         (curr-time (or date (current-time))))
    (and sunrise-time sunset-time
         (my-time-greater-p curr-time sunrise-time) (time-less-p curr-time sunset-time))))

(defun my-get-background-mode-for-time-of-day (&optional date)
  "Return either 'light or 'dark based on whether DATE (or (current-time)) is during daylight
hours or not."
  (if (my-date-in-daylight-hours (or date (current-time))) 'light 'dark))

;; Color theme
(let ((bgmode (my-get-background-mode-for-time-of-day)))
  (set-frame-parameter nil 'background-mode bgmode)
  (set-terminal-parameter nil 'background-mode bgmode))
(load-theme 'solarized t)
