Fork me on GitHub
#emacs
<
2021-08-31
>
afleck18:08:15

I’m running into an issue with indentation and threading macros, as they are specified as having 1 special form, but fairly often we’re threading things into threading macros, usually with cond->, like

(cond-> x
  :always inc
  (even? x) (cond->
                (< x 10) (* 2)
                :else (+ 5)))
so the second cond-> has no special form. the indent on the second cond-> looks kind of unpleasant and cljfmt complains about it (suggesting a 1-space indent which is inconsistent with the first cond->) my setup indentation-wise is stock clojure-mode/`cider` as far as i can tell. an indent specification of (cond-> :defn) looks a bit better:
(cond-> x
  :always inc
  (even? x) (cond->
              (< x 10) (* 2)
              :else (+ 5)))
but cljfmt still complains about this, saying the indentation on the second cond should be 1 space. so is there an accepted style for things like this? and a way to get clojure-mode and cljfmt to play nicely together?

vemv19:08:16

> so is there an accepted style for things like this? avoidance :) https://stuartsierra.com/2018/07/06/threading-with-style

afleck19:08:17

ah i’ve been looking for something like this, thank you. my suspicion was that theres a better idiom

🍻 1