lispy.el demo 5: ->>ification
| Back to github | This file in org-mode | Function reference |
Intro
This demo covers some very basic lispy commands such as:
- move code up/down with w / s
- grow/shrink current list with > / <
Task summary
Transform from:
( map #(* % %) (filter odd? [1 2 3 4 5]))
to:
( ->> [1 2 3 4 5]
(filter odd?)
(map #(* % %)))
Screencast
The screencast for this demo is here: http://youtu.be/N7C3FX4mr_o
Step-by-step expansion
step 1
2( to wrap with parens, enter ->>:
(->> (map #(* % %) (filter odd? [1 2 3 4 5])))
step 2
- C-f to get into special
- d to switch to the different side
- < to shrink list
(->> (map #(* % %)) (filter odd? [1 2 3 4 5]))
step 3
- j to move the cursor down by one sexp
- < to shrink again
(->> (map #(* % %)) (filter odd?) [1 2 3 4 5])
step 4
- j to move the cursor down
- ww to move the expression up twice
(->> [1 2 3 4 5] (map #(* % %)) (filter odd?))
step 5
- js to select
mapand move it down once
(->> [1 2 3 4 5] (filter odd?) (map #(* % %))< /span>)
step 6
- C-f or C-3 to exit the list (l should work as well since the point is still special)
- M to multiline
(->> [1 2 3 4 5]
(filter odd?)
(map #(* % %)))< /span>