technomancy / slamhound

Slamhound rips your namespace form apart and reconstructs it.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Port Emacs support to using nrepl.el

technomancy opened this issue · comments

Current elisp implementation depends upon slime.

Not sure how you'd like to structure the nrepl code wrt the slime code, but here is a slamhound function that will work with nrepl.el:

(defun nrepl-slamhound ()
  "Run slamhound on the current buffer. Requires active nrepl connection."
  (interactive)
  (let* ((code (slamhound-clj-string buffer-file-name))
         (result (plist-get (nrepl-send-string-sync code) :stdout)))
    (if (string-match "^:error \\(.*\\)" result)
        (error (match-string 1 result))
      (goto-char (point-min))
      (kill-sexp)
      ;; TODO: translate \n into newline
      (insert result))))

If you'd like I can put it into a pull request.

Thanks Tim! I went ahead and adapted this to support both slime and nrepl.el at the same time since it's only a couple lines of code.