 (autoload 'magit-status "magit" nil t)
 (global-set-key (kbd "C-x m") 'magit-status)
 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; CLOJURE/SWANK/SLIME
-
-(show-paren-mode 1)
-
-(autoload 'clojure-mode "clojure-mode" nil t)
-
-(eval-after-load 'clojure-mode
-  '(progn
-     (require 'paredit)
-     (defun clojure-paredit-hook () (paredit-mode +1))
-     (add-hook 'clojure-mode-hook 'clojure-paredit-hook)
-     
-     (define-key clojure-mode-map "{" 'paredit-open-brace)
-     (define-key clojure-mode-map "}" 'paredit-close-brace)
-     (define-key paredit-mode-map (kbd "M-)") 'paredit-forward-slurp-sexp)
-     (define-key paredit-mode-map (kbd "M-[") nil)
-
-     ;; Custom indentation rules; see clojure-indent-function
-     (define-clojure-indent
-       (describe 'defun)
-       (testing 'defun)
-       (given 'defun)
-       (using 'defun)
-       (with 'defun)
-       (it 'defun)
-       (do-it 'defun))))
-
-(eval-after-load 'slime
-  '(setq slime-protocol-version 'ignore))
-
-(require 'elein)
-
-(setq inferior-lisp-program "~/bin/clj")
-
-(defun my-slime-repl ()
-  (interactive)
-  (if (slime-connected-p)
-      (slime-repl)
-    (slime-connect "localhost" 4005)))
-
-(global-set-key (kbd "C-c o r") 'my-slime-repl)
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; FILE ASSOCIATIONS

     (expand-file-name "~/.emacs.d/elpa/package.el"))
  (package-initialize))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Locally-installed packages (non-ELPA)



(global-set-key (kbd "C-c o a") 'my-agenda)

(defun org-fixup-buffer-whitespace ()
  (interactive)
  (goto-char (point-min))
  (while (search-forward-regexp "^\\*+" (point-max) t)
    (beginning-of-line)
    (newline)
    (forward-line 1)
    (newline)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; CLOJURE/LISP/NREPL

(show-paren-mode 1)

(autoload 'clojure-mode "clojure-mode" nil t)

(eval-after-load 'clojure-mode
  '(progn
     (require 'paredit)
     (defun clojure-paredit-hook () (paredit-mode +1))
     (add-hook 'clojure-mode-hook 'clojure-paredit-hook)
     
     (define-key clojure-mode-map "{" 'paredit-open-brace)
     (define-key clojure-mode-map "}" 'paredit-close-brace)
     (define-key paredit-mode-map (kbd "M-)") 'paredit-forward-slurp-sexp)
     (define-key paredit-mode-map (kbd "M-[") nil)

     ;; Custom indentation rules; see clojure-indent-function
     (define-clojure-indent
       (describe 'defun)
       (testing 'defun)
       (given 'defun)
       (using 'defun)
       (with 'defun)
       (it 'defun)
       (do-it 'defun))))

(require 'nrepl)

(global-set-key (kbd "C-c o r") 'nrepl-switch-to-repl-buffer)

(setq inferior-lisp-program "~/bin/clj")

(defun nrepl-refresh ()
  (interactive)
  (set-buffer "*nrepl*")
  (goto-char (point-max))
  (insert "(clojure.tools.namespace.repl/refresh)")
  (nrepl-return))

(defun nrepl-reset ()
  (interactive)
  (set-buffer "*nrepl*")
  (goto-char (point-max))
  (insert "(user/reset)")
  (nrepl-return))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; org-babel + Clojure

(when (locate-file "ob" load-path load-suffixes)
  (require 'ob)
