Hi all,

I've recently added some Clojure support to
https://github.com/abo-abo/lispy.

A short description of the package is that it's all the Paredit
functions (and more) bound to unprefixed keys, e.g. "a", "c", "1", "2"
etc. Nothing to do with evil package. Keys call commands instead
of self-inserting when the point is in positions called special
(marked here with |):

    |(defn sqr |[x]| |(* x x)|)|

This comes together nicely since you rarely want to self-insert in those 
positions.

Just to show how succinct the usage can be, you can transform
from this:

    |(defn sqr [x] (* x x))

with just "4c" to this:

    |(defn sqr [x] (* x x))
    (defn sqr [x] (* x x))
    (defn sqr [x] (* x x))
    (defn sqr [x] (* x x))
    (defn sqr [x] (* x x))

and further with "3j" to this:

    (defn sqr [x] (* x x))
    (defn sqr [x] (* x x))
    (defn sqr [x] (* x x))
    |(defn sqr [x] (* x x))
    (defn sqr [x] (* x x))

and further with "2;" to this:

    (defn sqr [x] (* x x))
    (defn sqr [x] (* x x))
    (defn sqr [x] (* x x))
    ;; (defn sqr [x] (* x x))
    ;; (defn sqr [x] (* x x))

Here's another example that shows how to transform

    |(map sqr (filter odd? [1 2 3 4 5]))

to

    (->> [1 2 3 4 5]
         (map sqr)
         (filter odd?))|

I show it in a run-able test form (many more tests at github):

    (should
     (string=
      (lispy-with
       "|(map sqr (filter odd? [1 2 3 4 5]))" "2(->>]<]<]wwlM")
      "(->> [1 2 3 4 5]\n  (map sqr)\n  (filter odd?))|"))

The steps are:

1. "2(" - wrap with parens. 
2. "->>" - self-insert (because point isn't special).
3. "]" - forward list - point becomes special.
4. "<" - barf.
5. "]<]" - forward, barf, forward.
6. "ww" - move sexp up twice.
7. "l" - exit list forwards.
8. "M" - transform sexp to multi-line.
9. you can "e" - eval to see if code works.
    
Full description and some screenshots can be found at 
https://github.com/abo-abo/lispy.

Here's a list of Clojure-specific features (cider is used for most):

- look up doc inline in an overlay with "C-1"
- look up function arguments inline with "C-2"
- eval with "e"
- eval and insert with "E"
- goto symbol in file with "g" (clojure-semantic required)
- goto definition with "F"

The package is available in MELPA if you want to give it a go.
Feedback welcome.

regards,
Oleh



-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to