Skip to content

Instantly share code, notes, and snippets.

@MikeInnes
Last active Dec 20, 2015
Embed
What would you like to do?
;; Paredit's features (http://www.youtube.com/watch?v=D6h5dFyyUX0)
;; in clojure/clarity.
;; All examples can be done quickly with the keyboard in e.g.
;; Sublime Text - no plugins required.
defn my-command []
(interactive)
save-excursion
(do-some-things)
(do-more-things)
(conclude-doing-things)
;; Adding/removing args to `save-excursion` becomes a simple
;; case of (un) indenting the line.
defn my-command []
(interactive)
save-excursion
(do-some-things)
(do-more-things)
(conclude-doing-things)
;; Flipping `let` and `when` is just as easy
defn another-command []
let [v (calculate-v)
x (calculate-x)]
when (and (some-predicate)
(some-other-predicate))
(do-that-thing)
(do-something-more)
(do-even-more)
;; Just swap the lines and change the indent.
defn another-command []
when (and (some-predicate)
(some-other-predicate))
let [v (calculate-v)
x (calculate-x)]
(do-that-thing)
(do-something-more)
(do-even-more)
;; We can also temporarily comment out outer
;; forms much more easily.
defn another-command []
; let [v (calculate-v)
; x (calculate-x)]
when (and (some-predicate)
(some-other-predicate))
(do-that-thing)
(do-something-more)
(do-even-more)
defn another-command []
let [v (calculate-v)
x (calculate-x)]
; when (and (some-predicate)
; (some-other-predicate))
(do-that-thing)
(do-something-more)
(do-even-more)
;; Removing forms is often a simple case of
;; removing the lines. This makes it *much*
;; easier to temporarily comment sub-forms
;; out - no parens to worry about.
defn some-command []
do-stuff "this here is a string" 123
do-stuff
more-stuff "something"
"and more"
defn some-command []
do-stuff "this here is a string" 123
do-stuff
more-stuff "something"
; "and more"
defn some-command []
do-stuff "this here is a string" 123
; do-stuff
; more-stuff "something"
; "and more"
;; "Splitting" and "joining" are just adding
;; or removing a newline - easy.
defn some-command []
do-stuff "this here"
do-stuff " is a string" 123
ns test
:require [clojure.string :as str]
:require [clojure.core.async :as async]
:require [clojure.data.zip :as zip]
;; Just select the second require, Ctrl+D
;; to select both, tab to align.
ns test
:require [clojure.string :as str]
[clojure.core.async :as async]
[clojure.data.zip :as zip]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment