Browse files

Make slamhound.el work as a swank payload.

  • Loading branch information...
1 parent 2b1598f commit 63ddcd708adfb84c6bc69e67a18b258831af5372 @technomancy committed Sep 20, 2011
Showing with 16 additions and 38 deletions.
  1. +14 −10
  2. +1 −0 resources/swank_elisp_payloads.clj
  3. +1 −28 { → src/swank/payload}/slamhound.el
@@ -25,9 +25,9 @@
Slamhound rips your ns form apart and reconstructs it. No Dutch
surgeon required.
-Add it to your :dev-dependencies.
+Install it as a Leiningen plugin:
- [slamhound "1.1.1"]
+ $ lein plugin install slamhound 1.1.1
## Leiningen Usage
@@ -79,25 +79,29 @@ You can do it manually from the repl too:
## Emacs Usage
-The included slamhound.el allows for convenient access within Slime
-sessions via M-x slamhound as well as running it over an entire
-project with M-x slamhound-project.
+The included `src/swank/payload/slamhound.el` allows for
+convenient access within Slime sessions via `M-x slamhound` as well as
+running it over an entire project with `M-x slamhound-project`.
+You can install manually, but if you use `M-x clojure-jack-in` with
+Swank Clojure 1.3.3 or newer to launch your Slime session then it will
+be loaded into Emacs automatically.
## The Rules
Slamhound can only rebuild your namespace if it follows the rules and
-doesn't do anything too fancy. If your code depends upon a
-:require clause, the required namespace must be aliased :as the last
-segment of its name. The only supported option to :use is :only.
+doesn't do anything too fancy. If your code depends upon a `:require`
+clause, the required namespace must be aliased `:as` the last segment
+of its name. Referring to fully-qualified vars is not supported. The
+only supported option to `:use` is `:only`.
## Future Plans
* Better pretty-printing
-* Piggy-backing elisp inside jar
* Allow for custom disambiguator functions
## License
-Copyright (C) 2011 Phil Hagelberg
+Copyright © 2011 Phil Hagelberg
Distributed under the Eclipse Public License, the same as Clojure.
@@ -0,0 +1 @@
@@ -52,45 +52,18 @@
(catch Exception e
(println :error (.getMessage e)))))))
-(defun slamhound-point-at-end-of-sexp (start)
- (save-excursion (goto-char start) (end-of-sexp) (point)))
-(defun slamhound-prettify-subclause ()
- (backward-char 2)
- (let ((beginning-of-sexp (point)))
- (while (search-forward-regexp "[ \n]" (slamhound-point-at-end-of-sexp
- beginning-of-sexp) t)
- (just-one-space -1))))
-(defun slamhound-prettify-clause (clause)
- (just-one-space -1)
- (beginning-of-line)
- (let ((end-of-clause (save-excursion (end-of-sexp) (point))))
- (while (search-forward-regexp "[(\\[][a-z]" end-of-clause t)
- (slamhound-prettify-subclause))))
-(defun slamhound-prettify ()
- (interactive)
- (goto-char (point-min))
- (let ((end-of-ns (save-excursion (end-of-defun) (point))))
- (while (search-forward-regexp "(:\\([-a-z]+\\)" end-of-ns t)
- (slamhound-prettify-clause (match-string 0)))
- (indent-region (point-min) end-of-ns)))
(defun slamhound ()
"Run slamhound on the current buffer. Requires active slime connection."
(let* ((code (slamhound-clj-string buffer-file-name))
(result (first (slime-eval `(swank:eval-and-grab-output ,code)))))
- (setq rrr result)
(if (string-match "^:error \\(.*\\)" result)
(error (match-string 1 result))
(goto-char (point-min))
;; TODO: translate \n into newline
- (insert result)
- (slamhound-prettify))))
+ (insert result))))
;; Project-wide:

0 comments on commit 63ddcd7

Please sign in to comment.