Clojure Customizations

Clojure + Cider Keybindings of Interest

Key-Chord Command
C-c C-x Reload the current namespace
C-c , Run the current namespace's tests
C-c M-, Run one test
C-c C-, Re-run last test
C-c C-e Eval and print last s-exp


Set-up some local key-bindings. This will pull in clojure-mode as well.

(require-package 'cider)

(eval-after-load 'cider
     (define-key cider-mode-map (kbd "C-x M-e") 'repl/eval-and-print)
     (define-key cider-mode-map (kbd "<f3>")    'cider-eval-defun-at-point)
     (define-key cider-mode-map (kbd "<f5>")    'toby/save-and-eval-buffer)
     (define-key cider-mode-map (kbd "C-c C-e") 'cider-eval-print-last-sexp)))

Activate eldoc and paredit in Cider.

(defun toby/save-and-eval-buffer ()
  "Save open buffers and send the current buffer to the active Cider session."
  (save-some-buffers 't)

(add-hook 'cider-interaction-mode-hook 'cider-turn-on-eldoc-mode)
(toby/defhook cider-mode-hook (paredit-mode))


Paredit is my bestest friend

(defun toby/clojure-init ()
  (paredit-mode 1)

  ;; Compojure Macros:
    (defroutes 'defun)
    (GET 2)
    (POST 2)
    (PUT 2)
    (DELETE 2)
    (HEAD 2)
    (ANY 2)
    (context 2)))

(add-hook 'clojure-mode-hook 'toby/clojure-init)

Author: Toby Tripp

Created: 2015-02-04 Wed 10:55

Emacs 24.3.1 (Org mode 8.2.10)