Permalink
Browse files

Make slamhound.el work as a swank payload.

  • Loading branch information...
1 parent c98d626 commit be6dd0e0842f728c3bc39f913fa4b3a40514e3df @technomancy committed Sep 20, 2011
Showing with 16 additions and 38 deletions.
  1. +14 −10 README.md
  2. +1 −0 resources/swank_elisp_payloads.clj
  3. +1 −28 { → src/swank/payload}/slamhound.el
View
@@ -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.2.0"]
+ $ lein plugin install slamhound 1.2.0
## Leiningen Usage
@@ -79,27 +79,31 @@ 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.
Emacs version 24 or greater is required.
## 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 @@
+["swank/payload/slamhound.el"]
@@ -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)))
-
;;;###autoload
(defun slamhound ()
"Run slamhound on the current buffer. Requires active slime connection."
(interactive)
(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))
(kill-sexp)
;; TODO: translate \n into newline
- (insert result)
- (slamhound-prettify))))
+ (insert result))))
;; Project-wide:

0 comments on commit be6dd0e

Please sign in to comment.