 ;; org
 (use-package org
   :init
-  (defvar evil-leader-org-map
+  (defvar my-evil-leader-org-map
     (make-sparse-keymap "leader org-mode map"))
 
-  (emaps-define-key evil-leader-org-map
+  (emaps-define-key my-evil-leader-org-map
     "a" 'org-agenda
     "c" 'org-capture
     "l" 'org-store-link
     "s" 'org-switchb)
   :config
-  (defun org-subdir (path)
+  (defun my-org-subdir (path)
     "Return PATH under ORG-DIRECTORY"
     (concat org-directory "/" path))
 
-  (customize-set-variable 'org-agenda-files `(,(org-subdir "todo.org") ,(org-subdir "homework.org")))
+  (customize-set-variable 'org-agenda-files `(,(my-org-subdir "todo.org") ,(my-org-subdir "homework.org")))
 
   (customize-set-variable 'org-default-notes-file (concat org-directory "/notes.org"))
 
   (evil-leader/set-key
-    "o" evil-leader-org-map)
+    "o" my-evil-leader-org-map)
   (setq org-capture-templates
-        `(("t" "Todo" entry (file+headline ,(org-subdir "todo.org") "Tasks")
+        `(("t" "Todo" entry (file+headline ,(my-org-subdir "todo.org") "Tasks")
            "* TODO %?\n  %i\n  %a")
-          ("j" "Journal" entry (file+datetree ,(org-subdir "journal.org"))
+          ("j" "Journal" entry (file+datetree ,(my-org-subdir "journal.org"))
            "* %?\nEntered on %U\n  %i\n  %a"))))
 
 ;; Other commands

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

(defun 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 location-sunrise-sunset (location)
  "Get the '(SUNRISE SUNSET) times for LOCATION."
  (let ((loc-name (car location))
        (loc-lat (cadr location))
        (loc-lon  (caddr location)))
    (sunrise-sunset-times loc-name loc-lat loc-lon)))

(defun 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 (location-sunrise-sunset location-loc))
         (sunrise-time (car sunrise-sunset))
         (sunset-time (cadr sunrise-sunset))
         (curr-time (or date (current-time))))
    (and sunrise-time sunset-time
         (time-greater-p curr-time sunrise-time) (time-less-p curr-time sunset-time))))

(defun 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 (date-in-daylight-hours (or date (current-time))) 'light 'dark))

;; Color theme
(let ((bgmode (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)

  (define-key evil-window-map "t" 'evil-window-right) ; Replaces evil-window-top-left
  (define-key evil-window-map "-" 'evil-window-split) ; Replaces evil-window-set-width
  (define-key evil-window-map "|" 'evil-window-vsplit) ; Replaces evil-window-decrease-height
  (define-key evil-window-map "x" 'my-kill-buffer-and-window-ask)
  (define-key evil-window-map "s" 'ido-switch-buffer)
  (global-set-key (kbd "C-w") 'nil)

