parinfer

shaunlebron 2017-08-28T00:42:24.000117Z

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

shaunlebron 2017-08-28T00:42:36.000065Z

might wanna ask in the issue here: https://github.com/syl20bnr/spacemacs/issues/5574

shaunlebron 2017-08-28T00:43:26.000005Z

oh, looks like @doglooksgood wrote it

2017-08-28T01:02:40.000176Z

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

cfleming 2017-08-28T06:31:49.000066Z

Here’s an interesting problem I found today.

cfleming 2017-08-28T06:32:15.000077Z

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

cfleming 2017-08-28T06:33:13.000129Z

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

cfleming 2017-08-28T06:33:32.000186Z

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

cfleming 2017-08-28T06:33:58.000183Z

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

cfleming 2017-08-28T06:34:11.000165Z

Which is clearly not right at all.

cfleming 2017-08-28T06:35:29.000066Z

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.

cfleming 2017-08-28T06:36:11.000121Z

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

cfleming 2017-08-28T06:37:10.000239Z

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

cfleming 2017-08-28T06:37:52.000151Z

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.

cfleming 2017-08-28T06:38:24.000259Z

But if I do that, then:

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

cfleming 2017-08-28T06:39:11.000014Z

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.

cfleming 2017-08-28T06:39:32.000150Z

Any ideas for a heuristic that might work here?

cfleming 2017-08-28T06:57:52.000122Z

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

shaunlebron 2017-08-28T16:35:04.000236Z

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

shaunlebron 2017-08-28T16:39:36.000323Z

tracking here: https://github.com/shaunlebron/parinfer/issues/173

seancorfield 2017-08-28T16:45:39.000275Z

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.

seancorfield 2017-08-28T16:46:01.000093Z

(that was with the current Parinfer package for Atom)

shaunlebron 2017-08-28T16:53:56.000471Z

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

seancorfield 2017-08-28T17:20:10.000237Z

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