Closed ashercoren closed 8 years ago
Thanks for reporting! This is a known issue, and is the only irreconcilable inconsistency with the clojure indentation standards. When designing parinfer, I ran it against all clojure core repos to be sure that this was the only thing that had to go.
If it's any consolation, Parinfer is actually still compatible with the Clojure Style Guide, since it has a strict stance against indenting multi-arities that way. I brought up how this contradicts real-world usage to the style guide author here. You can read his response there.
So, from the perspectives of everyone involved:
I use the same indentation suggested in the style guide you mentioned. I always run into problems, though, when converting a function of single arity into a multiple arity one. I can't seem to find a way to wrap the old body around a new set of parenthesis without breaking the code:
(defn foo
"What I have."
[x]
(bar x))
(defn foo
"What I'd like next (before adding the other arity definition)."
([x]
(bar x)))
(defn foo
"What I actually get."
([x
(bar x)]))
I can't tell if it's parinfer or the editor -sublime- causing it. If it's parinfer, I wonder if that's a behaviour that could be changed.
Actually, nevermind, I just noticed I can avoid that by changing to paren
mode before adding the new parentheses.
@facundoolano yeah, it's a common enough hiccup. still thinking on alternate resolutions
When writing a multi arity functions, the regular way of writing it is:
Where each arity option has a list of parameters, followed by the function implementation. The function implementation is indented one level further than the list of parameters.
With indent mode, this automatically gets changed, since the function implementation is nested inside the variable list, so it gets changed to: