Skip to content

Instantly share code, notes, and snippets.

@jgrodziski
Created December 24, 2013 13:58
Show Gist options
  • Save jgrodziski/8113761 to your computer and use it in GitHub Desktop.
Save jgrodziski/8113761 to your computer and use it in GitHub Desktop.
my emacs live custom configuration
(setq inferior-lisp-program "lein repl")
(require 'package)
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/") t)
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)
(windmove-default-keybindings)
(defun nrepl-send-to-repl ()
"Send the appropriate forms to the repl to be evaluated."
(interactive)
(save-excursion
(let ((nrepl-proj-name
(format "*nrepl%s*"
(format "%s%s" nrepl-buffer-name-separator
(nrepl--project-name
(file-name-directory
(buffer-file-name (current-buffer)))))))
(clojure-buffer (current-buffer)))
(cond
;; 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(")
(save-excursion
(ignore-errors (forward-char 1))
(looking-at "\s(")))
(forward-list 1)
(let ((end (point))
(beg (save-excursion
(backward-list 1)
(point))))
(copy-region-as-kill beg end)))
;; At/after sexp - evaluate last sexp
((or (looking-at "\s)")
(save-excursion
(backward-char 1)
(looking-at "\s)")))
(if (looking-at "\s)")
(forward-char 1))
(let ((end (point))
(beg (save-excursion
(backward-list 1)
(point))))
(copy-region-as-kill beg end)))
;; Default - evaluate enclosing top-level sexp
(t
(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))
(yank)
(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