Fork me on GitHub
#parinfer
<
2017-08-28
>
shaunlebron00:08:24

@drewverlee looks like the author isn’t in the clojure community, and therefore not in this slack rom

shaunlebron00:08:26

oh, looks like @doglooksgood wrote it

Drew Verlee01:08:40

thanks @shaunlebron i’ll see if i can’t figure out why my setup doesn’t work.

cfleming06:08:49

Here’s an interesting problem I found today.

cfleming06:08:15

(reduce-kv (fn [m k v])
           {}
           {})

cfleming06:08:13

If I wrap this by just inserting (, then it works fine.

cfleming06:08:32

If I do it using Cursive’s paredit “wrap with parens” action, I get:

cfleming06:08:58

((reduce-kv (fn [m k v]
            {
            {}})))

cfleming06:08:11

Which is clearly not right at all.

cfleming06:08:29

This is because the wrap command auto-formats the form after wrapping. So there are 4 changes generated - insert closing ), insert opening (, then insert a single space at the start of lines 2 and 3.

cfleming06:08:11

The last two are due to the form being formatted at the end of the wrap action.

cfleming06:08:10

The problem is that the indent offset is incremented by the auto-format changes, but shouldn’t be.

cfleming06:08:52

I initially thought that perhaps I could ignore changes which were whitespace only when at the start of the line in the indent area, i.e. before any actual line content.

cfleming06:08:24

But if I do that, then:

(foo)
(bar {:a 1
      :b 2})

cfleming06:08:11

If I put the caret at the start of (bar and start pressing space, then the :b 2}) part won’t have its indentation corrected.

cfleming06:08:32

Any ideas for a heuristic that might work here?

cfleming06:08:52

Actually, having thought about it while doing the dishes, I’m not sure that’s actually the problem. I’ll debug and report back.

shaunlebron16:08:04

@cfleming: you’re right, this is a bug in parinfer

seancorfield16:08:39

That looks a bit like the bug I ran into trying the experimental "Smart Mode" last week. I haven't had time to repro yet but it was to do with paren-wrapping and it reformatted (and broke) my code.

seancorfield16:08:01

(that was with the current Parinfer package for Atom)

shaunlebron16:08:56

@seancorfield thanks for confirming, i’ll look into it. this happened when using with paredit?

seancorfield17:08:10

@shaunlebron Yes, using lisp-paredit package in Atom, with the slurp-forwards command, with Parinfer package and Smart Mode enabled.