Skip to content

Instantly share code, notes, and snippets.

Created December 24, 2013 13:58
What would you like to do?
my emacs live custom configuration
(setq inferior-lisp-program "lein repl")
(require 'package)
(add-to-list 'package-archives '("marmalade" . "") t)
(add-to-list 'package-archives '("melpa" . "") t)
(defun nrepl-send-to-repl ()
"Send the appropriate forms to the repl to be evaluated."
(let ((nrepl-proj-name
(format "*nrepl%s*"
(format "%s%s" nrepl-buffer-name-separator
(buffer-file-name (current-buffer)))))))
(clojure-buffer (current-buffer)))
;; Region selected - evaluate region
((not (equal mark-active nil))
(copy-region-as-kill (mark) (point)))
;; At/before sexp - evaluate next sexp
((or (looking-at "\s(")
(ignore-errors (forward-char 1))
(looking-at "\s(")))
(forward-list 1)
(let ((end (point))
(beg (save-excursion
(backward-list 1)
(copy-region-as-kill beg end)))
;; At/after sexp - evaluate last sexp
((or (looking-at "\s)")
(backward-char 1)
(looking-at "\s)")))
(if (looking-at "\s)")
(forward-char 1))
(let ((end (point))
(beg (save-excursion
(backward-list 1)
(copy-region-as-kill beg end)))
;; Default - evaluate enclosing top-level sexp
(kill-new (nrepl-expression-at-point))))
(dolist (buffer (buffer-list))
(when (string= nrepl-proj-name (buffer-name buffer))
(set-buffer buffer)))
(unless (eq (current-buffer) (window-buffer))
(pop-to-buffer (current-buffer) t))
;;(goto-char (point-max))
(set-buffer clojure-buffer))))
(global-set-key (kbd "C-c C-o") 'nrepl-send-to-repl)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment