#+TITLE: lispy.el demo 5: ->>ification
#+LANGUAGE: en
#+OPTIONS: H:3 num:nil toc:nil
#+HTML_HEAD:
| [[https://github.com/abo-abo/lispy][Back to github]] | [[https://raw.githubusercontent.com/abo-abo/lispy/gh-pages/demo-5.org][This file in org-mode]] | [[http://abo-abo.github.io/lispy/][Function reference]] |
* Setup :noexport:
#+begin_src emacs-lisp :exports results :results silent
(load-file "make-html.el")
(setq org-export-filter-src-block-functions '(make-html-region))
(setq org-html-validation-link nil)
(setq org-html-postamble nil)
(setq org-html-preamble "")
(setq org-html-text-markup-alist
'((bold . "%s")
(code . "%s")
(italic . "%s")
(strike-through . "%s")
(underline . "%s")
(verbatim . "%s
")))
(setq org-html-style-default nil)
(setq org-html-head-include-scripts nil)
#+end_src
* 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:
#+begin_src clojure
|(map #(* % %) (filter odd? [1 2 3 4 5]))
#+end_src
to:
#+begin_src clojure
|(->> [1 2 3 4 5]
(filter odd?)
(map #(* % %)))
#+end_src
* 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 =->>=:
#+begin_src clojure
(->>| (map #(* % %) (filter odd? [1 2 3 4 5])))
#+end_src
** step 2
- ~C-f~ to get into special
- ~d~ to switch to the different side
- ~<~ to shrink list
#+begin_src clojure
(->> (map #(* % %))| (filter odd? [1 2 3 4 5]))
#+end_src
** step 3
- ~j~ to move the cursor down by one sexp
- ~<~ to shrink again
#+begin_src clojure
(->> (map #(* % %)) (filter odd?)| [1 2 3 4 5])
#+end_src
** step 4
- ~j~ to move the cursor down
- ~ww~ to move the expression up twice
#+begin_src clojure
(->> [1 2 3 4 5]| (map #(* % %)) (filter odd?))
#+end_src
** step 5
- ~js~ to select =map= and move it down once
#+begin_src clojure
(->> [1 2 3 4 5] (filter odd?) (map #(* % %))|)
#+end_src
** 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
#+begin_src clojure
(->> [1 2 3 4 5]
(filter odd?)
(map #(* % %)))|
#+end_src
#+BEGIN_HTML
#+END_HTML