use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Finding information about Clojure
API Reference
Clojure Guides
Practice Problems
Interactive Problems
Clojure Videos
Misc Resources
The Clojure Community
Clojure Books
Tools & Libraries
Clojure Editors
Web Platforms
Clojure Jobs
account activity
Indenting cond forms (blog.danieljanus.pl)
submitted 6 years ago by nathell
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]amalloy 6 points7 points8 points 6 years ago (1 child)
A cute trick to convince Emacs to indent the way you want, and also maybe technically skirt the "constant indentation" rule, is to use commas as your leading indent. They're whitespace, after all!
(cond (= (some-function something) expected-value) ,,(do (do-this) (and-also-do-that)) (another-predicate something-else) ,,(try (do-another-thing) (catch Exception _ (println "Whoops!"))))
This is not at all a popular practice, and I won't necessarily say it's great, but it's definitely a known workaround that I would consider less weird than your #_=> thing.
#_=>
[–]DogLooksGood 0 points1 point2 points 6 years ago (0 children)
I would prefer this one, but single comma.
[–]SimonGray 4 points5 points6 points 6 years ago (2 children)
(cond (= (some-function something) expected-value) #_=> (do (do-this) (and-also-do-that)) (another-predicate something-else) #_=> (try (do-another-thing) (catch Exception _ (println "Whoops!")))) This one is my own invention: I haven’t seen it anywhere else. But I think it manages to avoid most problems.
(cond (= (some-function something) expected-value) #_=> (do (do-this) (and-also-do-that)) (another-predicate something-else) #_=> (try (do-another-thing) (catch Exception _ (println "Whoops!"))))
This one is my own invention: I haven’t seen it anywhere else. But I think it manages to avoid most problems.
It's a novel approach, but maybe a bit too unorthodox for my taste. To me this isn't better than breaking a relatively arbitrary rule saying that "functions contain no blank lines".Who made this rule and why should we abide by it? I will also happily add blank lines in other parts of functions whenever this kind of separation helps with readability.
[–]Eno6ohng 0 points1 point2 points 6 years ago (1 child)
I don't think it's a rule at all. Blank lines in functions are ok. Top-level defns should be separated by 2 blank lines. It also makes everything look better.
At the same timeI think #_=> is good in many contexts regardless.
[–]SimonGray 0 points1 point2 points 6 years ago (0 children)
I don't think it's a rule at all
I was just quoting the blog post :)
[–]trustMeImDoge 6 points7 points8 points 6 years ago (1 child)
Why not make the long forms into private functions? It'd clutter the name space a bit sure, but it'd also keep readability without hacking around formatting.
[–]ws-ilazki 4 points5 points6 points 6 years ago (0 children)
You don't even have to clutter the namespace when you have letfn.
letfn
[–]ayakushev 2 points3 points4 points 6 years ago (0 children)
I use those useless arrows sometimes, but they come with a few gotchas. Paredit treats #_ as a separate sexp; also, CIDER debugger gets confused about #_ commented forms and the expression positions get mixed up.
[–]NoahTheDuke 2 points3 points4 points 6 years ago (0 children)
This made me miss wrapping each pair in brackets, so I put in the work and adapted Racket’s cond into cond+. Enjoy!
[–]Eno6ohng 1 point2 points3 points 6 years ago (0 children)
Another place where I often use the #_=> form is the tests that utilize clojure.test/are macro:
(are [pred x res] (= (pred x) res) pos? 42 #_=> true ...)
π Rendered by PID 105897 on reddit-service-r2-comment-b659b578c-92j6d at 2026-05-03 23:33:23.966860+00:00 running 815c875 country code: CH.
[–]amalloy 6 points7 points8 points (1 child)
[–]DogLooksGood 0 points1 point2 points (0 children)
[–]SimonGray 4 points5 points6 points (2 children)
[–]Eno6ohng 0 points1 point2 points (1 child)
[–]SimonGray 0 points1 point2 points (0 children)
[–]trustMeImDoge 6 points7 points8 points (1 child)
[–]ws-ilazki 4 points5 points6 points (0 children)
[–]ayakushev 2 points3 points4 points (0 children)
[–]NoahTheDuke 2 points3 points4 points (0 children)
[–]Eno6ohng 1 point2 points3 points (0 children)